POST
/v1/whatsapp/messages/template
Send Template
Send a pre-approved template message
Send Template Message
Send a pre-approved template message to initiate a conversation or send notifications.
Endpoint
POST /v1/whatsapp/messages/template
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {access_token} |
| Content-Type | application/json |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to |
string | Yes | Recipient phone number |
template |
string | Yes | Template name |
language |
string | Yes | Template language code |
components |
array | No | Template variable values |
Example Request
curl -X POST https://api.apimw.com/v1/whatsapp/messages/template \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": "+1234567890",
"template": "order_confirmation",
"language": "en",
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John" },
{ "type": "text", "text": "ORD-12345" },
{ "type": "text", "text": "$99.99" }
]
}
]
}'
Response
Success Response (200 OK)
{
"success": true,
"data": {
"message_id": "wamid.HBgNNjI4MTU1NTc0NDU2FQIAERgSM0VGMDA0...",
"to": "+1234567890",
"template": "order_confirmation",
"status": "sent",
"timestamp": "2024-01-15T10:30:00Z"
}
}
Template Components
Header Component
{
"type": "header",
"parameters": [
{ "type": "image", "image": { "link": "https://example.com/image.jpg" } }
]
}
Body Component
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John Doe" },
{ "type": "currency", "currency": { "code": "USD", "amount_1000": 99990 } }
]
}
Button Component
{
"type": "button",
"sub_type": "url",
"index": 0,
"parameters": [
{ "type": "text", "text": "order-12345" }
]
}
Common Templates
| Template | Description | Variables |
|---|---|---|
order_confirmation |
Order placed notification | name, order_id, total |
shipping_update |
Shipping status update | name, tracking_number |
appointment_reminder |
Appointment reminder | name, date, time |
payment_received |
Payment confirmation | name, amount, invoice_id |