Developers

Sending WhatsApp messages with the API

Updated 13 November 2026

Send WhatsApp messages from your own backend with one POST request. Messages you send through the API appear in the conversation in your Inbox, like any other message.

The API is part of the Business plan, and you can try it during the free trial.

The fastest way: Send via API

You do not have to build the request by hand. Go to Settings → Templates, open a template and choose its Send via API tab. Baat shows a ready-to-run request for that template, with the channel ID, template ID, name, language and parameters filled in. Copy it as cURL, Node.js or Python, add your API key, and send.

The tab also lists the Parameters this template expects, so you know how many values to supply. The rest of this article describes the endpoint in full.

Endpoint

POST https://api.baat.ai/m1/whatsapp/messages
HeaderValue
X-API-KEYYour API key, with the messages:send scope
Content-Typeapplication/json

Request body

Field names use snake_case.

FieldTypeRequiredDescription
typestringNotemplate (the default) or text
phone_numberstringYesThe recipient: digits only, starting with the country code, such as 919876543210
channel_idnumberYesThe WhatsApp channel to send from. The Send via API tab shows it
contact_namestringNoA name for the contact, used if Baat creates the contact on this send
template_idstringFor templatesThe template’s Meta ID: template_id in the templates list
messageobjectYesThe template and its values, or the text to send (see below)
sourcestringNoA label stored with the message, such as the name of your system

The message object for a template

FieldTypeDescription
template_namestringThe template’s name, such as order_update. Required
language_codestringThe template’s language, such as en. Required
body_paramsstring[]Values for the body placeholders, in order: {{1}}, {{2}} and so on
header_paramsstring[]Values for header placeholders, if the template has them
button_paramsstring[]Values for dynamic button parameters, such as the end of a URL
body_params_by_nameobjectFor templates with named variables: {"name": "Jane Smith"}
header_params_by_nameobjectNamed header values
button_params_by_nameobjectNamed button values
button_params_by_indexobjectButton values by button position: {"0": "ABC123"}

Example: a template message

curl -X POST "https://api.baat.ai/m1/whatsapp/messages" \
  -H "X-API-KEY: $BAAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number": "919876543210",
    "contact_name": "Customer",
    "channel_id": 174,
    "template_id": "2067036557116441",
    "message": {
      "template_name": "lead_acknowledgement",
      "language_code": "en",
      "body_params": ["Jane Smith", "Coffee Maker"]
    }
  }'

Keep your key in an environment variable such as $BAAT_API_KEY, not in your code.

Example: a text message

You can send plain text only inside the 24-hour customer service window, which opens when the customer messages you. Outside it, the API answers 400 and you must send a template.

curl -X POST "https://api.baat.ai/m1/whatsapp/messages" \
  -H "X-API-KEY: $BAAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "text",
    "phone_number": "919876543210",
    "channel_id": 174,
    "message": { "body": "Your order has been packed and leaves today." }
  }'

Response

A successful call returns 202 Accepted. Baat has queued the message:

{
  "success": true,
  "message_id": "a1b2c3d4e5",
  "status": "queued"
}

202 does not mean the message was delivered. A wrong template name or language can still fail after this point. Check the conversation in your Inbox, or use a webhook.

Retries

Baat does not remove duplicate requests. If a call times out, check the conversation in your Inbox before you send it again, or the customer may receive the message twice. The Send via API tab includes a request_id field; Baat does not use it to prevent duplicates today.

Errors

HTTPstatusCause
401unauthorizedThe API key is unknown, inactive or expired
403insufficient_scopeThe key does not have the messages:send scope
400(message)The request is invalid: for example, phone_number is missing, the channel is not in your organization, or a text message is outside the 24-hour window
500(message)Something failed on Baat’s side. The message may already be queued, so check before you retry

Related reading

Where this fits in the wider picture.

Need a hand?

Our team answers on WhatsApp, usually within a business day.

Contact support Book a demo