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
| Header | Value |
|---|---|
X-API-KEY | Your API key, with the messages:send scope |
Content-Type | application/json |
Request body
Field names use snake_case.
| Field | Type | Required | Description |
|---|---|---|---|
type | string | No | template (the default) or text |
phone_number | string | Yes | The recipient: digits only, starting with the country code, such as 919876543210 |
channel_id | number | Yes | The WhatsApp channel to send from. The Send via API tab shows it |
contact_name | string | No | A name for the contact, used if Baat creates the contact on this send |
template_id | string | For templates | The template’s Meta ID: template_id in the templates list |
message | object | Yes | The template and its values, or the text to send (see below) |
source | string | No | A label stored with the message, such as the name of your system |
The message object for a template
| Field | Type | Description |
|---|---|---|
template_name | string | The template’s name, such as order_update. Required |
language_code | string | The template’s language, such as en. Required |
body_params | string[] | Values for the body placeholders, in order: {{1}}, {{2}} and so on |
header_params | string[] | Values for header placeholders, if the template has them |
button_params | string[] | Values for dynamic button parameters, such as the end of a URL |
body_params_by_name | object | For templates with named variables: {"name": "Jane Smith"} |
header_params_by_name | object | Named header values |
button_params_by_name | object | Named button values |
button_params_by_index | object | Button 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
| HTTP | status | Cause |
|---|---|---|
401 | unauthorized | The API key is unknown, inactive or expired |
403 | insufficient_scope | The 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 |