Skip to main content

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).

note

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​

HeaderRequiredDescription
X-API-KeyYesYour API key
Content-TypeYesMust 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​

ParameterTypeRequiredDescription
tostringYesRecipient phone number with country code, 10 to 15 digits (no + prefix)
templatestringYesTemplate name (must be approved by WhatsApp)
languagestringNoTemplate language code, must match the approved template exactly (e.g., en, hi, en_US). Default: en
variablesobjectNoTemplate variables as key-value pairs
externalIdstringNoYour reference ID for tracking (returned in webhooks)
accountIdstringNoSpecific 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:

FormatValid
919876543210Yes
+919876543210No
9876543210No
91-9876543210No

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"
}
FieldDescription
messageIdGB Chat internal message ID
waMessageIdWhatsApp message ID
statusMessage status (sent)
toRecipient phone number
templateTemplate name used
externalIdYour 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​

TemplatePurposeVariables
hello_worldTest messageNone
order_confirmationOrder placedOrder ID, amount
order_shippedShipment notificationCustomer name, order ID, delivery date
appointment_reminderAppointment reminderDoctor name, date/time
payment_receivedPayment confirmationAmount, 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.

warning

This will send a real message to the phone number you enter. Use your own number for testing.

API Tester