Messages

Overview

The Messages module lets you send messages from any of your connected WhatsApp numbers and retrieve the message history. All messages are logged and can be queried by direction, status, sender, or recipient.

Message types

TypePayload fieldDescription
texttext.bodyPlain text message
templatetemplateApproved WhatsApp message template
imageimageImage (by Media ID or URL)
documentdocumentPDF, Word, etc.
audioaudioAudio file
videovideoVideo file
locationlocationLatitude/longitude coordinates
interactiveinteractiveButtons, lists, etc.

Sending a message

POST /api/messages/send

The request body must include number_id, to, type, and a field matching type:

1{
2 "number_id": "clxyz123...",
3 "to": "5511999990000",
4 "type": "text",
5 "text": {
6 "body": "Hello! How can I help you today?"
7 }
8}

Idempotency

Add an Idempotency-Key header to prevent duplicate sends:

1POST /api/messages/send
2Idempotency-Key: <unique-string>

If a request with the same key is received within 24 hours, the original response is returned without sending another message.

Message directions

DirectionDescription
OUTBOUNDMessages sent by you via the API
INBOUNDMessages received from end-users

Message statuses

StatusDescription
sentAccepted by Meta’s servers
deliveredDelivered to the recipient’s device
readRead by the recipient
failedDelivery failed

Status updates are delivered via webhook events.

Querying messages

$# List inbound messages for a specific number
$curl "https://dev.muchau.com.br/api/messages?number_id=clxyz123...&direction=INBOUND&limit=50" \
> -H "Authorization: Bearer $MUCHAW_API_KEY"