API reference

Send a message

POST /api/v1/send — send a text message, a verification code or an approved template to a WhatsApp number.

POST/api/v1/send

Sends a message from one of your numbers. WABEK picks the sending method automatically based on the number type and the 24-hour window.

Requires a plan with API access (otherwise 403 plan_no_api) and, for keys with restricted permissions, the send permission (otherwise 403 permission_denied).

Headers

Header Value
X-API-Key Your key (or Authorization: Bearer <key>)
Content-Type application/json

Request body

Field Type Required Description
to string Yes Recipient number in international format, digits only with country code (for example 966500000000). phone is accepted as an alias.
message string Yes Message text.
instance_id string No ID of the sending number. If omitted, the oldest connected number on your account is used.
template string No Name of an approved template used if the recipient is outside the 24-hour window (Cloud API).
template_params object or array No Template body parameters, used with template: an object for named parameters ({"customer_name": "Sara"}) or an array for positional ones (["Sara", "1042"] → {{1}}, {{2}}).
template_language string No The template's approved language code exactly as shown in WhatsApp Manager (for example ar, en, en_US).
customer_name string No Customer name for the default template outside the window. Defaults to Customer.
code string or number No A 4–8 digit verification code. When present, the message is sent through an Authentication template.
type string No otp means message contains a verification code to extract.

How the sending method is chosen

Number type Case What happens
WhatsApp Web Always message is sent as text
Cloud API With code or type: "otp" The code is sent through an Authentication template; if that fails and the customer is inside the window, the text is sent
Cloud API Inside the 24-hour window message is sent as text
Cloud API Outside the window and message contains a 4–8 digit number Treated as a verification code and sent through an Authentication template
Cloud API Outside the window with template The given template is sent with template_params
Cloud API Outside the window without template The platform's default marketing template is sent, with the customer name in customer_name and the message text in offer_details

Templates are tried in template_language first (when given), then ar, en and en_US; a language in which the template does not exist (Meta error 132001) is skipped. See 24-hour window and templates.

Response

200 OK

JSON
{
  "success": true,
  "message_id": "wamid.HBgMOTY2NTAwMDAwMDAwFQIAERgSQzE2..."
}
Field Type Description
success boolean true when the message was accepted for sending
message_id string or null WhatsApp's message ID (may be null for some WhatsApp Web messages)

The message is saved in the inbox as an outbound message.

Errors

Status Example Cause
400 {"error": "to and message required"} Missing field
401 {"error": "Invalid API key"} Invalid key
403 {"error": "Recipient has opted out", "code": "opted_out"} Plan limit, opt-out or block; also plan_no_api / permission_denied
404 {"error": "No connected WhatsApp instance"} No number on the account
422 See below Outside the window and every template attempt failed
429 {"error": "Too many requests", "code": "rate_limited", "retryAfter": 60} + Retry-After header Request limit exceeded
502 {"error": "Failed to send message", "detail": "..."} The WhatsApp provider rejected the message

422 example:

JSON
{
  "error": "Recipient is outside the 24-hour messaging window",
  "detail": "Plain text cannot be delivered outside the 24h window. Tried sending via the \"order_update\" template ...",
  "attempts": [
    {
      "language": "en",
      "components": "named params (explicit)",
      "ok": false,
      "status": 404,
      "error": "(#132001) Template name does not exist in the translation"
    }
  ]
}

Examples

Text message

curl -X POST https://waabek.com/api/v1/send \
  -H "X-API-Key: $WABEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "966500000000",
    "message": "Your order #1042 has shipped."
  }'

With a fallback template outside the window

If the customer is inside the window, message is sent as text; otherwise the order_update template is sent. The template must be approved on the WhatsApp Business Account linked to the number, the template_params keys must match the variable names in its body, and template_language should be the template's approved language (if omitted, ar, en and en_US are tried).

cURL
curl -X POST https://waabek.com/api/v1/send \
  -H "X-API-Key: $WABEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "966500000000",
    "message": "Hi Sara, your order #1042 has shipped.",
    "instance_id": "3f1c2a7e-0000-4000-8000-000000000000",
    "template": "order_update",
    "template_language": "ar",
    "template_params": { "customer_name": "Sara", "order_id": "1042" }
  }'

Verification code

cURL
curl -X POST https://waabek.com/api/v1/send \
  -H "X-API-Key: $WABEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "966500000000",
    "message": "Your verification code is 482913",
    "code": "482913"
  }'