Skip to main content
Version: v0.31.0

Send messages from a session

Send text, images, documents, audio, locations, contact cards, polls, reactions, and bulk broadcasts from any connected session over the REST API. Every send is one HTTP call addressed to a session and a recipient.

Prerequisites

All examples use these placeholders. Set them once in your shell:

export BASE="http://localhost:2785/api" # /api is the global prefix; behind your domain + TLS in production
export API_KEY="YOUR_API_KEY" # an operator-or-higher key, from your dashboard
export SESSION="8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a" # the UUID id of a ready session

Address a recipient with a JID​

Every send takes a chatId — a JID (Jabber ID), WhatsApp's address for a chat. OpenWA uses two forms:

RecipientJID formExample
A person<phone>@c.us — full international number, digits only, no +628123456789@c.us
A group<groupId>@g.us120363021234567890@g.us

To message +62 812-3456-789, the chatId is 628123456789@c.us. For the other JID dialects and where each appears, see the Glossary.

The id must carry its domain. Since v0.26.0 a chatId without one (628123456789 instead of 628123456789@c.us), or sent as a JSON number, answers 400 (chatId must be a valid chat JID in the form localpart@host), and so does a fromChatId or toChatId on forward. Before, such an id reached the engine; on Baileys it answered 500, sent nothing and counted toward the send breaker. The check covers the chatId of every send and message-action body.

On Baileys, a send to a group reuses the group's participant list for up to 5 minutes instead of querying it for every message (v0.26.0+). Set BAILEYS_GROUP_METADATA_CACHE_TTL_MS=0 to query for every send as before. A membership or settings change, a refresh of the group listing, a reconnect or a write to the group through the gateway drops the cached list early. On both engines, 1:1 sends (send-text, media sends, send-location, send-contact, and send-sticker) prefer a resolved @lid privacy id when one is paired with the phone number, and fall back to <phone>@c.us otherwise.

Confirm a number is on WhatsApp

Resolve a raw number to its canonical JID with GET /api/sessions/{sessionId}/contacts/check/{number} before sending. The whatsappId it returns is in the <phone>@c.us form on both engines (v0.26.0+; whatsapp-web.js could answer an @lid for a contact moved to privacy-id addressing) and can differ from the digits you sent. Since v0.28.0 check/{number} refuses a non-phone @ id (such as @lid or @g.us) or a value containing no digits with 400 before calling the engine. To resolve a phone number to its paired @lid privacy id without sending, call GET /api/sessions/{sessionId}/contacts/{number}/lid (v0.27.1+, operator role, refused to chat-scoped keys), which returns { number, lid, hasLid } (lid: null and hasLid: false when no LID is known); the reverse lookup GET /api/sessions/{sessionId}/contacts/{contactId}/phone (viewer role, open to chat-scoped keys) resolves an @lid back to its phone number and, since v0.27.1, answers directly from {contactId} when given a phone JID on whatsapp-web.js. On GET /api/sessions/{sessionId}/contacts/profile-pictures, ids is optional in the OpenAPI contract since v0.27.1 (omitting it or passing an empty value returns {}). See the API reference.

Send a text message​

POST /api/sessions/{sessionId}/messages/send-text takes a chatId and a text body of up to 4096 characters.

curl -X POST "$BASE/sessions/$SESSION/messages/send-text" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "chatId": "628123456789@c.us", "text": "Hello from OpenWA!" }'

Every send route returns 201 Created with the WhatsApp message id and a timestamp (epoch seconds, a number):

{ "messageId": "true_628123456789@c.us_3EB0ABCD", "timestamp": 1719312000 }

Keep messageId — you need it to react to, reply to, or forward this message later.

A text send does not return at once. Unless SIMULATE_TYPING=false, the gateway shows the typing indicator and holds the message for 0.5 s plus 45 ms per character of text, capped at SIMULATE_TYPING_MAX_MS (default 5000) and then varied by up to 15 percent either way, with the result held to the cap too since v0.26.0, so a long text answers after at most the cap, 5 s by default (before, the variation could stretch that to about 5.75 s). A SIMULATE_TYPING_MAX_MS that is zero, negative, blank or not a number falls back to 5000; a negative value used to cut the pause to about 1 ms. send-template and the text sends of automation rules, plugins and MCP tools wait the same way; media, location, contact, poll, sticker, reply, forward and send-bulk sends do not. Keep client timeouts above that.

Since v0.14.0 the engines diverge on URL previews. On whatsapp-web.js WhatsApp Web still builds a preview by default and linkPreview: false suppresses it. On baileys previews are opt-in: the engine no longer fetches the page and generates a card unless you ask for it. Set linkPreview: true to have the gateway fetch the page and attach a preview, or leave it unset (or false) to send the URL as a plain link.

curl -X POST "$BASE/sessions/$SESSION/messages/send-text" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"text": "Read the launch notes https://example.com/launch",
"linkPreview": true
}'

Generating a preview is a blocking outbound fetch for the first https:// link with a domain-name host in the text only, given up after 3 seconds, which is why it is never done unless asked — a bulk campaign carrying URLs paid that fetch on every send. Since v0.31.0 a preview built from the fetched page has its title cut to 256 characters and its description to 1024, the lengths a customLinkPreview is held to.

On a Baileys session with an egress proxy, that preview fetch leaves through the proxy since v0.23.6, like the media downloads below; before, it left from the gateway's own address. A proxy that cannot reach the page leaves the message without a preview rather than failing the send, and the fetch never falls back to a direct one. If the proxy routes only WhatsApp traffic, set SESSION_PROXY_URL_FETCH=false so previews (and media URLs) are fetched from the gateway's own address. On whatsapp-web.js the preview is built inside the WhatsApp Web page, so the gateway makes no fetch of its own there.

Behaviour change for unchanged integrations on Baileys

If you send a URL on the baileys engine and did not set linkPreview, recipients who previously saw a preview card now see a plain link. Set linkPreview: true to restore it. whatsapp-web.js sessions are unaffected.

Supply your own card with customLinkPreview instead — nothing is fetched, so you can attach a preview even for a URL this server cannot reach. It needs at least url and title (WhatsApp renders no preview without a title):

{
"chatId": "628123456789@c.us",
"text": "We just launched https://example.com/launch",
"customLinkPreview": {
"url": "https://example.com/launch",
"title": "We just launched",
"description": "Read the announcement."
}
}

