Sending messages
Reply to a customer, or reach them with a template when the window is closed.
Every message goes through one endpoint: POST /api/v1/messages/. What you can send depends on one thing — whether the conversation window is open.
Check the window
Read the chat and look at contact.messaging_window_expires_at:
curl -H "Authorization: Token $SERVICE_TOKEN" $INBOX/api/v1/chats/$WA_ID/If that time is still in the future, the window is open and you can send anything. If it has passed, you can only send a template. Do not assume a fixed duration — it depends on how the conversation started. See The customer service window.
Reference: Retrieve chat
Window open: send a message
curl -X POST $INBOX/api/v1/messages/ \
-H "Authorization: Token $SERVICE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"wa_id": "'"$WA_ID"'", "type": "text", "text": {"body": "Thanks, your order is on its way."}}'wa_id is the value you got from the chat — a phone number or a BSUID. Pass it as is.
Reference: Create message
Window closed: send a template
Use one of your approved templates, in the same format as the WhatsApp API. Replace order_update with the name of one of yours:
curl -X POST $INBOX/api/v1/messages/ \
-H "Authorization: Token $SERVICE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"wa_id": "'"$WA_ID"'",
"type": "template",
"template": {
"name": "order_update",
"language": { "code": "en" }
}
}'To see which templates you have, call GET /api/v1/templates/.
The API does not check the template before accepting the message. If the name or language does not match an approved template, you still get 202, and the error arrives later in the message's waba_payload.errors — for example code 132001, template does not exist.
What the response means
202 Accepted means the message is queued, not yet delivered. The most common failure is 453: the window has closed, so send a template instead. All response codes are listed in the Create message reference.
Last updated
Was this helpful?