> For the complete documentation index, see [llms.txt](https://docs.oneroute.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oneroute.io/whatsapp-api/endpoints/send-template-message.md).

# Send Template Message

## Send WhatsApp Template Message

<mark style="color:green;">`POST`</mark> `https://api.oneroute.io/api/public/conversation/template`

Template messages can be delivered at any time. Each template needs to be registered and pre-approved by WhatsApp

#### Headers

| Name   | Type   | Description                 |
| ------ | ------ | --------------------------- |
| apiKey | string | API Key for authentication. |

#### Request Body

| Name                      | Type    | Description                                               |
| ------------------------- | ------- | --------------------------------------------------------- |
| messages.\*.save          | boolean | To save the message as a conversation on OneRoute or not. |
| messages.\*.template      | object  | The template object                                       |
| messages                  | array   | An array of messages to send                              |
| from                      | string  |                                                           |
| messages.\*.to            | string  | Whatsapp number to send template message to.              |
| messages.\*.template.name | string  | the template name                                         |
| messages.\*.metadata      | object  | Pass custom data to the metadata                          |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": [
        {
            "status": "success",
            "response": "gBGHI0kFNWAgTwIJk-_rr1Kse2yO"
        }
    ],
    "message": "Message sent to customer",
    "success": true
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "data": null,
    "success": false,
    "message": "\"template\" is required"
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    "data": null,
    "message": "Invalid API Key",
    "success": false
}
```

{% endtab %}
{% endtabs %}

### Example Request Payload

```
{
    "messages": [
        {
            "template": {
                "name": "first_welcome_messsage",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Michael"
                    }
                ] // leave the array empty if no placeholders in the template
            },
            "metadata": {
                "userId": "..."
            }, // custom properties
            "to": "234XXXXXXXX",
            "save": true
        },
                {
            "template": {
                "name": "new_conversation",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Timothy"
                    }
                ] // leave the array empty if no placeholders in the template
            },
            "metadata": {
                "location": "..."
            }, // custom properties
            "to": "234XXXXXXXX",
            "save": true
        }
    ],
    "from": "234XXXXXXXX"
}
```

### Example Request Payload (Authentication Template)

```
{
    "messages": [
        {
            "template": {
                "name": "first_welcome_messsage",
                "parameters": [
                    {
                        "type": "text",
                        "text": "OTP CODE"
                    }
                ],
                "buttons": [
                    {
                        "type": "text",
                        "text": "OTP CODE"
                    }
                ]
            },
            "metadata": {
                "userId": "..."
            }, // custom properties
            "to": "234XXXXXXXX",
            "save": true
        }
    ],
    "from": "234XXXXXXXX"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.oneroute.io/whatsapp-api/endpoints/send-template-message.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