customLinkPreview is Baileys only — whatsapp-web.js takes the boolean and answers 501. Do not combine it with linkPreview: false, which asks for the opposite: that request answers 400, and since v0.30.3 so does a send that a message:sending plugin rewrites into the combination (Baileys sent it with the preview before). Since v0.27.0 customLinkPreview also accepts an optional thumbnailUrl (an absolute http(s) URL fetched through the SSRF guard and the session's proxy unless SESSION_PROXY_URL_FETCH=false) or thumbnailBase64 (thumbnailBase64 wins when both carry data) to render a large preview card: the image is capped at 5 MiB (or MEDIA_DOWNLOAD_MAX_BYTES if lower) and re-encoded with sharp as a JPEG inside 1280x1280 (400 if blocked, unfetchable, or undecodable, 413 if over 5 MiB, 503 if the session proxy fails before any response, and all three release Idempotency-Key). Since v0.23.0 send-template carries the same linkPreview boolean with the same engine split as send-text.

A session can set its own default with the linkPreview key of its config (v0.30.3+, see Sessions). It applies to a send-text or send-template that sets neither linkPreview nor customLinkPreview, and a value in the request always wins. false sends without a preview on both engines, true asks for one (the default on whatsapp-web.js; on Baileys it makes the gateway fetch the first https:// link with a domain-name host in the text before the message is sent), and null goes back to the engine's default. The key is read on every send, so a change applies from the next one without a restart.

Plugins can ask for a preview too

A plugin relaying a URL had no way to restore the card once previews became opt-in. Since v0.14.1 the plugin send envelope carries its own linkPreview, forwarded on a plain text send.

Crash-stuck sends are reaped

Every outbound send is persisted as pending before it reaches the engine and resolved to sent/failed right after. A process crash between those two writes would strand the row pending forever, so a periodic reaper sweeps stale outbound pending rows, marks them failed with a reapedAt metadata marker, and re-emits the message:persisted hook — plugin-driven consumers (for example a search provider) reconcile to the terminal state. Tune it with MESSAGE_REAPER_INTERVAL_MS (default 10 minutes; 0 disables the reaper), MESSAGE_REAPER_GRACE_MS (default 1 hour — only rows older than this are reaped), and MESSAGE_REAPER_BATCH_SIZE (default 50 rows per sweep).

Retry a send without duplicating it​

Since v0.25.0, twelve single-recipient routes accept an optional Idempotency-Key header: send-text, send-template, send-image, send-video, send-audio, send-document, send-location, send-contact, send-sticker, send-poll, reply and forward. Use one key per logical send, unique within the session:

curl -X POST "$BASE/sessions/$SESSION/messages/send-text" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoice-2026-001" \
-d '{ "chatId": "628123456789@c.us", "text": "Your invoice is ready." }'

The key must contain 1-255 visible ASCII characters and is retained for 24 hours from its first claim. The same route and body replay the original successful response with Idempotent-Replayed: true; JSON property order does not matter. Reusing it for a different route or body returns 422 IDEMPOTENCY_KEY_REUSED; an invalid or repeated header returns 400 IDEMPOTENCY_KEY_INVALID.

A running request returns 409 IDEMPOTENCY_KEY_IN_PROGRESS. An uncertain engine outcome, or a claim still pending after ten minutes, returns 409 IDEMPOTENCY_OUTCOME_UNKNOWN: check the chat before using a new key. A refusal before engine execution (4xx or 501), or transport proof that nothing was sent, releases the key for retry. Since v0.26.0 so does a WhatsApp rate limit on Baileys (code 429, answered 503), and since v0.27.0 so does any engine refusal that proves nothing was handed to WhatsApp: a not-ready 409 before the send was attempted (session not ready, WhatsApp Web reloading its page before the send, or a Baileys connection replaced or stopped before the write), a Baileys connection closed before the write (503), a media, sticker or link-preview thumbnail fetch failure, an unregistered recipient on Baileys (400), or a missing or wrong-chat quoted or forwarded message on Baileys (404). Since v0.31.0 so does a Baileys media upload that WhatsApp's media host refused, a media url that carries a user name or password (400), and, on whatsapp-web.js, a video sticker that ffmpeg refused (400) or that a host with no working ffmpeg could not convert (503). A not-ready 409 after the send was already attempted (such as whatsapp-web.js retrying after No LID for user, since v0.31.0 a whatsapp-web.js send that a page reload cut while it ran, or a Baileys connection lost while writing) and a timeout WhatsApp reports for a query the send awaits (code 408, answered 503) do not prove nothing was sent, so the key stays taken and a retry gets 409 IDEMPOTENCY_OUTCOME_UNKNOWN. HTTP status alone cannot prove that outcome. Claims are shared through the data database and forwarded to the session owner. Without a header, sends behave as before. send-bulk, click-button and status posts do not support this header; retrying a bulk request can create another batch. A call beyond the 24-hour window has no deduplication guarantee.

All five SDKs take caller-supplied send keys from SDK 0.6.0; the JavaScript and PHP 0.5.1 packages ignore the extra argument, so on those send the header through a raw request or a direct HTTP request. See SDK usage.

Send media​

The media routes — send-image, send-video, send-audio, send-document, and send-sticker — all share one flat request body (SendMediaMessageDto). There is no nested { image: { url } } wrapper. Provide a media source; if you send both, base64 is used and url is ignored:

  • url — a public http/https URL that OpenWA fetches server-side, or
  • base64 — raw base64 data, in which case mimetype is required.
FieldRequiredConstraints
chatIdyesRecipient JID.
urlconditionalRequired when base64 is absent. An absolute http:// or https:// URL, fetched through an SSRF guard and, since v0.23.6, through the session's egress proxy when it has one (unless SESSION_PROXY_URL_FETCH=false).
base64conditionalRequired when url is absent. Decoded size is checked against the media cap.
mimetypeconditionalRequired with base64 — for example image/jpeg, application/pdf, audio/ogg.
filenamenoMax 255 characters. Only send-document shows it to the recipient. When omitted the name is file, except that whatsapp-web.js takes the last path segment of a document url.
captionnoMax 1024 characters. Applies to image, video and document; ignored for audio and sticker, neither of which carries a caption on either engine.

Omitting both url and base64, or sending base64 without mimetype, returns 400. Since v0.24.0 a present, non-string base64 is also refused when a valid url is supplied. Since v0.25.0 Baileys refuses SVG input for stickers and group/profile pictures with 400; convert it to PNG or WebP first. A sticker conversion over 500 animation frames is refused; an animated WebP passes through unchanged. Since v0.31.0 send-sticker on whatsapp-web.js answers 400 for a video that ffmpeg refuses to convert and 503 when the host's ffmpeg is missing or cannot run the conversion; both answered 500 before, counted toward the send breaker and kept the Idempotency-Key. Since v0.28.0 send-sticker on whatsapp-web.js also refuses non-image and non-video media (such as application/pdf or audio/*) with 400 before calling the browser, and send-video on Baileys extracts a 32-pixel-wide first-frame JPEG inline preview when ffmpeg is runnable at FFMPEG_PATH (ffmpeg by default; skipped when ffmpeg is absent or the video is unreadable). Since v0.23.6 so does a url that is not an absolute http(s) URL, on every send, status and picture route that takes a media url (status posts, profile and group pictures included), unless base64 carries data: the base64 payload is then sent and the url is neither fetched nor checked. Before, such a value (one without a scheme, or an ftp:// link) passed validation and was sent as garbled base64. The conversion routes already refused it with 400.

In other ways the check is looser than the one it replaced on the media routes above (send-image, send-video, send-audio, send-document, send-sticker) and on the profile and group pictures. Before v0.23.6 a single-label host such as http://media-store/a.jpg, a host containing an underscore, and a URL longer than 2084 characters (a long presigned S3 link, for example) all answered 400 there; now they are accepted. The SSRF guard still checks the host, so an internal host must be listed in SSRF_ALLOWED_HOSTS.

Since v0.31.0 a url that carries a user name or password (https://user:secret@host/file) is refused with 400 (Media URL must not contain credentials (userinfo)) before any connection is made, on every route that fetches a media url. Before, the send answered 500, counted toward the send breaker and kept its Idempotency-Key. A url whose server answers with a redirect is refused with 400 and Destination address is not allowed, the text a blocked address gets, and SSRF_ALLOWED_HOSTS does not lift it: send the address the redirect leads to. A send-bulk item whose url is redirected fails on its own with the error code SEND_BLOCKED.

Image by URL​

curl -X POST "$BASE/sessions/$SESSION/messages/send-image" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"url": "https://example.com/image.jpg",
"caption": "Check out this image!"
}'

Image by base64​

curl -X POST "$BASE/sessions/$SESSION/messages/send-image" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"base64": "/9j/4AAQSkZJRg...",
"mimetype": "image/jpeg"
}'

Document​

curl -X POST "$BASE/sessions/$SESSION/messages/send-document" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"url": "https://example.com/report.pdf",
"filename": "report.pdf",
"mimetype": "application/pdf"
}'

Audio / voice note​

Send a plain audio file by pointing url or base64 at the audio:

curl -X POST "$BASE/sessions/$SESSION/messages/send-audio" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"url": "https://example.com/song.mp3",
"mimetype": "audio/mpeg"
}'

Add "ptt": true to send a real WhatsApp voice note — the microphone bubble with a waveform — instead of a plain audio file. Voice notes require audio/ogg; codecs=opus, so when ptt is set without a mimetype the server defaults to that. Supply OGG/Opus bytes for reliable playback. A ptt send is stored and reported as message type voice, matching how inbound voice notes are classified.

curl -X POST "$BASE/sessions/$SESSION/messages/send-audio" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"url": "https://example.com/clip.ogg",
"ptt": true
}'

ptt is valid only on send-audio. send-video and send-sticker use the identical body as plain audio — point url or base64 at a video (video/mp4) or a sticker (image/webp).

Media size cap

All media share one byte cap: 50 MiB (52,428,800 bytes) by default, set by the MEDIA_DOWNLOAD_MAX_BYTES environment variable. It bounds base64 sends, remote-URL downloads, and inbound media alike. A blob whose decoded size exceeds the cap is rejected with 413 Payload Too Large.

A base64 send must also fit the request body limit, BODY_SIZE_LIMIT (25mb by default), because the base64 text travels in the JSON body and is a third larger than the file. On a default install the largest file you can send as base64 is about 18.7 MiB; a bigger request answers 413 with request entity too large before the media cap is checked. Send the file by url, which counts only against the media cap, or raise BODY_SIZE_LIMIT together with MEDIA_DOWNLOAD_MAX_BYTES; see Troubleshooting.

A remote URL pointing at an internal or blocked address is rejected by the SSRF guard with 400 on a single send route, and since v0.31.0 also on a status post and a profile or group picture (500 before); a send-bulk item fails on its own after the 202; the rejection message is generic and does not disclose the resolved internal address.

