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
limitintegerItems per page (default: 50, max: 100)
before_idstringLoad older messages before this message ID (cursor-based pagination)
accountstringFilter messages by a specific WhatsApp account
{
"status": "success",
"data": {
"messages": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "880e8400-e29b-41d4-a716-446655440000",
"direction": "incoming",
"message_type": "text",
"content": {
"body": "Hello! How can I help you?"
},
"status": "read",
"wamid": "wamid.HBgLMTIzNDU2Nzg5MEUCGQYSFDM5...",
"whatsapp_account": "default_account",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:01:00Z"
}
],
"total": 245
}
}

Cursor-Based Paginated Response (When using before_id)

Section titled “Cursor-Based Paginated Response (When using before_id)”
{
"status": "success",
"data": {
"messages": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "880e8400-e29b-41d4-a716-446655440000",
"direction": "incoming",
"message_type": "text",
"content": {
"body": "Older message content"
},
"status": "read",
"wamid": "wamid.HBgLMTIzNDU2Nzg5MEUCGQYSFDM5...",
"whatsapp_account": "default_account",
"created_at": "2024-01-01T11:00:00Z",
"updated_at": "2024-01-01T11:00:00Z"
}
],
"has_more": true
}
}

Send a text message to a contact.

Terminal window
POST /api/contacts/{id}/messages
{
"type": "text",
"content": {
"body": "Hello! How can I help you today?"
},
"whatsapp_account": "default_account"
}
{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "880e8400-e29b-41d4-a716-446655440000",
"direction": "outgoing",
"message_type": "text",
"content": {
"body": "Hello! How can I help you today?"
},
"status": "pending",
"whatsapp_account": "default_account",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
}
}

Send a pre-approved template message to a contact or phone number. Supports templates with optional header media (image, video, document), TEXT header variables, and dynamic URL buttons.

If including a raw media file for a template header, use multipart/form-data. Otherwise, use application/json.

Terminal window
POST /api/messages/template
FieldTypeRequiredDescription
contact_idstringOne of contact_id or phone_numberUUID of the recipient 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_paramsobjectNoKey-value pairs for body parameters
header_paramsobjectNoKey-value pairs for TEXT header variables
button_paramsobjectNoKey-value pairs for dynamic URL buttons (button index → parameter value)
account_namestringNoSpecific WhatsApp account to use
header_media_idstringNoAlready-uploaded WhatsApp media ID for header
header_media_urlstringNoURL of media to download and upload to WhatsApp
header_media_filenamestringNoFilename (required for DOCUMENT headers)
header_filefileNoRaw header media file (only when using multipart/form-data)

Using JSON:

Terminal window
curl -X POST "https://dashboard.cloudwa.net/api/messages/template" \
-H "X-API-Key: whm_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "1234567890",
"template_name": "seasonal_promotion",
"template_params": {
"customer_name": "John",
"discount": "20%"
},
"header_params": {
"season": "Summer"
},
"button_params": {
"0": "promo-2024"
}
}'

Using multipart/form-data (for raw file upload):

Terminal window
curl -X POST "https://dashboard.cloudwa.net/api/messages/template" \
-H "X-API-Key: whm_your_api_key" \
-F "phone_number=1234567890" \
-F "template_name=order_receipt" \
-F "template_params={\"customer_name\":\"John\"}" \
-F "header_file=@/path/to/invoice.pdf" \
-F "header_media_filename=invoice.pdf"
{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "880e8400-e29b-41d4-a716-446655440000",
"direction": "outgoing",
"message_type": "template",
"content": {
"body": "Hello John, your Summer promo code is promo-2024!"
},
"status": "pending",
"whatsapp_account": "default_account",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
}
}

Upload and send a media message (image, video, document, or audio) directly. This endpoint accepts multipart/form-data request payloads.

Terminal window
POST /api/messages/media
ParameterTypeRequiredDescription
filefile binaryYesThe file payload to upload and send
contact_idstringYesUUID of the recipient contact
typestringNoMedia type: image, video, audio, document (default: image)
captionstringNoOptional caption for the media (images and videos only)
whatsapp_accountstringNoSpecific WhatsApp account to use
Terminal window
curl -X POST "https://dashboard.cloudwa.net/api/messages/media" \
-H "X-API-Key: whm_your_api_key" \
-F "contact_id=880e8400-e29b-41d4-a716-446655440000" \
-F "type=image" \
-F "caption=Here is your product image!" \
-F "file=@/path/to/product.png"
TypeFormatsMax Size
imageJPEG, PNG5 MB
videoMP4, 3GPP16 MB
audioAAC, MP3, OGG16 MB
documentPDF, DOC, XLS, PPT100 MB
{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "880e8400-e29b-41d4-a716-446655440000",
"direction": "outgoing",
"message_type": "image",
"media_url": "/media/images/abcdef.png",
"media_mime_type": "image/png",
"media_filename": "product.png",
"content": {
"body": "Here is your product image!"
},
"status": "pending",
"whatsapp_account": "default_account",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
}
}

Send interactive messages with reply buttons or CTA (Call to Action) URL buttons.

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

Send a message with up to 3 quick reply buttons:

{
"type": "interactive",
"interactive": {
"type": "button",
"body": "How would you like to proceed?",
"buttons": [
{ "id": "yes", "title": "Yes" },
{ "id": "no", "title": "No" }
]
},
"whatsapp_account": "default_account"
}

Send a message with a Call to Action URL button:

{
"type": "interactive",
"interactive": {
"type": "cta_url",
"body": "Click below to view your order details",
"button_text": "View Order",
"url": "https://example.com/orders/12345"
},
"whatsapp_account": "default_account"
}
{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "880e8400-e29b-41d4-a716-446655440000",
"direction": "outgoing",
"message_type": "interactive",
"interactive_data": {
"type": "button",
"body": "How would you like to proceed?",
"buttons": [
{ "id": "yes", "title": "Yes" },
{ "id": "no", "title": "No" }
]
},
"status": "pending",
"whatsapp_account": "default_account",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
}
}

Mark a message as read.

Terminal window
PUT /api/messages/{id}/read
{
"status": "error",
"message": "Not implemented yet"
}

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