Send a whatsapp template message
POST/v2/agents/{agentId}/whatsapp/messages
Send an approved WhatsApp template to a phone number, fill its variables and get the conversation where the customer's reply will land.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
Sends one template message to one phone number and opens a conversation for it. Call it for order updates, reminders and other first messages. When the customer replies, the reply is added to the returned conversation and the agent answers as usual.
Warning: The message goes to a real person as soon as the call succeeds. Use your own test number while you build.
Request
POST /v2/agents/{agentId}/whatsapp/messages
Path parameters:
| Name | Type | Required | Description |
|---|---|---|---|
agentId |
string | Yes | The ID of the agent, starting with agt_. |
Body fields:
| Name | Type | Required | Description |
|---|---|---|---|
to |
string | Yes | The recipient in international format with a plus sign and country code, for example +15555550123. |
template |
string | Yes | The template name from List whatsapp templates. |
language |
string | No | The language code of the template. Defaults to en. |
variables |
object | If the template has variables | One string value for each placeholder, with the number as the key: { "1": "Dana", "2": "A-1042" }. |
Send a value for every placeholder in the template body. A missing value returns invalid_request before anything is sent. Make sure you have the customer's permission to message them. That is your responsibility and not legal advice.
Example request
curl -X POST https://api.askocto.co/v2/agents/agt_8f3k2m/whatsapp/messages \
-H "Authorization: Bearer $OCTO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15555550123",
"template": "order_update",
"language": "en",
"variables": { "1": "Dana", "2": "A-1042" }
}'
const response = await fetch("https://api.askocto.co/v2/agents/agt_8f3k2m/whatsapp/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.OCTO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "+15555550123",
template: "order_update",
language: "en",
variables: { "1": "Dana", "2": "A-1042" },
}),
})
const { conversationId, message } = await response.json()
console.log(conversationId, message.content)
Example response
A successful call returns 201 Created.
{
"conversationId": "conv_8d4m2x",
"message": {
"id": "msg_3j7t5n",
"conversationId": "conv_8d4m2x",
"role": "assistant",
"content": "Hi Dana, your order A-1042 has shipped.",
"sources": [],
"feedback": null,
"createdAt": "2026-03-21T10:30:00Z"
}
}
Response fields
| Name | Type | Description |
|---|---|---|
conversationId |
string | The conversation for this customer, starting with conv_. Keep it to follow the replies. |
message |
object | The message that was sent, with the variables filled in. It has the same shape as any message of a conversation. |
Read the replies with List conversation messages. The WhatsApp API overview shows the whole flow, and Outbound WhatsApp covers sending from the dashboard.
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request |
to is not in international format, or a variable value is missing or not a string. |
| 401 | unauthorized |
The API key is missing, malformed or deleted. |
| 403 | forbidden |
The agent has no WhatsApp connection. Connect the channel first. |
| 404 | not_found |
The agent does not exist, or no approved template matches template and language. |
| 429 | rate_limited |
Too many requests. Wait for the number of seconds in the Retry-After header. |