Send a WhatsApp template
Send an approved WhatsApp template in a WhatsApp conversation. Templates are the only way to write to a contact outside WhatsApp's 24-hour window (for example right after starting a conversation).
Endpoint
Body
| Name | Type | Required | Description |
|---|---|---|---|
conversation_id | integer | Yes | WhatsApp conversation. |
message_type | string | Yes | template. |
template_id | integer | Yes | id of the template from List WhatsApp templates. Must belong to your organization. WhatsApp only delivers templates with status APPROVED. |
custom_variables | object | No | Values for template placeholders, keyed by the variable names in the template's variables_matching (for example { "custom_body_1": "A-1043" }). |
How placeholders are filled
Each template has variables_matching, which maps a placeholder (body_1 = {{1}} of the body, header_1 = {{1}} of the header) to a variable name. When sending, each variable is filled from custom_variables, the contact's data (for example contact_first_name, contact_full_name), the contact's custom fields, or the conversation owner's fields. Templates imported from Meta map {{n}} to custom_body_n / custom_header_n, so pass those keys in custom_variables.
Request
Response
The stored message, with message_type: "template" and the rendered text in message_text.
json
Notes
- A template can only be sent from a number of its own WhatsApp Business Account (WABA). If the conversation's number is in another WABA, the template with the same name and language of that WABA is used; if there is none the request is rejected.
- Contacts blacklisted for WhatsApp return
403 Forbidden.
Errors
| Status | When |
|---|---|
400 Bad Request | The template belongs to another organization or cannot be sent from the conversation's number. |
404 Not Found | template_id does not exist. |
Report an issue with this documentation
Please log in to report issues with our documentation.