DevelopersSend a text message Browse docs

Send a text message

Send your own text to a customer inside WhatsApp's 24-hour customer service window.

Sends free-form text to a customer. WhatsApp only allows this within 24 hours of the customer’s last message — outside that window, send a template instead.

POST/api/external/send-message

Request body

FieldTypeRequiredDescription
tostringYesThe recipient’s number with country code, for example +971501234567.
bodystringYesThe message text, up to 4,096 characters.

Examples

curl -X POST "https://YOUR_WORKSPACE_DOMAIN/api/external/send-message" \
  -H "Authorization: Bearer $WAZLINE_TOKEN" \
  -H "Origin: https://yourstore.com" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{ "to": "+971501234567", "body": "Hi Sara, your order #4821 is out for delivery." }'
// Node.js 18 or later
const res = await fetch('https://YOUR_WORKSPACE_DOMAIN/api/external/send-message', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.WAZLINE_TOKEN}`,
    Origin: 'https://yourstore.com',
    'Content-Type': 'application/json',
    Accept: 'application/json',
  },
  body: JSON.stringify({
    to: '+971501234567',
    body: 'Hi Sara, your order #4821 is out for delivery.',
  }),
});
const data = await res.json();

Response

{
  "success": true,
  "message_id": 18343,
  "wa_message_id": "wamid.HBgMOTcxNTAxMjM0NTY3FQIAERgS..."
}

Errors

Statuserror_codeWhat to do
422window_closedThe customer hasn’t messaged in the last 24 hours. Send an approved template instead.
422number_not_foundNo WhatsApp number is linked to this token. Check the API client in Wazline.
422invalid_numberInclude the country code.
422invalid_payloadto or body is missing, empty or longer than 4,096 characters.
502send_failedWhatsApp rejected the message. Try again shortly.

Which endpoint should I use?

send-templatesend-message
Outside the 24-hour windowYesNo
ContentAn approved template, with variablesAny text up to 4,096 characters
Typical useNotifications, confirmations, remindersReplies while a conversation is active

Tip: A common pattern is to call send-message first and, if it returns window_closed, fall back to send-template.

Still have questions?

Our team is happy to walk you through Wazline and help you set up your workspace.

Contact us