POST /messages sends a message. It needs connectionId, to (number in international format, for example +237600000000) and exactly one content field.
Content types#
| Field | Use |
|---|---|
text |
Free text, 4,096 characters at most. |
image, document, audio, video |
Media, by assetId (see below) or by url. Caption and file name are optional. |
product |
Meta product card (catalogId, productRetailerId, optional body). |
productList |
Product list (catalogId, body, sections[].productItems[]). |
template |
Approved template: { name, language, components? }. |
smart |
Free text if the 24-hour window is open, otherwise the fallback template: { text, template }. |
buttons |
Up to 3 quick-reply buttons. |
list |
A list of choices, up to 10 rows. |
cta |
A button that opens a web address. |
otp |
One-time code, see the guide. |
flow |
WhatsApp Flow (navigate, data_exchange or cta): see WhatsApp Flows. |
callPermissionRequest |
Asks the customer for permission to call them: see WhatsApp calls. |
reaction |
Reaction to a received message. |
{ "connectionId": "con_...", "to": "+237600000000", "text": "Your parcel leaves tomorrow." }{
"connectionId": "con_...",
"to": "+237600000000",
"template": {
"name": "order_shipped",
"language": "en",
"components": [
{ "type": "body", "parameters": [{ "type": "text", "text": "A-2041" }] }
]
}
}{
"connectionId": "con_...",
"to": "+237600000000",
"buttons": {
"body": "Would you like delivery tomorrow?",
"buttons": [{ "id": "yes", "title": "Yes" }, { "id": "no", "title": "No" }]
}
}{
"connectionId": "con_...",
"to": "+237600000000",
"smart": {
"text": "Hello Awa, here are your interview details.",
"template": { "name": "interview_reminder", "language": "en", "components": [] }
}
}The 24-hour window#
WhatsApp only accepts a free-form message (text, media, buttons, list) within 24 hours of the recipient's last message. Outside it, you need an approved template. A send outside the window fails with error 131047. To personalise and send in bulk while the window is open, use a free-form campaign.
The life of a message#
Click a status to follow the message's path, or the failure to see the error code.
The 200 response gives id, wamid and status = accepted. This means Meta took the message, not that it arrived. The status then moves to sent, delivered, read or failed. Follow it with a webhook or with GET /messages/{id}.
Send media#
Upload the file with POST /media (multipart, field file), then use the assetId you receive in the message. The same file uploaded twice is stored once. Media is kept 30 days in a private vault, then deleted.
curl -X POST https://hira.localtechstudio.com/api/v1/media \
-H "Authorization: Bearer pk_live_..." \
-F "[email protected]"
Failures#
A failed message exposes Meta's error code. The detail of each code and the right reaction are in Error codes.