Endpoints
List WhatsApp templates
List the approved WhatsApp templates on one of your agent's connected numbers
The list_whatsapp_templates tool reads the message templates Meta has approved for a WhatsApp number connected to your agent, fresh from Meta on every call. It returns each template's name, language, body text and how many {{n}} values it takes, sorted by name. Use a template's name and language when you send it with send_campaign or a WhatsApp automation.
https://api.qwryai.com/public/v1/tools/list_whatsapp_templatesAuthentication
Send your API key as Authorization: Bearer YOUR_API_KEY. The key needs Read agent settings. See Authentication.
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
chatbotId | string | Yes | The agent's id, from list_agents. |
number | string | No | Which connected number's account to read: the phone number as listed, such as +14155550123, or its id from list_whatsapp_automations or get_outbound. Left out, the agent's first connected number is used. |
Request example
curl -X POST 'https://api.qwryai.com/public/v1/tools/list_whatsapp_templates' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"chatbotId": "YOUR_AGENT_ID"}'const response = await fetch("https://api.qwryai.com/public/v1/tools/list_whatsapp_templates", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", number: "+14155550123" }),
});
const { data } = await response.json();
console.log(data.templates);import requests
response = requests.post(
"https://api.qwryai.com/public/v1/tools/list_whatsapp_templates",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"chatbotId": "YOUR_AGENT_ID"},
)
templates = response.json()["data"]["templates"]Response
{
"success": true,
"data": {
"templates": [
{
"name": "back_in_stock",
"language": "en",
"body": "Good news, {{1}}! {{2}} is back in stock.",
"category": "MARKETING",
"parameters": 2
},
{
"name": "order_shipped",
"language": "en",
"body": "Hi {{1}}, good news: your order {{2}} is on its way.",
"category": "UTILITY",
"parameters": 2
}
]
}
}| Field | Type | Description |
|---|---|---|
templates[].name | string | The template's name in WhatsApp Manager. |
templates[].language | string | Its language code. A name can exist in several languages; the pair names one template. |
templates[].body | string | The body text, with its {{n}} placeholders. |
templates[].category | string | Meta's category, such as UTILITY or MARKETING. |
templates[].parameters | integer | How many {{n}} values the body takes. |
An empty templates list means the number's account has no approved template QwryAI can fill in. Create templates in WhatsApp Manager; see WhatsApp templates.
Errors
| HTTP status | code | When |
|---|---|---|
| 400 | INVALID_ARGUMENTS | number is empty or over 60 characters, or an unknown argument was sent. |
| 400 | CHATBOT_ID_REQUIRED | chatbotId is missing or isn't a valid agent id. |
| 403 | INSUFFICIENT_PERMISSION | The key doesn't hold Read agent settings. |
| 404 | CHATBOT_NOT_FOUND | No agent with that chatbotId in your workspace. |
| 409 | VALIDATION_INVALID_BODY | The number isn't connected to this agent, the agent has no connected WhatsApp number, or the number's business account needs connecting again. message says which. |
| 500 | TOOL_FAILED | Meta couldn't be reached. Try again. |
See Error Handling for authentication and rate-limit errors.