Skip to main content

Send WhatsApp Message

Send text, media, template, or interactive messages via WhatsApp.

Endpoint​

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

Request Parameters​

ParameterRequiredTypeDescription
fromMandatoryStringYour WhatsApp-enabled phone number (E.164)
toMandatoryStringRecipient phone number (E.164)
contentMandatoryObjectMessage content object (see below)
status_callbackOptionalStringWebhook URL for delivery status updates
custom_dataOptionalStringApplication-specific metadata

Content Object​

{
"recipient_type": "individual",
"type": "text",
"text": {
"body": "Hello! How can we help you today?"
}
}

Supported Content Types​

Text:

{ "type": "text", "text": { "body": "Your message here" } }

Image:

{ "type": "image", "image": { "link": "https://example.com/image.jpg", "caption": "Check this out" } }

Document:

{ "type": "document", "document": { "link": "https://example.com/invoice.pdf", "filename": "invoice.pdf" } }

Location:

{ "type": "location", "location": { "latitude": 12.9716, "longitude": 77.5946, "name": "Exotel Office", "address": "Bangalore, India" } }

Interactive (Buttons):

{
"type": "interactive",
"interactive": {
"type": "button",
"body": { "text": "Choose an option:" },
"action": {
"buttons": [
{ "type": "reply", "reply": { "id": "btn_yes", "title": "Yes" } },
{ "type": "reply", "reply": { "id": "btn_no", "title": "No" } }
]
}
}
}

Code Examples​

curl -X POST "https://<your_api_key>:<your_api_token>@api.exotel.com/v2/accounts/<your_sid>/messages" \
-H "Content-Type: application/json" \
-d '{
"from": "+919876500001",
"to": "+919876543210",
"content": {
"recipient_type": "individual",
"type": "text",
"text": { "body": "Hello from Exotel!" }
},
"status_callback": "https://your-server.com/wa-status"
}'

Response​

HTTP 202 Accepted

{
"request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"http_code": 202,
"metadata": {
"total": 1,
"success": 1,
"failed": 0
},
"response": {
"whatsapp": {
"messages": [
{
"code": 202,
"status": "success",
"data": {
"sid": "msg_sid_value"
}
}
]
}
}
}

HTTP Status Codes​

CodeDescription
202Message accepted for delivery
400Malformed request
401Authentication failed
402Plan limit exceeded
403Access denied
404Resource not found
5xxServer error — retry the request

Try It​