Skip to content

Template Message

A WhatsApp template is required to send messages outside the 24-hour window (conversation opener). The template must be in APPROVED status in Meta before it can be used.

Manage templates on the app.mahadata.io page Message Template.

{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "template",
"template": {
"name": "order_confirmation",
"language": {
"code": "id"
},
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John Doe" },
{ "type": "text", "text": "ORD-12345" }
]
}
]
}
}
FieldTypeRequiredDescription
namestringYesTemplate name (must already be APPROVED)
languageobjectYesLanguage object with the code
componentsarrayNoArray of dynamic components (header, body, button)
FieldTypeRequiredDescription
codestringYesLanguage/locale code, e.g. "id", "en_US", "en"
FieldTypeRequiredDescription
typestringYesComponent type: "header", "body", "button"
parametersarrayNoDynamic parameters for this component
sub_typestringNoSub-type for button: "url", "quick_reply"
indexstring/numberNoButton index (0-based), for component button

Each parameter in parameters has a field type:

TypeExampleDescription
text{ "type": "text", "text": "John" }Text parameters
image{ "type": "image", "image": { "link": "..." } }Image in header
document{ "type": "document", "document": { "link": "..." } }Document in header
currency{ "type": "currency", "currency": { "fallback_value": "Rp 150.000", "code": "IDR", "amount_1000": 150000000 } }Currency value
coupon_code{ "type": "coupon_code", "coupon_code": "DISKON50" }Coupon code
{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Budi Santoso" },
{ "type": "currency", "currency": { "fallback_value": "Rp 250.000", "code": "IDR", "amount_1000": 250000000 } }
]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{ "type": "text", "text": "INV-2026-001" }
]
}
]
}
}
Terminal window
curl -X POST https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "template",
"template": {
"name": "order_confirmation",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John Doe" },
{ "type": "text", "text": "ORD-12345" }
]
}
]
}
}'
{
"messaging_product": "whatsapp",
"messages": [
{
"id": "msg_f7a816e2-8397-11f0-8e34-010203040506"
}
]
}
  1. message.status.sent — Template was sent successfully
  2. message.status.delivered — Template reached the recipient’s device
  3. message.status.read — Template was read by the recipient

In addition, you can also receive events related to the status of the template itself:

TheDescription
template_status_updateTemplate status changes (APPROVED, REJECTED, PENDING)
template_quality_updateTemplate quality update
template_category_updateTemplate category change by Meta

See the page Webhook for details on the payload format of each event.