Since v0.23.6 a remote-URL download that runs over the cap answers 413 as well, and a URL that answers non-2xx, times out, or cannot be reached answers 400. Both used to surface as a 500 that counted toward the send breaker. On a session with an egress proxy the download leaves through that proxy, and a connection failure or timeout before any response arrives answers a retryable 503, since the gateway cannot tell a proxy outage from an unreachable host. The gateway still resolves and checks the host name itself before the request reaches the proxy, so a host it cannot resolve, or one that resolves to a blocked address, is refused just as it is without a proxy. Only a direct fetch or a SOCKS proxy keeps the guard's DNS-rebind pinning, though: an http or https proxy resolves the name again with its own resolver, so a name that passes the check and then re-resolves to an internal address reaches it, if the proxy can. SESSION_PROXY_URL_FETCH=false fetches from the gateway's own address instead, which keeps the pinning and suits a proxy that only routes WhatsApp traffic.

A send by url holds the whole body in memory: at least twice its size at the peak and, on whatsapp-web.js, more while the page call that carries it is in flight, until the engine has taken it. Size the container memory for the number of large sends you run in parallel.

Convert media server-side​

WhatsApp is picky about formats — a voice note only plays as Ogg/Opus, a video streams cleanly only as fast-start MP4. When your source is something else, convert it on the gateway before sending instead of building an ffmpeg pipeline of your own. Conversion is opt-in and gated behind MEDIA_CONVERSION_ENABLED (default off).

First check the gateway can convert for the session — GET /api/sessions/{sessionId}/media/convert reports whether conversion is switched on and the ffmpeg binary actually runs, so you can decide between converting here and converting before you send:

curl "$BASE/sessions/$SESSION/media/convert" \
-H "X-API-Key: $API_KEY"
{ "available": true }

When available is false, the convert routes answer 503 — set MEDIA_CONVERSION_ENABLED=true and, if ffmpeg is not on PATH, point FFMPEG_PATH at the binary. The official Docker image ships ffmpeg and only needs the flag.

A key restricted with allowedChats (v0.23.6+) is refused every conversion route, the GET availability check included, with 403. Convert with a key that has no allowedChats, then send the bytes with the restricted one.

RouteOutputUse it before
POST /api/sessions/{sessionId}/media/convert/voiceOgg/Opus audiosend-audio with ptt: true, or status/send-voice
POST /api/sessions/{sessionId}/media/convert/videoFast-start MP4 (baseline H.264 + AAC, long edge ≤ 1280)send-video or status/send-video

Both take the same flat body. Give exactly one source — base64 wins if you supply both:

FieldNotes
urlPublic http/https URL, server-fetched through the SSRF guard. Since v0.23.6 a proxied session's fetch leaves through its egress proxy: the running engine's, or the one stored on the session when it is not started. SESSION_PROXY_URL_FETCH=false fetches it from the gateway's own address instead.
base64Raw base64 of the media. Takes precedence when both are supplied and it holds data. Since v0.26.0 a bare data:...;base64, prefix counts as empty, so url is used, and an empty url beside base64 is accepted (it answered 400 before).

A voice-note conversion returns bytes ready to pass straight to send-audio with ptt: true:

# 1. Convert the source into Ogg/Opus.
curl -X POST "$BASE/sessions/$SESSION/media/convert/voice" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/note.m4a" }'
{ "mimetype": "audio/ogg; codecs=opus", "base64": "T2dnUwAC..." }
# 2. Send the converted bytes as a voice note.
curl -X POST "$BASE/sessions/$SESSION/messages/send-audio" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"base64": "T2dnUwAC...",
"mimetype": "audio/ogg; codecs=opus",
"ptt": true
}'

Conversion is bounded so a burst cannot stack ffmpeg processes. MEDIA_CONVERSION_CONCURRENCY (default 2) caps concurrent conversions behind a short queue; beyond the queue the endpoint answers 503 — retry shortly rather than piling on. Each conversion is also killed after MEDIA_CONVERSION_TIMEOUT_MS (default 60000), and the converted bytes are capped at MEDIA_CONVERSION_MAX_OUTPUT_BYTES (default 50 MiB).

Since v0.23.6 ffmpeg reads only single-file media containers: MP4, M4A, 3GP and MOV, Matroska and WebM, Ogg, MP3, WAV and W64, AAC, AC-3 and E-AC-3, FLAC, WavPack, AU, AMR, AVI, MPEG-PS and MPEG-TS, ASF, FLV, CAF, AIFF, GIF, and raw H.264 and HEVC. Any other input, playlists and manifests included, is refused with 400.

StatusCause
400 Bad RequestNeither url nor base64 given, ffmpeg refused the input (including a format outside the list above), or the input URL is not an absolute http(s) URL, carries a user name or password (v0.31.0+), is blocked, answers non-2xx, times out, or cannot be reached.
413 Payload Too LargeThe supplied media, or since v0.23.6 the media downloaded from url (a 400 before), is above the media size cap.
503 Service UnavailableConversion is disabled, ffmpeg is not runnable, or the queue is saturated — retry shortly. Since v0.23.6 also a url fetch through the session's egress proxy that failed to connect or timed out before any response. Since v0.26.0 also any request once the gateway is shutting down, and no new ffmpeg work starts then.

Mention participants​

Every text-carrying route accepts an optional mentions array of WIDs (<phone>@c.us) to tag participants — most useful in groups. That is send-text, the media routes, and (since v0.23.0) reply, edit, send-template, and each send-bulk item. Pass neutral @c.us WIDs and the active engine de-normalizes them. For a tag to render and notify, the text or caption must also contain the matching @<number> token:

curl -X POST "$BASE/sessions/$SESSION/messages/send-text" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "120363021234567890@g.us",
"text": "Hey @628123456789, can you check this?",
"mentions": ["628123456789@c.us"]
}'

Inbound messages that tag participants surface the tagged WIDs as mentionedIds on the webhook payload. See the API reference for the full field constraints.

On edit the tags are re-applied, not preserved: an edit replaces the message content, so a caller editing a tagged message passes mentions again or the tags are gone. On Baileys, since v0.28.0, edit refuses a message that carries no text or caption (such as a location, contact card, audio, sticker, or uncaptioned media) with 403.

In send-bulk, since v0.26.0, an item's mentions entry may also be a {{placeholder}} that the item's variables fill in, so one batch can tag a different participant per item. The rendered value must be an individual WID (<phone>@c.us or <lid>@lid), or that item fails.

Send a location​

send-location requires latitude and longitude; description and address are optional.

curl -X POST "$BASE/sessions/$SESSION/messages/send-location" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"latitude": -6.2088,
"longitude": 106.8456,
"description": "Jakarta",
"address": "Central Jakarta"
}'

Coordinates outside the valid latitude/longitude range return 400.

Send a contact card​

send-contact requires chatId, contactName, and contactNumber.

curl -X POST "$BASE/sessions/$SESSION/messages/send-contact" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"contactName": "John Doe",
"contactNumber": "628987654321"
}'

Send a poll​

POST /api/sessions/{sessionId}/messages/send-poll sends a native WhatsApp poll with 2–12 options. Single choice is the default; set allowMultipleAnswers to true to let voters pick more than one. Polls work on both engines.

curl -X POST "$BASE/sessions/$SESSION/messages/send-poll" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "120363021234567890@g.us",
"name": "Where should we meet?",
"options": ["Park", "Beach", "Downtown"],
"allowMultipleAnswers": false
}'

name is the poll question (max 255 characters); each entry in options is a vote label (max 100 characters). The gateway stores the poll as 📊 <name> in the sent row's body so the history stays readable (see Filter and page stored messages for what the engine reports). Like the other send routes, send-poll returns 201 with { messageId, timestamp }. An inbound poll arrives as a message of type poll, and since v0.23.2 its question fills body on both engines. Since v0.25.0 poll creation messages also carry poll: { name, options, allowMultipleAnswers } in live events and history; persisted messages store the same object in metadata.poll. Poll choices remain available after reload. An inbound poll is cut to 32 options of at most 1024 characters, and its question to 1024 characters, on both engines since v0.26.0 (far above WhatsApp's own limits). This describes poll creation, not a stream of vote updates: on whatsapp-web.js, since v0.26.0, votes arrive as the poll.vote event (see Webhooks), and on Baileys since v0.30.2, where a vote is reported while the poll's creation message is still in the session's message store (BAILEYS_MESSAGE_STORE_LIMIT) and earlier votes are not backfilled.

The JavaScript SDK wraps the route as client.messages.sendPoll:

const poll = await client.messages.sendPoll('8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a', {
chatId: '120363021234567890@g.us',
name: 'Where should we meet?',
options: ['Park', 'Beach', 'Downtown'],
});

React to a message​

