WhatsApp Template Message
Send a pre-approved WhatsApp template message with optional dynamic variables to a contact
This endpoint allows you to send WhatsApp template messages with dynamic variables to contacts through your registered WhatsApp Business account.
Prerequisites
- An active premium subscription
- A configured WhatsApp Business account integration
- Agent configured with the WhatsApp channel
- Template must be pre-approved on WhatsApp Business Manager
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
phoneNumberId | string | Yes | The WhatsApp Business phone number ID |
Request Body
Template Variables
You can include dynamic variables in your template by adding fields with the var_
prefix to your request body. These will be automatically mapped to the template parameters.
Format: var_[parameter_name]: "value"
Examples:
var_customer_name: "John Doe"
→ maps to parametercustomer_name
var_order_id: "12345"
→ maps to parameterorder_id
var_delivery_date: "2024-01-15"
→ maps to parameterdelivery_date
Response
Returns the created conversation object.
Example JS Code
Basic Template (No Variables)
Template with Variables
Template Variable Mapping
The API automatically converts var_
prefixed fields into WhatsApp Cloud API template components:
Request Body:
Generated WhatsApp Components:
Error Responses
Status Code | Description |
---|---|
400 | Bad Request - Missing required parameters |
401 | Unauthorized - Invalid token |
402 | Payment Required - Premium subscription required |
404 | Not Found - Phone number ID or agent not found |
500 | Internal Server Error |
Webhooks
After sending a template, a webhook with the AGENT_MESSAGE_SENDED
event type will be triggered with the following data:
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Path Parameters
ID of the WhatsApp Business phone number
Body
Recipient's phone number with country code
Message text to store in conversation history
ID of the agent to associate with this message
Name of the pre-approved WhatsApp template
Language code for the template
Dynamic template variables with 'var_' prefix (e.g., var_customer_name, var_order_id)
Response
Conversation ID
External ID for the channel
Conversation channel
whatsapp
Messages in the conversation
Was this page helpful?