Skip to content

Messages

The Messages API allows you to send various types of WhatsApp messages including text, media, templates, and interactive messages.

Retrieve messages for a specific contact.

Terminal window
GET /api/contacts/{id}/messages
ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 50, max: 100)
beforestringGet messages before this message ID
afterstringGet messages after this message ID
{
"status": "success",
"data": {
"items": [
{
"id": "uuid",
"wa_message_id": "wamid.xxx",
"contact_id": "uuid",
"direction": "incoming",
"type": "text",
"content": {
"text": "Hello!"
},
"status": "delivered",
"timestamp": "2024-01-01T12:00:00Z"
}
],
"total": 100,
"page": 1,
"limit": 50
}
}

Send a text message to a contact.

Terminal window
POST /api/contacts/{id}/messages
{
"type": "text",
"text": "Hello! How can I help you today?"
}
{
"status": "success",
"data": {
"id": "uuid",
"wa_message_id": "wamid.xxx",
"status": "sent",
"timestamp": "2024-01-01T12:00:00Z"
}
}

Send a pre-approved template message.

Terminal window
POST /api/messages/template
FieldTypeRequiredDescription
contact_idstringOne of contact_id or phone_numberUUID of existing contact
phone_numberstringOne of contact_id or phone_numberPhone number (creates contact if not exists)
template_namestringOne of template_name or template_idName of the template
template_idstringOne of template_name or template_idUUID of the template
template_paramsobjectNoNamed or positional body parameters
button_paramsobjectNoDynamic URL button parameters (button index → value)
account_namestringNoSpecific WhatsApp account to use

Using phone number (creates contact if needed):

Terminal window
curl -X POST "http://your-server:8080/api/messages/template" \
-H "X-API-Key: whm_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "919876543210",
"template_name": "hello_world"
}'
{
"phone_number": "919876543210",
"template_name": "hello_world"
}

With named parameters:

If your template has placeholders like Hello {{name}}, your order {{order_id}} is ready:

{
"contact_id": "uuid",
"template_name": "order_confirmation",
"template_params": {
"name": "John",
"order_id": "12345"
}
}

With positional parameters:

{
"phone_number": "919876543210",
"template_name": "order_confirmation",
"template_params": {
"1": "John",
"2": "12345"
}
}

With URL button parameters:

If your template has a URL button with a dynamic variable (e.g., https://example.com/track/{{1}}), provide the dynamic value via button_params. The key is the button index (starting from "0"):

{
"contact_id": "uuid",
"template_name": "order_shipped",
"template_params": {
"name": "John",
"order_id": "12345"
},
"button_params": {
"0": "12345"
}
}
{
"status": "success",
"data": {
"message_id": "uuid",
"phone_number": "919876543210",
"status": "pending",
"template_name": "order_confirmation"
}
}

Send an image, video, document, or audio message.

Terminal window
POST /api/messages/media
{
"contact_id": "uuid",
"type": "image",
"media_url": "https://example.com/image.jpg",
"caption": "Check out this product!"
}
TypeFormatsMax Size
imageJPEG, PNG5 MB
videoMP4, 3GPP16 MB
audioAAC, MP3, OGG16 MB
documentPDF, DOC, XLS, PPT100 MB
{
"status": "success",
"data": {
"id": "uuid",
"wa_message_id": "wamid.xxx",
"status": "sent"
}
}

Send interactive messages with buttons or CTA URLs.

Terminal window
POST /api/contacts/{id}/messages

Send a message with up to 3 quick reply buttons:

Terminal window
curl -X POST "http://your-server:8080/api/contacts/{contact_id}/messages" \
-H "X-API-Key: whm_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"type": "interactive",
"interactive": {
"type": "button",
"body": "How would you like to proceed?",
"buttons": [
{ "id": "yes", "title": "Yes" },
{ "id": "no", "title": "No" }
]
}
}'
{
"type": "interactive",
"interactive": {
"type": "button",
"body": "How would you like to proceed?",
"buttons": [
{ "id": "yes", "title": "Yes" },
{ "id": "no", "title": "No" }
]
}
}

Send a message with a call-to-action URL button:

Terminal window
curl -X POST "http://your-server:8080/api/contacts/{contact_id}/messages" \
-H "X-API-Key: whm_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"type": "interactive",
"interactive": {
"type": "cta_url",
"body": "Click below to view your order details",
"button_text": "View Order",
"url": "https://example.com/orders/12345"
}
}'
{
"type": "interactive",
"interactive": {
"type": "cta_url",
"body": "Click below to view your order details",
"button_text": "View Order",
"url": "https://example.com/orders/12345"
}
}
{
"status": "success",
"data": {
"id": "uuid",
"wa_message_id": "wamid.xxx",
"status": "sent"
}
}

Mark a message as read.

Terminal window
PUT /api/messages/{id}/read
{
"status": "success",
"data": null
}

Messages go through the following status flow:

StatusDescription
pendingMessage queued for sending
sentMessage sent to WhatsApp servers
deliveredMessage delivered to recipient’s device
readMessage read by recipient
failedMessage failed to send

Text

Plain text messages

Image

JPEG, PNG images with optional caption

Video

MP4 videos with optional caption

Document

PDF, Word, Excel, and other documents

Audio

Voice messages and audio files

Template

Pre-approved message templates

Interactive

Buttons, lists, and reply buttons

Flow

WhatsApp Flows