POST /api/sessions/{sessionId}/messages/react adds or removes an emoji reaction on an existing message. All three fields are required; send an empty emoji to remove a reaction.

curl -X POST "$BASE/sessions/$SESSION/messages/react" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"messageId": "true_628123456789@c.us_3EB0ABCD",
"emoji": "👍"
}'

Unlike the send routes, react returns 200 OK with a fixed body:

{ "success": true }

Reply and forward follow the same pattern: reply sends a text reply quoting a prior message ({ chatId, quotedMessageId, text } — all three required, text capped at 4096 characters), and forward copies one between chats ({ fromChatId, toChatId, messageId }). Both return 201. Since v0.27.1 forward copies the original message's type, text, and media onto the new stored message row when the source message is in the gateway's history (falling back to type: "forward" and [Forwarded] only when it is not). On whatsapp-web.js, since v0.28.0, GET /api/sessions/{sessionId}/messages/{chatId}/{messageId}/receipts (viewer role, open to chat-scoped keys for an allowed chatId; Baileys answers 501) returns the per-recipient delivery, read, and played timestamps ({ messageId, chatId, receipts: [{ participantId, deliveredAt, readAt, playedAt }] }) for a message sent by this session (403 if the message was not sent by the session, 404 if the chat or message is not found). See the API reference.

reply is not deprecated and is not superseded. It is the text shorthand, and the one route that takes quotedMessageId from a key restricted with allowedChats (v0.23.6+), because it binds the quote to the chat it sends into. Before v0.23.6 it was also the only quoting call that resolved the quoted message's body into the stored quote preview; every quoted send does now. Reach for quotedMessageId on a send-* route instead whenever the reply carries anything other than plain text, or when you also need linkPreview or customLinkPreview — neither of which reply accepts (mentions it does take, since v0.23.0). Neither mechanism replaces the other; both ship and both are supported. See Quote a message on any send below.

Delete a message​

POST /api/sessions/{sessionId}/messages/delete deletes a message and needs an operator key. chatId and messageId are required. forEveryone is optional and defaults to true; send the boolean false to delete the message on the account's side only. The route answers 200 with { "success": true }.

A delete for everyone only takes effect when the account sent the message or administers the group, because WhatsApp ignores any other revoke. Since v0.23.7, when the account cannot revoke the message (another sender's message in a one-to-one chat, or in a group the account does not administer), Baileys deletes it, with its media, for the account alone and still answers 200; before, it reported success and deleted nothing. When a group's member list shows no row for the account, the revoke is still sent. A 200 therefore does not prove the other party lost the message.

Quote a message on any send (v0.17.0+)​

Since v0.17.0 nine send routes accept an optional quotedMessageId string, which turns the send into a reply quoting an earlier message. The field is optional on every one of them — adding it changes nothing else about the call — and an empty string is rejected with 400.

Route (POST /api/sessions/{sessionId}/messages/…)The reply carries
send-texttext
send-imagean image
send-videoa video
send-audioaudio — a quoted voice note is { chatId, url, ptt: true, quotedMessageId }
send-documenta document
send-stickera sticker
send-locationa location
send-contacta contact card
send-polla poll

send-template, send-bulk, send-product, and click-button (v0.23.6+) do not accept quotedMessageId, and they reject it with 400 rather than ignoring it — every route refuses body fields it does not declare. From a key restricted with allowedChats (v0.23.6+), a non-empty quotedMessageId at the top level of the body answers 403 instead, because the chat fence refuses it before validation runs. If you build send bodies from one shared template, strip the field before it reaches those four instead of assuming it is harmless everywhere. (send-catalog accepted it equally little, but the route was removed in v0.19.0.) The four status/send-* routes do not accept it either: status posts are not quotable.

The id format differs per engine​

The id is engine-specific, and the two formats are deliberately not harmonized — a body that works on one engine does not work verbatim on the other:

whatsapp-web.jsBaileys
id to supplythe serialized message id (true_<chat>_<hash>)the raw message key id
where it is resolvedin the WhatsApp Web pagethe gateway's local message store
message not found404 — the send is refused404 — the send is refused

Baileys can only quote a message it has already stored. Since v0.31.0, with STORE_EPHEMERAL_MESSAGES=false, Baileys keeps no copy of an incoming disappearing message, so a quote, reply, forward, reaction, edit, star, pin, unpin, delete by id or click-button aimed at one answers 404; on whatsapp-web.js the live chat history still returns such a message, because WhatsApp Web holds it until it expires. On Baileys, an unlink (a logout, or one that WhatsApp starts) also deletes the stored copies of the session's messages, so a reply, forward or reaction to a message from before it answers 404 from then on (see Sessions). Neither engine checks that the quoted message belongs to the chat you are sending to — the id is passed through as given.

Since v0.23.6 the stored row of every quoted send keeps the quoted message's text in its quote preview (metadata.quotedMessage.body), looked up in this gateway's history. Before, only reply did; the other routes stored the quoted id with an empty body, which the dashboard drew as a blank quote box. A quoted message with no text of its own, such as a caption-less image, still stores an empty body.

A key restricted with allowedChats (v0.23.6+) is refused quotedMessageId on every route in the table above with 403: a quote can name a message from a chat outside the key's allowlist. Use reply for a text reply with such a key. See Authentication.

Reply to a message with an image:

curl -X POST "$BASE/sessions/$SESSION/messages/send-image" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"url": "https://example.com/receipt.jpg",
"caption": "Here is the receipt you asked for",
"quotedMessageId": "true_628123456789@c.us_3EB0ABCD"
}'

The response is the usual 201 with { messageId, timestamp }.

An id the engine cannot resolve fails the send with 404 Not Found on both engines, message Message <id> not found — the send is not delivered unquoted, so nothing reaches the recipient. On whatsapp-web.js this is a change: the same request answered 500 before v0.17.0. Two consequences for retry logic:

  • A client that branches on status codes must treat an unresolvable quote as a 404 on whatsapp-web.js, where it used to read as a server fault.
  • Only failures that reached WhatsApp count toward the send breaker, and a 404 is not one of them. Retrying a stale quote id therefore no longer accumulates toward the breaker, so a caller looping on an expired id can no longer pause every send on that session for the breaker cooldown.
One case whatsapp-web.js still delivers unquoted

If the quoted message resolves but WhatsApp Web decides it is not replyable, whatsapp-web.js sends the message without the quote and still answers 201. That path is upstream and cannot be switched off, so a caller that must confirm the quote landed has to check the delivered message. Baileys has no such case.

Answer a WhatsApp Business prompt (v0.23.6+)​

Some businesses send prompts with choices to tap: reply buttons, template quick replies, or list rows. On Baileys such a prompt reaches message.received with a buttons array (see Inbound message types), and POST /api/sessions/{sessionId}/messages/click-button answers it by sending the structured reply WhatsApp expects, quoted to the prompt.

FieldRequiredConstraints
chatIdyesThe chat that holds the prompt.
messageIdyesThe WhatsApp id of the inbound prompt.
buttonIdyesA buttons[].id from that prompt. Max 256 characters.
textnoThe visible label, max 4096 characters; an empty string is refused with 400. When omitted, it is read from the stored prompt. When given, it is sent as the reply's label (trimmed) even if no choice carries it, and when several choices share buttonId (a list that repeats a row id across sections) the one labelled text is answered; otherwise the first choice with that id is.
curl -X POST "$BASE/sessions/$SESSION/messages/click-button" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"messageId": "0587502EE4F5C80E5C",
"buttonId": "yes",
"text": "Yes"
}'

Like the send routes, it returns 201 with { messageId, timestamp }, and the stored reply quotes the prompt's text.

Baileys only, and not a native tap

whatsapp-web.js has no interactive-reply send path and answers 501. On Baileys the reply is built by the library's button-reply and list-reply helpers, so WhatsApp may treat it differently from a tap on a phone. Classic button, template, and list prompts are supported; replies to native-flow interactiveMessage prompts are unverified. Only reply buttons, template quick replies, list rows, and native-flow buttons named quick_reply or button_click appear in buttons and can be clicked. URL and call buttons, and every other native-flow button (a copy-code button, for example), never do.

The prompt must still be in the Baileys message store, which holds what the session sent and received over its live connection, including messages WhatsApp queued while it was offline, but not the history synced when the account was linked. The store is kept in the database and survives a restart, but it holds only the newest BAILEYS_MESSAGE_STORE_LIMIT messages per session (default 5000, sent and received counted together), so a prompt drops out of it as newer traffic arrives. A prompt the store no longer holds, or one from another chat, answers 404, even when the dashboard still renders its buttons from the stored row. A 400 means the message is not a prompt with clickable choices, or buttonId is not one of them. A template prompt that numbers its buttons is answered with the tapped button's own number, one that numbers none with its position, and a reply to a choice that a numbered template left unnumbered carries its id and label with no number at all.

