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
Sending Media Templates
To send a template with a media header (image, video, or document), provide the header_type and the corresponding media source (header_link or header_id).
- Using a URL: Set
header_typeand provide the public URL inheader_link. - Using a Media ID: Set
header_typeand provide the ID of a previously uploaded media file inheader_id. - Text Header: Set
header_typeto"text"and provide the text inheader_text.
Body Variables
You can include dynamic variables in your template body by adding fields with the var_ prefix to your request body. These will be automatically mapped to the template parameters.
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_namevar_order_id: "12345"→ maps to parameterorder_idvar_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 with Image Header
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
The default status to set for the conversation.
RESOLVED, UNRESOLVED, HUMAN_REQUESTED 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?

