Skip to main content

Template Messages

Send pre-approved WhatsApp message templates with dynamic parameter substitution. Templates must be approved in the WhatsApp Business Manager before use.

Endpoint​

POST https://<api_key>:<api_token><subdomain>/v2/accounts/<account_sid>/messages

Template Content Object​

{
"from": "+919876500001",
"to": "+919876543210",
"content": {
"recipient_type": "individual",
"type": "template",
"template": {
"name": "order_confirmation",
"language": {
"code": "en",
"policy": "deterministic"
},
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Rahul" },
{ "type": "text", "text": "#ORD-12345" },
{ "type": "text", "text": "Feb 10, 2024" }
]
}
]
}
}
}

Template Parameters​

FieldRequiredDescription
template.nameMandatoryApproved template name
template.language.codeMandatoryLanguage code (e.g., en, hi, ta)
template.language.policyMandatorydeterministic (recommended)
template.componentsOptionalArray of component objects for dynamic values

Component Types​

TypeDescription
headerTemplate header parameters (text, image, video, document)
bodyTemplate body text parameters
buttonButton parameters (URL suffix, quick reply payload)

Parameter Types​

TypeFieldsDescription
texttextDynamic text value
imagelinkImage URL for header
videolinkVideo URL for header
documentlink, filenameDocument URL for header

Example: Template with Header Image​

{
"from": "+919876500001",
"to": "+919876543210",
"content": {
"recipient_type": "individual",
"type": "template",
"template": {
"name": "promo_with_image",
"language": { "code": "en", "policy": "deterministic" },
"components": [
{
"type": "header",
"parameters": [
{ "type": "image", "image": { "link": "https://example.com/promo.jpg" } }
]
},
{
"type": "body",
"parameters": [
{ "type": "text", "text": "50%" },
{ "type": "text", "text": "Feb 28" }
]
}
]
}
}
}

cURL Example​

curl -X POST "https://<api_key>:<api_token>@api.exotel.com/v2/accounts/<sid>/messages" \
-H "Content-Type: application/json" \
-d '{
"from": "+919876500001",
"to": "+919876543210",
"content": {
"recipient_type": "individual",
"type": "template",
"template": {
"name": "order_confirmation",
"language": { "code": "en", "policy": "deterministic" },
"components": [{
"type": "body",
"parameters": [
{ "type": "text", "text": "Rahul" },
{ "type": "text", "text": "#ORD-12345" }
]
}]
}
}
}'
note

Templates must be approved by Meta before they can be used. Unapproved templates will result in a 400 error. Create and manage templates in the WhatsApp Business Manager.