For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

1

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

2

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

3

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/.

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?