The SDKs wrap this route from 0.5.1; in the JavaScript SDK it is client.messages.clickButton (see SDK usage).

Send to many recipients​

POST /api/sessions/{sessionId}/messages/send-bulk queues a batch and processes it in the background, with a delay between its own sends. It accepts up to 100 messages and returns immediately. Each batch spaces only its own items: batches on the same session are not serialised, so batches that run at once send at their combined rate. Queue the next batch after the previous one finishes.

Cold blasts get numbers banned

Sending the first-ever message to a batch of strangers is the top cause of WhatsApp restrictions, on either engine — pacing does not protect you. Send bulk only to recipients who opted in, and read Ban risk & safe sending before you broadcast.

Each item carries a type (text, image, video, audio, or document) and a typed content object. Use {{name}} placeholders in text plus a per-item variables map for mail-merge style substitution. Per-item text and caption match the single-send caps (4096 and 1024 characters), and variables must be an object — a non-object value is rejected with 400. Items that are identical in chatId, type, content and variables are queued once, the first one winning, so totalMessages can be lower than the number of items you sent.

Media presence and size are re-validated per item after variable substitution and the message:sending hook run — a {{variables}} substitution or a hook rewrite that grows a payload past the 50 MiB media cap, or strips the last media source, fails just that item (honoring stopOnError) instead of failing the whole batch. Since v0.26.0 the rendered size is measured before the text is built, so a placeholder repeated through a small body cannot make the server allocate the result first: an item with variables whose rendered text or caption would pass TEMPLATE_RENDER_MAX_CHARS (default 64 KiB), whose rendered media would pass the media cap, or whose other strings (a URL, a filename) would together grow by more than TEMPLATE_RENDER_MAX_CHARS characters fails just that item.

Since v0.23.6 a media item's url must be an absolute http(s) URL, unless the item's base64 carries data (then base64 is sent and url is not checked). An item whose url is not one fails the whole request with 400 and nothing is queued, unless the url contains a { (as a {{placeholder}} does): that one is checked after substitution, and a rendered value that is not an absolute http(s) URL fails just that item (honoring stopOnError). A url is downloaded after the 202, so one that cannot be fetched, or runs over the cap, also fails just that item. Since v0.31.0 a url that carries a user name or password is treated the same way: one written out in the request fails the whole request with 400 and nothing is queued, and one that a placeholder renders fails just that item.

curl -X POST "$BASE/sessions/$SESSION/messages/send-bulk" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "chatId": "628111111111@c.us", "type": "text", "content": { "text": "Hi {{name}}" }, "variables": { "name": "Alice" } },
{ "chatId": "628222222222@c.us", "type": "image", "content": { "image": { "url": "https://example.com/promo.jpg" }, "caption": "Promo" } }
],
"options": { "delayBetweenMessages": 3000, "randomizeDelay": true, "stopOnError": false }
}'

send-bulk returns 202 Accepted with a batchId and a statusUrl:

{
"batchId": "batch_a1b2c3d4",
"status": "pending",
"totalMessages": 2,
"estimatedCompletionTime": "2026-06-25T09:21:00.000Z",
"statusUrl": "/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/messages/batch/batch_a1b2c3d4"
}

options controls how this one batch spaces its own items: delayBetweenMessages (milliseconds, 1000–60000, default 3000), randomizeDelay (adds 0–2 s of jitter, default true), and stopOnError (halt on the first failure, default false).

A top-level batchId names the batch yourself instead of the generated batch_<id>; it must be at most 255 characters and unique within the session, or the request answers 400. A batch arriving during shutdown answers 503 and is not sent. Since v0.23.6 . and .. are refused with 400, GET .../batch/history reads the batch named history instead of being routed to chat history, and statusUrl percent-encodes the id, so an id containing /, ?, or # can be followed from it. Percent-encode the id the same way when you build the status or cancel URL yourself.

Track and cancel a batch​

Poll GET /api/sessions/{sessionId}/messages/batch/{batchId} for progress:

{
"batchId": "batch_a1b2c3d4",
"status": "processing",
"progress": { "total": 2, "sent": 1, "failed": 0, "pending": 1, "cancelled": 0 },
"results": [
{ "chatId": "628111111111@c.us", "status": "sent" },
{ "chatId": "628222222222@c.us", "status": "pending" }
]
}

Batch status is one of pending, processing, completed, cancelled, or failed; each result is pending, sent, failed, or cancelled. Cancel a running batch with POST /api/sessions/{sessionId}/messages/batch/{batchId}/cancel; remaining pending items move to cancelled; the response's counters are those of the last saved checkpoint, so a recipient whose send is running when the batch is cancelled may still be delivered, and then counts as sent when you read the batch. A failed result carries error: { code, message }, where code is SEND_FAILED when the engine refused or failed the send, SEND_BLOCKED when the SSRF guard refused the media url, and SEND_PACING_LIMITED when send pacing refused the send. The terminal statuses are exclusive — cancelling a batch that is already completed, cancelled, or failed returns 400 (Batch '<id>' is already <status>), so a cancel can no longer relabel a failed batch and mask its delivery failures. A cancellation is also final once it lands: every status transition is a guarded database update, so a batch's later writes can't flip cancelled back — even a cancel that arrives before the first item is sent.

A batch a crash left processing is marked failed at the next start (since v0.2.2). Since v0.24.0 the next start also marks failed a batch left pending, and a gateway shutdown marks every batch it is still running failed. None of them is resumed. Items already sent stay sent; read progress and results from the status route to see which, then send the rest as a new batch.

A key restricted with allowedChats (v0.23.6+) can queue a batch for chats in its allowlist but cannot follow it: the status and cancel routes answer 403 for such a key, because a batch records no key to check the allowlist against. Poll and cancel with a key that has no allowedChats, or send through the single-send routes instead.

Post a status update​

The status endpoints post to the WhatsApp Status (Stories) feed. All four work on both engines; what differs is the audience. Baileys posts to exactly the recipients allow-list. whatsapp-web.js ignores recipients and broadcasts to the account's status-privacy audience instead. A key restricted with allowedChats (v0.23.6+) is refused every status route with 403.

RouteBody
POST /api/sessions/{sessionId}/status/send-texttext (max 4096), recipients[], optional backgroundColor (#rrggbb), optional font: one of 0 (System), 1 (System text), 2 (Script), 6 (Bold), 7 (Morning Breeze), 8 (Calistoga), 9 (Exo 2), 10 (Courier Prime), the names the dashboard shows; any other value is rejected with 400, and whatsapp-web.js honors only 0 to 7 and clamps anything higher to the default
POST /api/sessions/{sessionId}/status/send-imageimage (url or base64 + mimetype), recipients[], optional caption
POST /api/sessions/{sessionId}/status/send-videovideo (url or base64 + mimetype), recipients[], optional caption
POST /api/sessions/{sessionId}/status/send-voiceaudio (url or base64), recipients[], optional backgroundColor (#RRGGBB, Baileys only); see note below (v0.14.0+)

recipients is engine-conditional: up to 256 JIDs, each <phone>@c.us or <phone>@lid. On Baileys it is the allow-list the status is posted to, so it is effectively required there: omitting it or sending an empty array is rejected with 400. On whatsapp-web.js it is ignored, so omit it. @c.us recipients are reliable; @lid is best-effort and unverified.

Since v0.23.6 a media status post also checks the value it is about to post. Beyond the url rule under Send media, a base64 value that is not base64 text, such as a file path with an extension (cdn/banner.jpg) or a data URI that is not base64-encoded (data:image/png,...), is refused with 400 (media must be an absolute http(s) URL or base64); before, it was handed to the engine as if it were base64. The check runs on the media after the message:sending hook, so a plugin that rewrites the media to such a value is refused the same way. A path made only of base64 characters (such as cdn/banner) cannot be told apart from base64 and is still sent as such. Since v0.26.0 an empty url beside base64 is accepted (it answered 400 before), and a media source sent as an array instead of an object answers 400.

curl -X POST "$BASE/sessions/$SESSION/status/send-text" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "We are live!",
"recipients": ["628123456789@c.us", "628987654321@c.us"],
"backgroundColor": "#25D366"
}'

A voice status posts an audio clip as a playable voice bubble. WhatsApp plays a status voice note only as Ogg/Opus and neither engine transcodes, so convert the source first with /media/convert/voice. backgroundColor styles the bubble behind the voice note and is honored on Baileys only; whatsapp-web.js ignores it and broadcasts to the account's status-privacy audience instead of an explicit recipients list.

curl -X POST "$BASE/sessions/$SESSION/status/send-voice" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"audio": { "base64": "T2dnUwAC..." },
"backgroundColor": "#25D366",
"recipients": ["628123456789@c.us"]
}'

