Guides
Messages

Send messages

Text, media, location, contacts, reactions, contextual replies and read receipts through the /messages endpoint.

Every message goes through Send a message, POST /{phone-number-id}/messages. The body always has messaging_product: "whatsapp", the recipient in to and the type; the content goes in a key named after the type.

Text

bash
curl --request POST \
  --url https://whatsapp.mimicr.dev/v24.0/424361664134261/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "5511987654321",
    "type": "text",
    "text": { "preview_url": false, "body": "Seu pedido #1042 saiu para entrega." }
  }'
json
{
  "messaging_product": "whatsapp",
  "contacts": [{ "input": "5511987654321", "wa_id": "5511987654321" }],
  "messages": [{ "id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABEYEkEzRERCRDI2Q0RBNTA0NUZGRgA=" }]
}

body takes up to 4096 characters. Keep the wamid: status webhooks refer to it.

The 24-hour customer service window

Free-form messages (text, media, interactive, location, contacts, reactions) are only delivered if the customer wrote in the last 24 hours. Outside the window, the Graph API accepts the message and the status webhook arrives with failed and error 131047. To start a conversation, use a template.

In Mimicr, the window counts on the sandbox clock: move it forward 25 hours (npx mimicr clock whatsapp:docs +25h) to test 131047. Reactions do not reopen the window.

Media

By public link or by the id of an upload (see Media):

json
{
  "messaging_product": "whatsapp",
  "to": "5511987654321",
  "type": "image",
  "image": { "link": "https://picsum.photos/600", "caption": "Nota fiscal" }
}

The types are image, audio, video, document (with filename) and sticker. audio and sticker don't take a caption.

Location, contacts and reaction

json
{ "messaging_product": "whatsapp", "to": "5511987654321", "type": "location",
  "location": { "latitude": -23.5613, "longitude": -46.6565, "name": "Loja Paulista", "address": "Av. Paulista, 1000" } }
json
{ "messaging_product": "whatsapp", "to": "5511987654321", "type": "contacts",
  "contacts": [{ "name": { "formatted_name": "Suporte Loja Aurora" }, "phones": [{ "phone": "+551130000000", "type": "WORK" }] }] }
json
{ "messaging_product": "whatsapp", "to": "5511987654321", "type": "reaction",
  "reaction": { "message_id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABEYEjY0M0JCNDQ5MzQyMEMxMjVGNQA=", "emoji": "👍" } }

An empty emoji removes the reaction.

Replying to a message

Include context.message_id with the wamid of the quoted message. To get an identifier of yours back in the status webhooks, use biz_opaque_callback_data:

json
{
  "messaging_product": "whatsapp",
  "to": "5511987654321",
  "type": "text",
  "context": { "message_id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABEYEjY0M0JCNDQ5MzQyMEMxMjVGNQA=" },
  "biz_opaque_callback_data": "pedido-1042",
  "text": { "body": "Claro, já verifico." }
}

Mark as read and show typing

When you receive a message, mark it as read and show the typing indicator while you prepare the answer (Mark as read):

bash
curl --request POST \
  --url https://whatsapp.mimicr.dev/v24.0/424361664134261/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "messaging_product": "whatsapp",
    "status": "read",
    "message_id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABEYEjY0M0JCNDQ5MzQyMEMxMjVGNQA=",
    "typing_indicator": { "type": "text" }
  }'

The response is {"success": true}. Earlier messages of the conversation are marked as read too, and the indicator goes away when you reply or after 25 seconds.

Common synchronous errors

ErrorWhen
100Missing messaging_product, to or the type object; invalid to
131009Value out of bounds (text, buttons, rows, URL)
131021to is the business's own number
131051Unsupported type
133010Business number not registered
130429Throughput above the sandbox limit
131056Too many messages to the same number in a short time

See them all in Errors. Delivery errors (131026, 131047, 131049, 131050) arrive by webhook, see Delivery statuses.