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

# Template

> Envie uma mensagem usando um template aprovado pela Meta

<Note>
  Templates precisam estar com status `APPROVED` antes de serem usados. Crie em [Templates → Criar](/api-reference/templates/create).
</Note>

<ParamField body="messaging_product" type="string" required default="whatsapp" />

<ParamField body="to" type="string" required placeholder="5511999999999">
  Número do destinatário no formato E.164 sem o `+`.
</ParamField>

<ParamField body="recipient_type" type="string" default="individual" />

<ParamField body="type" type="string" required default="template" />

<ParamField body="context" type="object">
  Para responder uma mensagem. Inclua `message_id` da mensagem original.
</ParamField>

<ParamField body="template" type="object" required>
  <Expandable title="campos" defaultOpen>
    <ParamField body="template.name" type="string" required placeholder="order_confirmation">
      Nome exato do template.
    </ParamField>

    <ParamField body="template.language" type="object" required>
      <Expandable title="campos" defaultOpen>
        <ParamField body="template.language.code" type="string" required placeholder="pt_BR">
          Código do idioma. Ex: `pt_BR`, `en_US`.
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="template.components" type="array">
      Variáveis e cabeçalho do template. Veja exemplos abaixo.
    </ParamField>
  </Expandable>
</ParamField>

## Exemplos

<Tabs>
  <Tab title="Só variáveis no body">
    ```json theme={null}
    {
      "messaging_product": "whatsapp",
      "to": "5511999999999",
      "type": "template",
      "template": {
        "name": "order_confirmation",
        "language": { "code": "pt_BR" },
        "components": [
          {
            "type": "body",
            "parameters": [
              { "type": "text", "text": "João" },
              { "type": "text", "text": "#12345" }
            ]
          }
        ]
      }
    }
    ```
  </Tab>

  <Tab title="Header com imagem + variáveis">
    ```json theme={null}
    {
      "messaging_product": "whatsapp",
      "to": "5511999999999",
      "type": "template",
      "template": {
        "name": "promo_imagem",
        "language": { "code": "pt_BR" },
        "components": [
          {
            "type": "header",
            "parameters": [
              { "type": "image", "image": { "link": "https://example.com/promo.jpg" } }
            ]
          },
          {
            "type": "body",
            "parameters": [
              { "type": "text", "text": "50%" }
            ]
          }
        ]
      }
    }
    ```
  </Tab>

  <Tab title="Botão com parâmetro dinâmico">
    ```json theme={null}
    {
      "messaging_product": "whatsapp",
      "to": "5511999999999",
      "type": "template",
      "template": {
        "name": "rastreio_pedido",
        "language": { "code": "pt_BR" },
        "components": [
          {
            "type": "body",
            "parameters": [
              { "type": "text", "text": "#12345" }
            ]
          },
          {
            "type": "button",
            "sub_type": "url",
            "index": "0",
            "parameters": [
              { "type": "text", "text": "12345ABC" }
            ]
          }
        ]
      }
    }
    ```
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 theme={null}
  {
    "messaging_product": "whatsapp",
    "contacts": [{ "input": "5511999999999", "wa_id": "5511999999999" }],
    "messages": [{ "id": "wamid.HBgLNTUxMTk5OTk5OTk5..." }]
  }
  ```
</ResponseExample>