In the SDK, these live on client.status:

await client.status.sendText("8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a", {
text: "We are live!",
recipients: ["628123456789@c.us"],
});

Since v0.28.0, a status update deleted by its poster is removed from GET .../status, GET .../status/{id}, and GET .../status/{statusId}/media (404 on media), and GET .../status/{id} no longer matches a phone number before the first @ on a two-@, group, or channel id.

Send from the JavaScript SDK​

The @rmyndharis/openwa SDK 0.13.0 wraps the send routes above, including messages.clickButton (see SDK usage), messages.receipts (v0.28.0+), and contacts.lid (v0.27.1+). Construct the client with the server root (no /api suffix) and your key:

import { OpenWAClient } from "@rmyndharis/openwa";

const client = new OpenWAClient({
baseUrl: "http://localhost:2785",
apiKey: process.env.OPENWA_API_KEY!,
});

const result = await client.messages.sendText("8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a", {
chatId: "628123456789@c.us",
text: "Hello from the OpenWA SDK!",
});

console.log(result.messageId);

client.messages exposes sendImage, sendVideo, sendAudio, sendDocument, sendSticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, forward, react, and sendBulk with the same fields as the curl bodies above. Status posts live on client.status (sendText, sendImage, sendVideo, sendVoice, alongside list, fromContact, media, and delete). See SDK usage.

Filter and page stored messages​

GET /api/sessions/{sessionId}/messages reads the gateway database, not live WhatsApp history. In v0.25.0 it accepts these filters alongside chatId, from, limit (1-100, default 50), offset, after and inlineMedia:

ParameterMeaning
messageIdExact WhatsApp message reference.
sinceInclusive lower message-time bound in Unix milliseconds.
untilExclusive upper message-time bound in Unix milliseconds.
directionincoming or outgoing.
typeExact stored type, such as text, image or voice.
orderBycreatedAt (default, ingestion time) or timestamp (message time), newest first.
curl "$BASE/sessions/$SESSION/messages?chatId=628123456789%40c.us&since=1791936000000&until=1792022400000&direction=incoming&orderBy=timestamp&inlineMedia=false&limit=100" \
-H "X-API-Key: $API_KEY"

Time bounds must be finite, safe numbers between 0 and 9007199254740991; decimal and scientific notation work, but blank, invalid or reversed bounds return 400. Message times remain whole seconds in stored rows. With a time bound or orderBy=timestamp, unknown times are excluded from messages and total, and counted separately as unknownTimestampTotal. Since v0.27.0 messages sent through the API store from as <phone>@c.us instead of bare digits, and the from filter matches both forms.

Continue with after=<last row id>, retaining every filter and orderBy. It takes precedence over offset. The cursor must belong to the selected session; a deleted or unknown anchor returns 400. With since, until, direction, type, messageId or orderBy=timestamp it must also belong to the same selection (chatId and from included), or the request returns 400. With only chatId and from, a cursor from another chat of the same session is accepted and the page continues from that row's position in the order. Timestamp ordering breaks ties by UUID. Concurrent older arrivals may appear later, so pagination does not freeze the archive or establish complete remote history. A chat-restricted key must supply an allowed chatId.

