List whatsapp templates
GET/v2/agents/{agentId}/whatsapp/templates
Return the approved WhatsApp message templates of an agent with their name, language, body and number of variables, ready to send.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
Returns the WhatsApp templates that an agent can send. Call it before you send a message, to find the exact name and language of a template and to learn how many variables it expects.
Only approved templates are returned. If one you created is missing, check its status in the WhatsApp templates settings, as WhatsApp templates describes.
Request
GET /v2/agents/{agentId}/whatsapp/templates
Path parameters:
| Name | Type | Required | Description |
|---|---|---|---|
agentId |
string | Yes | The ID of the agent, starting with agt_. |
Query parameters:
| Name | Type | Required | Description |
|---|---|---|---|
language |
string | No | Only templates in this language code, for example en. |
limit |
integer | No | Items per page, from 1 to 100. Defaults to 20. |
cursor |
string | No | The nextCursor value from the previous page. |
The agent needs a connected WhatsApp number. Setup is covered in WhatsApp.
Example request
curl "https://api.askocto.co/v2/agents/agt_8f3k2m/whatsapp/templates?language=en" \
-H "Authorization: Bearer $OCTO_API_KEY"
const url = new URL("https://api.askocto.co/v2/agents/agt_8f3k2m/whatsapp/templates")
url.searchParams.set("language", "en")
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.OCTO_API_KEY}` },
})
const { data } = await response.json()
for (const template of data) console.log(template.name, template.variables)
Example response
A successful call returns 200 OK.
{
"data": [
{
"name": "order_update",
"language": "en",
"status": "approved",
"variables": 2,
"body": "Hi {{1}}, your order {{2}} has shipped."
},
{
"name": "welcome_back",
"language": "en",
"status": "approved",
"variables": 1,
"body": "Welcome back, {{1}}. How can we help today?"
}
],
"nextCursor": null
}
Response fields
| Name | Type | Description |
|---|---|---|
data[].name |
string | The template name. Use it as template when you send. |
data[].language |
string | The language code of the template. |
data[].status |
string | approved for every template in this list. |
data[].variables |
integer | How many numbered placeholders the body has. |
data[].body |
string | The template text with {{1}}, {{2}} and so on as placeholders. |
nextCursor |
string or null | Pass it as cursor for the next page. null on the last page. |
A template name can exist in several languages, so identify a template by name together with language. Send one with Send a whatsapp template message.
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request |
limit is outside 1 to 100. |
| 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 |
No agent has this ID in your workspace. |
| 429 | rate_limited |
Too many requests. Wait for the number of seconds in the Retry-After header. |
See the WhatsApp API overview for the full flow.