Send template message
Send a WhatsApp template message to a recipient. The business is determined from your API key, and all resources (templates, phone numbers) are validated to belong to that business.
POST
/api/external/v2/send-templateAuthentication
This endpoint authenticates with an API key via the X-API-Key header (ek_live_... format), instead of the bearer token used in the rest of the reference.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | String (UUID) | Required | UUID of the WhatsApp template to send (must belong to your business). |
from_phone_number | String | Required | Business phone number to send from (include the country code without the '+' sign). |
agent_id | String (UUID) | Optional | UUID of an agent to assign to the conversation (must belong to your business). |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
phone | String | Required | Recipient's phone number (include the country code without the '+' sign). |
buttons | Array | Optional | Optional array of dynamic button parameters. Each item is { "index": <button position>, "sub_type": "url", "text": "<value>" }. For a URL button defined as https://host/qr/{{1}}, the text replaces {{1}}. |
Example request
bash
curl -X POST "https://eclectic-api-537143970188.us-central1.run.app/api/external/v2/send-template?template_id=abc-123&from_phone_number=56987654321&agent_id=def-456" \
-H "X-API-Key: ek_live_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"phone": "56912345678",
"name": "John Doe",
"company": "Acme Inc",
"buttons": [
{ "index": 0, "sub_type": "url", "text": "ejemplo-123" }
]
}'Example response
json
{
"success": true,
"message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"recipient": "56912345678",
"template_name": "welcome_template"
}Notes
- Body fields are matched to the variables the template declares; fields that don't match a template variable are ignored.
- Use numeric keys ("1", "2", ...) for positional variables, or named keys ("name", "company") for named variables.
- For templates with a dynamic URL button, pass the value via the buttons array, not as a body variable — Meta rejects a URL sent as a body parameter.
- Possible errors: 400 (validation or blocked send), 401 (invalid or missing API key), 403 (resource does not belong to your business), 500 (internal error).