Skip to content

Messages

Overview

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

Get Messages

Retrieve messages for a specific contact.

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

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 50, max: 100)
beforestringGet messages before this message ID
afterstringGet messages after this message ID

Response

{
"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 Text Message

Send a text message to a contact.

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

Request Body

{
"type": "text",
"text": "Hello! How can I help you today?"
}

Response

{
"status": "success",
"data": {
"id": "uuid",
"wa_message_id": "wamid.xxx",
"status": "sent",
"timestamp": "2024-01-01T12:00:00Z"
}
}

Send Template Message

Send a pre-approved template message.

Terminal window
POST /api/messages/template

Request Body

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 parameters
account_namestringNoSpecific WhatsApp account to use

Examples

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"
}
}

Response

{
"status": "success",
"data": {
"message_id": "uuid",
"phone_number": "919876543210",
"status": "pending",
"template_name": "order_confirmation"
}
}

Send Media Message

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

Terminal window
POST /api/messages/media

Request Body

{
"contact_id": "uuid",
"type": "image",
"media_url": "https://example.com/image.jpg",
"caption": "Check out this product!"
}

Supported Media Types

TypeFormatsMax Size
imageJPEG, PNG5 MB
videoMP4, 3GPP16 MB
audioAAC, MP3, OGG16 MB
documentPDF, DOC, XLS, PPT100 MB

Response

{
"status": "success",
"data": {
"id": "uuid",
"wa_message_id": "wamid.xxx",
"status": "sent"
}
}

Send Interactive Message

Send interactive messages with buttons or CTA URLs.

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

Button Message

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" }
]
}
}

CTA URL Button

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"
}
}

Response

{
"status": "success",
"data": {
"id": "uuid",
"wa_message_id": "wamid.xxx",
"status": "sent"
}
}

Mark Message as Read

Mark a message as read.

Terminal window
PUT /api/messages/{id}/read

Response

{
"status": "success",
"data": null
}

Message Status

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

Message Types

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