Send Template Message
Send an approved WhatsApp template message to a mobile number. Templates can be sent to any number at any time (this is how you start a conversation).
This page covers template messages. Free-form text messages (which WhatsApp allows only within 24 hours of the customer's last message) will be documented on their own page, Send Text Message.
Endpoint
POST /api/v1/whatsapp/template/send
Headers
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | Your API key |
Content-Type | Yes | Must be application/json |
Request Body
{
"to": "919876543210",
"template": "order_confirmation",
"language": "en",
"variables": {
"1": "John Doe",
"2": "ORD-12345",
"3": "₹1,499"
},
"externalId": "your-reference-123",
"accountId": "wa_account_id"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient phone number with country code, 10 to 15 digits (no + prefix) |
template | string | Yes | Template name (must be approved by WhatsApp) |
language | string | No | Template language code, must match the approved template exactly (e.g., en, hi, en_US). Default: en |
variables | object | No | Template variables as key-value pairs |
externalId | string | No | Your reference ID for tracking (returned in webhooks) |
accountId | string | No | Specific WhatsApp account ID (the default active account is used if not provided) |
Phone Number Format
The to field must be a phone number with country code, without the + prefix:
| Format | Valid |
|---|---|
919876543210 | Yes |
+919876543210 | No |
9876543210 | No |
91-9876543210 | No |
Variables
Template variables are numbered placeholders in your approved template. Provide them as an object with string keys:
{
"variables": {
"1": "First variable",
"2": "Second variable",
"3": "Third variable"
}
}
For example, if your template is:
Hello {{1}}, your order {{2}} has been shipped!
You would provide:
{
"variables": {
"1": "John Doe",
"2": "ORD-12345"
}
}
Response
Success (200)
{
"success": true,
"data": {
"messageId": "msg_abc123xyz",
"waMessageId": "wamid.HBgLMTIzNDU2Nzg5MA==",
"status": "sent",
"to": "919876543210",
"template": "order_confirmation",
"externalId": "your-reference-123"
},
"message": "Message sent successfully"
}
| Field | Description |
|---|---|
messageId | GB Chat internal message ID |
waMessageId | WhatsApp message ID |
status | Message status (sent) |
to | Recipient phone number |
template | Template name used |
externalId | Your reference ID (if provided) |
Error Responses
Validation Error (400)
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": [
{ "field": "to", "message": "Required" }
]
}
}
Template Not Found (404)
{
"success": false,
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template \"order_shipped\" with language \"en\" not found"
}
}
Template Not Approved (400)
{
"success": false,
"error": {
"code": "TEMPLATE_NOT_APPROVED",
"message": "Template \"order_shipped\" is not approved (status: PENDING)"
}
}
No Active WhatsApp Account (404)
{
"success": false,
"error": {
"code": "ACCOUNT_NOT_FOUND",
"message": "No default WhatsApp account configured"
}
}
Send Failed (500)
WhatsApp rejected the message. message carries WhatsApp's reason and details.waErrorCode its error code.
{
"success": false,
"error": {
"code": "SEND_FAILED",
"message": "Parameter value is not valid",
"details": { "waErrorCode": 132000 }
}
}
See Error Handling for every code.
Examples
Basic Message
curl -X POST https://inboxapi.workmatic.in/api/v1/whatsapp/template/send \
-H "X-API-Key: gbk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"template": "hello_world",
"language": "en"
}'
Message with Variables
curl -X POST https://inboxapi.workmatic.in/api/v1/whatsapp/template/send \
-H "X-API-Key: gbk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"template": "order_shipped",
"language": "en",
"variables": {
"1": "John Doe",
"2": "ORD-12345",
"3": "Feb 10, 2024"
},
"externalId": "order-12345"
}'
Using a Specific WhatsApp Account
curl -X POST https://inboxapi.workmatic.in/api/v1/whatsapp/template/send \
-H "X-API-Key: gbk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"template": "appointment_reminder",
"language": "en",
"variables": {
"1": "Dr. Smith",
"2": "Tomorrow at 10:00 AM"
},
"accountId": "67890abcdef"
}'
Template Requirements
Approval Status
Only templates with APPROVED status can be used, and the template must be synced into GB Chat (Dashboard, Broadcast, Templates, Sync) for the same WhatsApp account that sends it. New templates created in Meta are not available through the API until they are synced.
Template Components
Templates can have multiple components:
- HEADER - Text, image, video, or document
- BODY - Main message text with variables
- FOOTER - Optional footer text
- BUTTONS - Call-to-action or quick reply buttons
Header text variables, body variables and URL-button variables are filled from variables using their number. Header media (image, video, document) is not supported yet.
Common Templates
| Template | Purpose | Variables |
|---|---|---|
hello_world | Test message | None |
order_confirmation | Order placed | Order ID, amount |
order_shipped | Shipment notification | Customer name, order ID, delivery date |
appointment_reminder | Appointment reminder | Doctor name, date/time |
payment_received | Payment confirmation | Amount, transaction ID |
Rate Limiting
This endpoint is subject to rate limiting. Default: 60 requests per minute.
Try It Out
Test the API directly from your browser. Enter your API key and send a test message.
This will send a real message to the phone number you enter. Use your own number for testing.