> ## Documentation Index
> Fetch the complete documentation index at: https://docs.1to1ai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> What a WhatsApp template is and when you need one to send.

A **template** is a message pre-approved by Meta. It is the only message type
you can send when the **24-hour window is closed** — that is, when the contact
hasn't written to you in the last 24 hours. While the window is open you can
send free text; once it closes, only a template will reach the customer.

<Note>
  Templates are created and approved in the dashboard. The public API only
  **consumes** them to send — it does not create or edit them.
</Note>

## How a template is resolved

<Steps>
  <Step title="Identify the template by name">
    A template is identified by its `template_name` — the same name you see in
    the dashboard and report to Meta.
  </Step>

  <Step title="Specify the language if needed">
    If the same name is approved in several languages, add `language` (Meta
    `lower_UPPER` format, e.g. `en_US`) to pick which one to send. If it exists
    in only one language, it is optional.
  </Step>

  <Step title="Verify it is approved">
    Only templates with status **`APPROVED`** can be sent. One in `PENDING` or
    `REJECTED` is not sendable.
  </Step>
</Steps>

## Template components

When sending a template you fill in its dynamic parts:

<CardGroup cols={3}>
  <Card title="body_variables" icon="brackets-curly">
    The body placeholders (`{{1}}`, `{{2}}`, ...). Array of objects
    `{ index, value }`.
  </Card>

  <Card title="header" icon="image">
    The header: text, or media via `file_uuid`.
  </Card>

  <Card title="button_parameters" icon="link">
    Parameters for dynamic buttons (e.g. the suffix of a URL button).
  </Card>
</CardGroup>

## Sending a template

A typical send, with two variables in the body:

```bash theme={null}
curl -X POST "https://app.1to1.ai/api/v1/public/{slug}/conversation/messages/template" \
  -H "Authorization: Bearer sk_1to1_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "conversation": { "phone": "+5215512345678" },
    "template_name": "appointment_confirmation",
    "language": "en_US",
    "body_variables": [
      { "index": 1, "value": "Ana" },
      { "index": 2, "value": "10:00 AM" }
    ]
  }'
```

<Tip>
  To discover which templates you have available and what variables each one
  expects, query the template catalog endpoints in the API Reference.
</Tip>

## Test templates for tester conversations

The dashboard lets you create **test templates** (`status: FAKE`) from the
Tester module without going through Meta's approval. They exist so operators
and integrators can test flows against tester conversations without waiting
for Meta review.

Sending rules via the public API:

* **Tester conversation** (`is_tester: true` in `GET /conversations`) — you
  can send both APPROVED templates and FAKE templates. The send replicates
  the real flow but does not hit Meta (`wamid` returns `""`).
* **Real conversation** (`is_tester: false`) — **only** APPROVED templates.
  If you try to send a FAKE template or a template with `is_tester: true` to
  a real conversation, the API responds with
  `TEMPLATE_FAKE_REQUIRES_TESTER_CONVERSATION` (422).

The public catalog (`GET /templates` and `GET /templates/{name}/{language}`)
does not include FAKE templates — only real APPROVED ones. If you need the
name of a FAKE template to send it, ask the operator.

## Next steps

<CardGroup cols={2}>
  <Card title="Send messages" icon="paper-plane" href="/en/messages">
    Sending templates, text, media, and quick replies.
  </Card>

  <Card title="Conversations" icon="comments" href="/en/conversations">
    The 24-hour window and the state of a conversation.
  </Card>
</CardGroup>
