---
docId: doc_167db9f94f6149cd8c658aa14fa706a9
title: Send WhatsApp templates
description: "Create a WhatsApp template, wait for Meta's approval and send it to a contact."
---

<script>
  import { Note, Steps, Ways } from '$lib/components';
</script>

# Send WhatsApp templates

<span id="what-youll-build"></span>

Create a WhatsApp template and send it to a contact once Meta approves it. Then read its results. To message the contact outside the 24-hour service window, use an approved template.

## Before you start

You need a [connected WhatsApp number](/help/integrations/whatsapp/connect-number) in the workspace and your Platica API key in `PLATIC_API_KEY`.

Check [Meta's guidelines](https://developers.facebook.com/docs/whatsapp/message-templates/guidelines) for names, categories and content before creating the template.

To use the platform, see [Manage your WhatsApp number](/help/integrations/whatsapp/manage).

<Steps>
<Steps.Step>

**Find your WhatsApp number**

The `prefixedChannelId` of a WhatsApp channel (it starts with `wb-`) is the `channelId` you send messages from. ([List channels](/api-reference/channels/list))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/channels \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });

const channels = await platic.channels.list();
const whatsapp = channels.filter((channel) => channel.prefixedChannelId?.startsWith("wb-"));
for (const channel of whatsapp) {
  console.log(channel.prefixedChannelId, channel.displayPhoneNumber, channel.health.state);
}
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Which WhatsApp numbers do I have connected?

</Ways.Say>

Tool: [`list_channels`](/mcp/tools#list_channels).

</Ways.Way>
</Ways>

Keep the number's `prefixedChannelId` in `CHANNEL_ID`.

</Steps.Step>
<Steps.Step>

**Create the template**

Platica creates it in the workspace's WhatsApp Business account (WABA) and sends it to Meta's review. It starts as `PENDING` and can't be sent until Meta approves it. Every variable (`{{1}}`, `{{2}}`) needs an example value. ([Create a template](/api-reference/whatsapp-templates/create))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/whatsapp/templates \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "order_ready",
    "language": "es_MX",
    "category": "UTILITY",
    "components": [
      {
        "type": "BODY",
        "text": "Hola {{1}}, tu pedido {{2}} está listo para recoger.",
        "example": { "body_text": [["Ana", "A-1024"]] }
      },
      { "type": "FOOTER", "text": "Acme" }
    ]
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const template = await platic.whatsapp.templates.create({
  name: "order_ready",
  language: "es_MX",
  category: "UTILITY",
  components: [
    {
      type: "BODY",
      text: "Hola {{1}}, tu pedido {{2}} está listo para recoger.",
      example: { body_text: [["Ana", "A-1024"]] },
    },
    { type: "FOOTER", text: "Acme" },
  ],
});
console.log(template.status, template.nextStep);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Create a utility template in Spanish (Mexico) called order_ready that tells a customer their order is ready to pick up. It takes the customer's name and the order number.

</Ways.Say>

Tool: [`create_whatsapp_template`](/mcp/tools#create_whatsapp_template).

</Ways.Way>
</Ways>

`name` takes only lowercase letters, numbers and underscores, and it is the name you use when you send. `category` is `MARKETING`, `UTILITY` or `AUTHENTICATION`. `language` is a Meta language code, like `es`, `es_MX` or `en_US`.

If the workspace has several WhatsApp Business accounts, send `wabaId` with the one the template belongs to. Without it the error is `WABA_REQUIRED` and `details.available` lists them. For an image, video or document header, put the file's public URL in `example.header_url`.

</Steps.Step>
<Steps.Step>

**Wait for Meta's review**

Check the template's status and wait for `APPROVED` before sending it. The review time depends on Meta. ([Get a template](/api-reference/whatsapp-templates/get))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl "https://api.platic.ai/v1/whatsapp/templates/order_ready?language=es_MX" \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const current = await platic.whatsapp.templates.get("order_ready", { language: "es_MX" });
console.log(current.status, current.languages);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Did Meta approve the order_ready template?

</Ways.Say>

Tool: [`get_whatsapp_template`](/mcp/tools#get_whatsapp_template).

</Ways.Way>
</Ways>

The name and language identify a template version: `order_ready` in `es_MX` and in `en_US` are different versions. If you omit `language`, you receive the only available version or, if there are several, an approved one.

To receive approval or rejection on your server, subscribe a webhook to `template.status.updated`. See [Receive webhooks](/guides/webhooks) and [Payloads](/api-reference/webhooks/payloads#whatsapp-templates).

</Steps.Step>
<Steps.Step>

**Send it**

Send the approved template to a contact. If there is an open conversation with them, the message joins it; if not, a new one is created. `conversationId` is the contact's phone number in E.164 format, without `+`. ([Send a template message](/api-reference/messages/send-template))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/messages/template \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channelId": "'$CHANNEL_ID'",
    "conversationId": "5215512345678",
    "responderAgentId": "'$AGENT_ID'",
    "template": {
      "name": "order_ready",
      "language": "es_MX",
      "params": ["Ana", "A-1024"]
    }
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
if (current.status !== "APPROVED") {
  throw new Error(`order_ready is ${current.status}: only an approved template can be sent`);
}

// api_example is a ready template filled with the example values: replace the ones you need.
const sent = await platic.messages.sendTemplate({
  channelId: process.env.CHANNEL_ID!,
  conversationId: "5215512345678",
  responderAgentId: process.env.AGENT_ID!,
  template: { ...current.api_example, language: current.language, params: ["Ana", "A-1024"] },
});
console.log(sent.messageId, sent.status);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Send the order_ready template to 5215512345678 from my WhatsApp number, with the name Ana and the order number A-1024. Have the Sales agent handle the replies.

</Ways.Say>

Tool: [`send_template_message`](/mcp/tools#send_template_message).

</Ways.Way>
</Ways>

`params` must match **exactly** the number of variables in the template. `channelId` and `responderAgentId` are independent: the first decides which number sends, the second which agent handles the replies. Without `responderAgentId`, a new conversation has no agent and, when the contact replies, a person has to take it.

To send later, use `delay` (3 seconds to 24 hours, in milliseconds) or `scheduleTime` (ISO 8601, up to 30 days ahead), never both. Then you can [check, reschedule or cancel it](/api-reference/messages/scheduled) by `messageId`.

<Note type="important">

The message reaches the selected number. Check the Meta fees that apply to the template. Send your first one to your own number.

</Note>

</Steps.Step>
</Steps>

## Check it worked

Check `messageId` and `status` in the response. After the message is sent, find the conversation in the inbox. If you scheduled it, wait for the send date.

Use [Template analytics](/api-reference/whatsapp-templates/analytics) to see sent, delivered, read, clicked and cost, by period and day.

```bash
curl "https://api.platic.ai/v1/whatsapp/templates/order_ready/analytics?days=7" \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

With the SDK, `platic.whatsapp.templates.analytics("order_ready", { days: 7 })`. Your assistant uses [`get_whatsapp_template_analytics`](/mcp/tools#get_whatsapp_template_analytics).

To change a template later, use [Update a template](/api-reference/whatsapp-templates/update); to remove it, [Delete a template](/api-reference/whatsapp-templates/delete). Meta reviews every new or edited template again.

## Next steps

- [Send a campaign](/guides/campaigns) to reach a whole audience with an approved template.
- [Receive webhooks](/guides/webhooks) to learn when a template is approved and when a contact replies.
- [WhatsApp templates](/api-reference/whatsapp-templates/list): list, create, update and delete.