The body the gateway writes for a send made through the API is 📇 <contact name> for a contact card, 📊 <poll name> for a poll, 📍 <description or Location> for a location, and the file name for a document sent without a caption. The engine reports the same send back with a body of its own (a contact card's vCard, the poll question, no file name for a document), and the stored row keeps whichever of the two reaches the database first, so the stored body can differ from the gateway's text and between engines. message.sent carries the engine's form.

Since v0.24.0 MESSAGE_RETENTION_DAYS can remove stored messages and finished bulk batches at boot and daily. Its default 0 keeps them indefinitely; a value above 36500 fails boot. Retention can remove a cursor between pages.

Inbound message types and omitted media​

When you receive messages back over webhooks or the WebSocket, the type field discriminates the payload. Beyond the familiar text, image, video, audio, document, sticker, location, and contact types, watch for:

typeMeaning
voiceA PTT voice note (matches the outbound ptt send).
pollA native WhatsApp poll (matches send-poll).
callAn incoming call; carries { video, missed } detail.
maskedA high-security business message (e.g. an enterprise OTP) whose body is withheld on linked devices — the body is empty by design and only readable on the primary phone.
revokedA message deleted "for everyone"; the payload carries an optional revokedId for the original message.
orderA cart the customer placed from your business catalog (v0.23.5+, both engines; before that it arrived as a bodyless unknown). The message carries no line items: order.orderId, plus the single-order order.token when WhatsApp sends one, is the correlation handle you redeem against WhatsApp's own order lookup, which OpenWA does not proxy. Pass the token through unchanged and keep it out of your logs.
productA catalog product card shared into the chat (v0.23.5+, both engines; before that it arrived as a bodyless unknown). Both engines fill product.productId; title, description, and businessOwnerJid are best-effort. The id resolves through the catalog routes only when businessOwnerJid's catalog is the session's own, and those routes are Baileys only. Sharing a whole catalog rather than one card carries no product id, and the engines differ: Baileys reports unknown, filling body with the text the share carried, or the catalog title when it carried none; whatsapp-web.js keeps type: "product" with product unset. Branch on the product field, not on the type alone.

On whatsapp-web.js, a security, business or group notice WhatsApp Web draws in a chat is left out of the live chat history and is not reported as a chat's last message (v0.30.2+; live delivery of notices stopped in v0.28.0), and an entry of a kind the library does not list that carries neither text nor media is not stored or announced as an unknown message, is left out of the live chat history and is not reported as a chat's last message (v0.30.2+). The header of an album is left out the same way since v0.30.3, and its photos and videos arrive as messages of their own. That history returns a message deleted for everyone as revoked under the id the message had (v0.30.2+; it carried the id of the delete notice before), and since v0.30.3 under the id of its stored row when the delete notice names the chat, or in a group the author, in the other id form (phone number or lid) and the gateway knows the two to be one person. On Baileys, a message or status that decrypts only in part and is left with no content is not stored or announced as an empty unknown message (v0.30.2+), so a redelivery that carries the content is not skipped as a duplicate.

Since v0.23.2 the Baileys engine fills body for inbound content that carries display text without being a plain message: a shared contact card's vCard (several cards shared at once are newline-joined into one multi-vCard body, in the order they were shared), a poll's question, a shared event's name, and the label a contact tapped on a business button or template reply. That text previously arrived as an empty body on Baileys, so a body filter, a search, or the dashboard missed it; whatsapp-web.js already reported the vCard, the poll question, and the event name. On whatsapp-web.js a message that shares several contacts had an empty body until v0.31.0, and now holds their vCards newline-joined as on Baileys; the chat list preview and a quote of such a message carry them too. Quoting one of these keeps its text in the quoted-message preview instead of an empty string.

Since v0.23.6 Baileys also reports business prompts and the replies to them in structured form on message.received. Neither field below exists on whatsapp-web.js, so the REST chat-history route, which only whatsapp-web.js serves, never carries them. Since v0.29.1 message.received and message.sent on both engines, and GET /api/sessions/{sessionId}/messages/{chatId}/history on whatsapp-web.js, carry isForwarded: true when WhatsApp marks the message as forwarded, together with forwardingScore (how many times it has been forwarded) when the engine reports a positive value; both fields are absent on non-forwarded messages, stripped on revoke, and not included on stored-message responses (GET /api/sessions/{sessionId}/messages).

  • A prompt that offers choices (reply buttons, template quick replies, list rows, native-flow quick_reply and button_click buttons) carries buttons: [{ id, text }], up to 20 of them. Only choices that can be answered with a reply are listed: URL and call buttons, and every other native-flow button such as a copy-code button, are left out. The choices are also kept in the stored row's metadata.buttons. Pass an id to click-button to answer the prompt.
  • A tap on a button, quick reply, list row, or native-flow control arrives as type: "text" with button: { id, text? }: id is the stable id the business gave the choice, and the label also fills body. button is left out when WhatsApp sent no id. Such a reply also carries quotedMessage: { id, body } naming the prompt it answers, when WhatsApp includes one, so quotedMessage.id matches that prompt's id; before v0.23.6 Baileys delivered these replies with no quote.
  • listMessage, buttonsResponseMessage, templateButtonReplyMessage, and listResponseMessage now arrive as type: "text" rather than unknown, so a consumer that filters on type sees them as text. A list prompt's description, or its title when it has none, now fills body, which was empty before.

Since v0.24.0 INBOUND_MEDIA_GLOBAL_CONCURRENCY can cap downloads across all sessions in a process (default 0, disabled). Media waiting longer than MEDIA_DOWNLOAD_TIMEOUT_MS for a slot arrives omitted. On PostgreSQL, v0.25.0 also caps held payloads per session with INBOUND_MEDIA_CONCURRENCY, preserves arrival order within each chat, and omits a payload only after it has waited twice MEDIA_DOWNLOAD_TIMEOUT_MS with no slot released in that time; while slots keep releasing, it keeps waiting.

When MEDIA_DOWNLOAD_ENABLED=false — or an inbound media item exceeds the MEDIA_DOWNLOAD_MAX_BYTES cap — the media is not downloaded. The message still arrives, but its media field carries an omitted marker instead of the bytes:

{ "mimetype": "image/jpeg", "omitted": true, "sizeBytes": 84213 }

Use that shape to distinguish "media was present but not downloaded" from a genuinely text-only message.

Since v0.23.4 a download that fails produces the same marker on both engines, with the declared size, rather than dropping the media field altogether. Before that, a message that plainly carried an image reached webhooks and persistence looking like one that never had any: a filter or rule gated on hasMedia skipped it, and the dashboard rendered an empty bubble. Those messages now match hasMedia. On Baileys the failure is logged at warn rather than debug, so it is visible without raising LOG_LEVEL.

You can also ask for the markers deliberately. GET /api/sessions/{sessionId}/messages takes inlineMedia=false (v0.23.4+), which omits every inline payload while keeping each row's { omitted, sizeBytes } marker and leaving the media reachable through the per-message media route above. Only the exact strings false and 0 turn it off; anything else keeps the default. That matters when walking history: the inline-media budget (MESSAGE_LIST_INLINE_MEDIA_BUDGET_BYTES, 8 MiB) is spent per response, so a paged walk pays it again on every page, and a client that wants the rows rather than the bytes is asking for megabytes it will throw away.

Archive chat media server-side​

By default an inbound media item is downloaded once and attached inline to its stored message row. That stored copy stays downloadable while the row keeps it, even after WhatsApp's link expires. Switch on CHAT_MEDIA_ARCHIVE_ENABLED (default off) and every message's media is also written to the file store (local or S3), so it stays retrievable long after delivery.

Fetch it back with the chat and message id:

curl "$BASE/sessions/$SESSION/messages/628123456789@c.us/true_628123456789@c.us_3EB0ABCD/media" \
-H "X-API-Key: $API_KEY" -o photo.jpg

A successful response (200 OK) streams the bytes back as an attachment (with Content-Length when the store reports a size, v0.27.0+): the archived file when one exists, otherwise the inline copy held on the message row — which is how media sent by this account is served. On S3, at most 50 media downloads (chat and status media combined) are held open at once per process (503 with Retry-After: 1 when 50 are already open), and a download aborts after 30 seconds of store silence or 10 minutes of the client not reading (v0.27.0+). Set CHAT_MEDIA_ARCHIVE_OUTBOUND=true (default off, and it requires CHAT_MEDIA_ARCHIVE_ENABLED=true) to give outbound media the same durable file copy, S3 portability, and TTL retention that inbound media gets.

A 404 covers these cases: the message carries no media; media download was disabled or the payload was over the cap when it was stored, leaving a size-only marker; it was a URL-based API send with no stored own-send echo (always the case on Baileys); or the message is not in this gateway's history. Retention (CHAT_MEDIA_ARCHIVE_TTL_DAYS, default 0 = forever) clears the archived file (and removes archived: true from outbound-archived rows, v0.27.0+), after which an inline copy still answers if present. Revoked messages have neither copy and answer 404.

Store archived media once​

Since v0.25.0 MESSAGE_INLINE_MEDIA=archive replaces successfully archived inline payloads with { mimetype, filename?, omitted: true, sizeBytes, archived: true }. It requires CHAT_MEDIA_ARCHIVE_ENABLED=true, otherwise boot fails. The file is written and verified byte for byte before the row changes; storage or verification failure leaves the inline copy intact. Fetch the bytes through the media endpoint above. Webhook and WebSocket payloads are unaffected because they use the engine message.

Rows stored before the switch, media above CHAT_MEDIA_ARCHIVE_MAX_BYTES, rows without a WhatsApp message ID and outbound media without CHAT_MEDIA_ARCHIVE_OUTBOUND=true retain their inline bytes. Archive TTL now removes the only copy of archive-only media, after which downloads return 404. A database export omits those bytes, so back up the media store too. The default mode keeps both copies.

The sweep runs even with archiving off

Since v0.16.0 the retention purge and the orphan sweep run while CHAT_MEDIA_ARCHIVE_ENABLED is false, which previously stopped both. If you once had archiving on and later switched it off, the sweep now deletes any file under chat-media/ that no message row references, once it has been seen unreferenced for CHAT_MEDIA_ORPHAN_GRACE_MS (default 3600000 — 1 hour); the sweep itself runs every CHAT_MEDIA_ORPHAN_SWEEP_INTERVAL_MS (default 1 hour), and the first pass after a restart only records what it sees, so nothing is deleted before a full grace window has elapsed. Only the chat-media/ prefix is swept. The TTL purge stays a no-op while CHAT_MEDIA_ARCHIVE_TTL_DAYS is 0.

Common errors​

Errors use the standard envelope { statusCode, message, error }. On a 400 validation failure, message is an array of field-level strings. Any body field not listed for a route is rejected with 400 (strict validation).

StatusCauseFix
400 Bad RequestValidation failed, an unknown body field, neither url nor base64, base64 without mimetype, non-image/non-video media on send-sticker on whatsapp-web.js (v0.28.0+) or, since v0.31.0, a video that ffmpeg refuses there, an SSRF-blocked URL on a single send, a status post or a profile or group picture (a url whose host does not resolve, that points at or resolves to a blocked internal address, or that answers with a redirect; a status post and a profile or group picture answered 500 for these before v0.31.0; a send-bulk item fails on its own after the 202), a media url that carries a user name or password (v0.31.0+), a media url that is not an absolute http(s) URL (before v0.23.6 a scheme-less or ftp:// one passed) or, since v0.23.6, one that answers non-2xx, times out, or cannot be reached, a status post whose media is neither an absolute http(s) URL nor base64 text (v0.23.6+), a click-button (v0.23.6+) target that is not a clickable prompt or a buttonId it does not offer, out-of-range coordinates, a rendered template that is empty or over the TEMPLATE_RENDER_MAX_CHARS cap (default 64 KiB), a chatId, fromChatId or toChatId without a domain or sent as a JSON number (500 on Baileys before v0.26.0), a non-phone @ id or digitless value on contacts/check/{number} (v0.28.0+), since v0.26.0 also a JSON boolean or object in a string field (a JSON number is still read as its text), an array where the body expects an object (bulk options, customLinkPreview, a bulk item's content and media, a status media source) or an object where it expects a list, a body nested more than 100 levels deep, a cancel on a batch already in a terminal status, or the session has no live engine on a send route (a status post answers 404 instead) — an unknown or not-yet-started session id both return 400 (Session '...' is not active. Start the session first.), not 404.Check the message array and the field constraints above; confirm the session id is correct and ready.
401 UnauthorizedMissing, invalid, expired or revoked X-API-Key.Send a valid, active key. See Authentication.
403 ForbiddenSince v0.24.0 a valid key outside its allowed sessions or IPs; also a key whose role is below operator. Since v0.23.6 also a key restricted with allowedChats that names a chat outside its allowlist (each send-bulk item included), sends a quotedMessageId anywhere but reply, or calls a route such a key cannot use: the batch status and cancel routes, every status post, media conversion (GET and POST .../media/convert...), GET .../messages without an allowed chatId, GET .../contacts/check/{number}, and GET .../contacts/{number}/lid (v0.27.1+). Also GET .../messages/{chatId}/{messageId}/receipts on a message not sent by the session, or POST .../messages/edit on Baileys when the target message has no text or caption (both v0.28.0+).For a role refusal, use an operator-or-higher key. With a key restricted by allowedChats, add the chat to its allowlist, and quote only through reply, which sends text. For a quoted non-text send, and for the batch status and cancel, status post, conversion, number-check and LID-lookup routes, use a key without allowedChats; for stored messages pass an allowed chatId. See Authentication.
404 Not FoundA quotedMessageId (on a send route or on reply) that the engine cannot resolve — on both engines since v0.17.0, where whatsapp-web.js previously answered 500; or the batch id on GET batch/{batchId} or POST batch/{batchId}/cancel does not exist; or, since v0.23.6, a whatsapp-web.js reply whose chatId, or forward whose fromChatId, the session cannot resolve (a 500 before), or a click-button prompt the Baileys store no longer holds or that belongs to another chat. (A missing or not-started session id on a send route returns 400, not 404 — see the row above.)Quote an id the engine still holds, in the format that engine expects; verify the batchId from the send-bulk response.
409 ConflictAn idempotency key is still in progress or its outcome is unknown (see Retry a send), or the session has an engine but it is not ready: disconnected, reconnecting, or initializing, so the request never reached WhatsApp. One window answers this while the session still reads ready, when WhatsApp Web reloads its own page and the engine re-injects into it: on whatsapp-web.js that 409 carries code: "ENGINE_PAGE_RELOADING" and retryAfterSeconds (v0.31.0+) and the request is safe to repeat (a send was refused before it reached the page, and a message action converges when repeated); its message now ends Retry every few seconds: this can last a few minutes. where it ended Retry in a few seconds., so match on the code, not the text. Since v0.26.0, on whatsapp-web.js, a send, reply, forward, status post or message action that races a session stop or teardown answers the same 409, where it answered 500 or 503. A whatsapp-web.js send, reply, forward or status post that a page reload cut once the message was handed to the page (a reload that cuts the chat read in front of a reply or forward gets the coded 409 above, and nothing was sent), and a Baileys send, status post, status delete, reaction, edit, message delete for everyone or pin whose connection was replaced or stopped while it was being written, answer a 409 with no code whose message says the message may or may not have been sent, published, removed or applied (v0.31.0+; the Baileys case read as a plain not-connected 409 before).For a readiness refusal, wait for ready. For ENGINE_PAGE_RELOADING, ask again every retryAfterSeconds: a reload takes seconds on most pages and can take a few minutes, and no event marks its end. For a 409 that says the message may or may not have been sent, check the chat (or your status) before sending again; a retry with the same Idempotency-Key answers IDEMPOTENCY_OUTCOME_UNKNOWN. For IDEMPOTENCY_KEY_IN_PROGRESS, retry with the same key once the first request finishes. For IDEMPOTENCY_OUTCOME_UNKNOWN, check the chat first and send again only with a new key: the same key keeps answering 409 until its 24-hour window ends.
413 Payload Too LargeDecoded media, or since v0.23.6 media downloaded from url, exceeds the 50 MiB cap (413), or a customLinkPreview thumbnail exceeds its 5 MiB cap (413, v0.27.0+); or a base64 request body exceeds BODY_SIZE_LIMIT (25mb by default, which fits about 18.7 MiB of media).Compress the file or send a smaller asset. For base64 over the body limit, send by url or raise BODY_SIZE_LIMIT.
429 Too Many RequestsThree sources. The request rate limiter (RATE_LIMIT_*) shed the request: the body is { statusCode, message } with no error field, and since v0.23.6 a Retry-After header gives the seconds to wait. Send pacing (opt-in, SEND_PACING_ENABLED) refused the send: the body also carries code: "SEND_PACING_LIMITED" and retryAfterSeconds, and there is no Retry-After header. Pacing covers the send-* routes, reply, forward, click-button, edit, send-product and status posts; inside a send-bulk batch it lands in that item's result, not on the 202. send-bulk itself answers 429 with Too many bulk batches in progress (max N); retry shortly, no code and no header, while BULK_MAX_CONCURRENT_BATCHES (default 50) batches are running in this process.For the rate limiter, wait for Retry-After. For a pacing refusal, wait retryAfterSeconds, which can be hours when a daily cap is spent; see send pacing. For the batch cap, retry once a running batch finishes.
500 Internal Server ErrorThe send failed at the WhatsApp engine. The engine leg of a send is deliberately left unbounded, so an engine failure answers 500, not a retry-safe 503, except that a rate limit or timeout WhatsApp itself reports on Baileys has answered 503 since v0.26.0 (see the 503 row). A 500 here can also mean a dead whatsapp-web.js page left the outcome unknown, and the message may already be on the wire. Since v0.23.6 each such failure logs a Send failed in the engine (<type>) warning carrying the session, chat, message id, and the engine's error. On whatsapp-web.js, an error the WhatsApp Web page throws now names what it threw and the WhatsApp Web build that ran (it used to read t: t), and a failed bulk item's results[].error.message carries the same text. A whatsapp-web.js media send failing with Data passed to getter must include an id property is fixed in v0.23.6; see Troubleshooting.Confirm the session is connected, then read the chat back before resending. A blind retry is how one send becomes two.
501 Not ImplementedThe session's engine lacks the feature. On whatsapp-web.js: click-button (v0.23.6+), send-product, customLinkPreview, media sent to a channel (@newsletter), and, since v0.23.7, a send with quotedMessageId or a location or contact card to a channel or to a status or broadcast list (@broadcast), and a poll or sticker to a status or broadcast list; nothing is sent. On Baileys: vote-poll, the live chat history read (GET .../messages/{chatId}/history), the reactions read (GET .../messages/{chatId}/{messageId}/reactions), and the per-recipient receipts read (GET .../messages/{chatId}/{messageId}/receipts, v0.28.0+). On whatsapp-web.js a route can also answer 501 when the WhatsApp Web build the session runs has no job to send the change with, which depends on the build and not on the engine: since v0.31.0 pin and unpin (no pin sender the gateway can call; nothing was sent, the pin is unchanged).Use a Baileys session for click-button, send-product and customLinkPreview, and a whatsapp-web.js session for vote-poll, history, reactions, and per-recipient message receipts. On whatsapp-web.js, send a channel text without quotedMessageId. For pin and unpin, use a Baileys session.
503 Service UnavailableThe gateway's in-flight request-body budget (INFLIGHT_BODY_BUDGET_BYTES), or the caller's share of it, is spent, typically by concurrent large base64 uploads; this 503 carries Retry-After. Since v0.24.0 a request with an active API key is charged to that key (half the budget by default, however many addresses use the key); a request without one is charged to its client IP, resolved through TRUSTED_PROXIES, inside a smaller unkeyed pool, and since v0.23.6 an IPv6 client is counted on its /64. Also since v0.23.6: the session routes url fetches through an egress proxy, and the media download failed to connect or timed out before any response arrived. In both cases nothing was sent. Since v0.31.0, on whatsapp-web.js, send-sticker also answers 503 when the host's ffmpeg is missing or cannot run the video conversion; nothing was sent. On whatsapp-web.js, react also answers 503 when the page connection dies mid-request or, since v0.31.0, when WhatsApp Web does not answer within the request budget, and so do edit, delete, star, pin, unpin, vote-poll and a status delete; that change may or may not have been applied. Since v0.31.0 pin and unpin also answer 503 there when WhatsApp answers the read of the group in front of the send with a rate limit, a timeout or a server error (408, 423, 429 or 5xx), and nothing was sent. On Baileys, since v0.26.0, a send, reply, forward, click-button, send-product, reaction, edit, delete, pin, unpin or status post (a status delete included) also answers 503 when WhatsApp rate-limits it (code 429: nothing was sent, and a keyed send frees its Idempotency-Key) or times out a query it awaits (code 408: the outcome is not proven, and a keyed send keeps its key taken); both answered 500 before.Retry, honouring Retry-After when present; repeating a reaction is safe, since it converges on the same state. After a rate-limit 503 wait before retrying; after a timeout 503 read the chat back first. A budget 503 that keeps recurring calls for a higher INFLIGHT_BODY_BUDGET_BYTES (see Deployment); a proxy 503 that persists while the proxy works points at the url.

Since v0.25.0 Baileys checks a phone recipient without a known LID before sending: an unregistered number returns 400, and a lookup that gets no answer returns 503 with proof that nothing was sent. Every send to such a number performs this lookup. On whatsapp-web.js, vote-poll with no matching option text returns 400 POLL_OPTION_NOT_FOUND; an empty options list still clears the vote.

On Baileys, replying to, quoting, editing, reacting to, pinning, unpinning, starring, forwarding and answering a button prompt on an already revoked message each answer 404. A delete does not refuse a revoked message, and vote-poll answers 501 on Baileys. Deleting a Baileys status whose audience is unknown returns 403: only statuses posted by this running session in the last 24 hours have a known audience, so a restart loses that lookup.

Since v0.24.0 a whatsapp-web.js send or status post rejected inside the page returns 500 with code: "ENGINE_PAGE_ERROR", pageError: { name, message } and an optional WhatsApp Web build (including, since v0.27.0, a send whose recipient lookup in the page does not answer in time, while a lookup cut short by a page reload answers 409 instead of 400). Keep those diagnostics and check the chat before retrying; they do not establish that nothing was sent.

Next steps​