Sending WhatsApp messages
Send a pre-approved template or a free-form service message to one WhatsApp recipient. The API accepts your request immediately and delivers the message asynchronously.
Each call to POST /v1/whatsapp/messages targets one recipient. To reach an entire audience with one template, use Broadcasts.
Minimal request
The smallest request sets to and a template slug. Omit language to use the template's default language, and pass variable values in parameters.
For cURL requests, replace {region} with us1 for US keys or eu1 if your key starts with bk_eu1_. The SDKs infer the region from your key automatically.
const msg = await bird.whatsapp.send({
to: "+15551234567",
template: {
slug: "bird_otp",
parameters: { code: "123456" },
},
});
console.log(msg.id, msg.status);msg = client.whatsapp.send(
to="+15551234567",
template="bird_otp",
language="en",
parameters={"code": "123456"},
)
print(msg.id, msg.status)msg, err := client.Whatsapp.Send(context.Background(), bird.WhatsappSendParams{
To: "+15551234567",
Template: "bird_otp",
Language: "en",
Parameters: map[string]any{"code": "123456"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(msg.Id, *msg.Status)$message = $bird->whatsapp->send(
to: '+15551234567',
template: 'bird_otp',
language: 'en',
parameters: ['code' => '123456'],
);
echo $message->getId(), ' ', $message->getStatus();bird whatsapp send \
--language en \
--parameters '{"code":"123456"}' \
--template bird_otp \
--to +15551234567curl -X POST "https://{region}.platform.bird.com/v1/whatsapp/messages" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"template": {
"slug": "bird_otp",
"language": "en",
"parameters": {
"code": "123456"
}
}
}'The customer service window
Whether you can send a free-form service message or must use a pre-approved template depends on the customer service window.
A contact opens this 24-hour window by messaging or calling your business number, and each reply resets the timer. While the window is open, you can send free-form service messages. Once the window closes, send a pre-approved template. The contact's reply reopens the window.
Bird checks the window before charging and rejects closed-window service messages with 422 (E15044). Because this check is best-effort and fails open, a window that closes between acceptance and dispatch fails asynchronously with service_window_expired. See the customer service window for the full lifecycle.
Building up the payload
Every request targets one recipient (to) and includes one content field: either template or a service message type. For the complete request schema, see the Create WhatsApp message API reference.
Recipient
to accepts one of three destination formats:
- Phone number: an E.164 number with a leading
+and country code, such as+14155550100. Invalid numbers are rejected before charging. - Business-scoped user ID: an identifier such as
US.13491208655302741918for contacts who messaged you without sharing a phone number. Authentication templates and maximum-price templates require a phone number. - WhatsApp group ID: a group ID such as
wag_01krdgeqcxet5s7t44vh8rt9mg, which delivers to the group chat. Group sends omitfrom.
Category and sender
A template's category (authentication, utility, or marketing) shapes how WhatsApp handles the message and, with the destination country, its price. Whether you include from depends on who owns the sender:
- Bird-managed templates (slugs starting with
bird_) and group sends: omitfrom. Bird chooses the sender automatically. - Authored templates and service messages: set
fromto a connected number your workspace owns. Authored templates must belong to the same WhatsApp Business Account asfrom.
See Phone number setup for connecting your own number.
Template parameters
Set template.slug to a template from your Templates catalog, optionally add language (such as en or pt-BR), and supply variable values in parameters.
| What you are filling | Key in parameters |
|---|---|
Named variable ({{order_id}}) | The variable name (order_id) |
Numbered variable ({{1}}) | The variable number (1) |
| Authentication code or copy-code button | code |
| Numbered URL button suffix | button_url (or button_url_1, button_url_2 for carousel cards). Named suffixes use their variable name |
| Media header | header_url or an uploaded header_file_id (add _1, _2 for carousel cards) |
| Document header filename | header_filename |
| Location header | header_location ({ latitude, longitude }) |
Values can be strings, numbers, or booleans, and unused keys are ignored. To send a template's approved sample media, omit the media header key and still pass parameters (use "parameters": {} when the template has no other variables). Templates imported from Meta have no stored sample and require a URL or file ID.
const msg = await bird.whatsapp.send({
to: "+15551234567",
from: "+13124495648",
template: {
slug: "order_update",
language: "en",
parameters: { order_id: "A-4192", first_name: "Ava" },
},
});
console.log(msg.id, msg.status);msg = client.whatsapp.send(
to="+15551234567",
from_="+13124495648",
template="order_update",
language="en",
parameters={"order_id": "A-4192", "first_name": "Ava"},
)
print(msg.id, msg.status)msg, err := client.Whatsapp.Send(context.Background(), bird.WhatsappSendParams{
To: "+15551234567",
From: "+13124495648",
Template: "order_update",
Language: "en",
Parameters: map[string]any{
"order_id": "A-4192",
"first_name": "Ava",
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(msg.Id, *msg.Status)$message = $bird->whatsapp->send(
to: '+15551234567',
from: '+13124495648',
template: 'order_update',
language: 'en',
parameters: ['order_id' => 'A-4192', 'first_name' => 'Ava'],
);
echo $message->getId(), ' ', $message->getStatus();bird whatsapp send \
--to +15551234567 \
--from +13124495648 \
--template order_update \
--language en \
--parameters '{"order_id":"A-4192","first_name":"Ava"}'curl -X POST "https://{region}.platform.bird.com/v1/whatsapp/messages" \
-H "Authorization: Bearer $BIRD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"from": "+13124495648",
"template": {
"slug": "order_update",
"language": "en",
"parameters": { "order_id": "A-4192", "first_name": "Ava" }
}
}'Templates whose bindings read recipient contact fields (such as bird.contact.first_name) cannot be sent as single messages. Send them through Broadcasts instead.
For legacy templates with duplicate numbered placeholders across blocks (such as {{1}} in both the header and body) or a text variable that collides with a reserved key like header_file_id or button_url, pass header_url where applicable or use template.components. See Create WhatsApp message for that schema.
Service messages
Inside an open customer service window, send one free-form content type instead of template. Service messages require a workspace-owned from number.
| Content type | Field | Guide |
|---|---|---|
| Plain text (optional link preview) | text | Plain text |
| Media (URL or uploaded file ID) | image, video, audio, sticker, document | Service messages |
| Map pin | location | Location |
| Structured vCard contacts (up to five) | contact_cards | Contact cards |
| Buttons, menus, links, carousels, requests | interactive | Interactive messages |
{
"to": "+16505551234",
"from": "+13124495648",
"text": { "body": "Your order shipped: https://example.com/track/A1B2C3", "preview_url": true }
}Uploaded files
To send a private document or reuse media across recipients without hosting a public URL, upload the file once with POST /v1/whatsapp/files. Each upload returns a file ID that you can pass in header_file_id on an authored template or in file_id on a media service message.
import { readFile } from "node:fs/promises";
const file = await bird.whatsapp.files.create({
from: "+13125550101",
file: new Blob([await readFile("invoice-4821.pdf")]),
name: "invoice-4821.pdf",
});
const msg = await bird.whatsapp.send({
to: "+14155550100",
from: "+13125550101",
template: {
slug: "order_invoice",
language: "en",
parameters: {
header_file_id: file.id,
invoice_number: "4821",
},
},
});
console.log(msg.id, msg.status);with open("invoice-4821.pdf", "rb") as f:
file = client.whatsapp.files.create(
from_="+13125550101",
file=f,
filename="invoice-4821.pdf",
)
msg = client.whatsapp.send(
to="+14155550100",
from_="+13125550101",
template="order_invoice",
language="en",
parameters={
"header_file_id": file.id,
"invoice_number": "4821",
},
)
print(msg.id, msg.status)invoice, err := os.Open("invoice-4821.pdf")
if err != nil {
log.Fatal(err)
}
defer func() { _ = invoice.Close() }()
file, err := client.Whatsapp.Files.Create(context.Background(), bird.WhatsappFilesCreateParams{
From: "+13125550101",
File: invoice,
Filename: "invoice-4821.pdf",
})
if err != nil {
log.Fatal(err)
}
msg, err := client.Whatsapp.Send(context.Background(), bird.WhatsappSendParams{
To: "+14155550100",
From: "+13125550101",
Template: "order_invoice",
Language: "en",
Parameters: map[string]any{
"header_file_id": file.Id,
"invoice_number": "4821",
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(msg.Id, *msg.Status)$contents = file_get_contents('invoice-4821.pdf');
if ($contents === false) {
exit("Cannot read invoice-4821.pdf\n");
}
$file = $bird->whatsapp->files->create(
from: '+13125550101',
contents: $contents,
filename: 'invoice-4821.pdf',
);
$message = $bird->whatsapp->send(
to: '+14155550100',
from: '+13125550101',
template: 'order_invoice',
language: 'en',
parameters: [
'header_file_id' => $file->getId(),
'invoice_number' => '4821',
],
);
echo $message->getId(), ' ', $message->getStatus();FILE_ID=$(bird whatsapp files upload \
--from +13125550101 \
--file ./invoice-4821.pdf \
| jq -er '.id') && \
bird whatsapp send \
--to +14155550100 \
--from +13125550101 \
--template order_invoice \
--language en \
--parameters "{\"header_file_id\":\"$FILE_ID\",\"invoice_number\":\"4821\"}"FILE_ID=$(curl -fsS -X POST "https://us1.platform.bird.com/v1/whatsapp/files" \
-H "Authorization: Bearer $BIRD_API_KEY" \
-H "Idempotency-Key: invoice-4821-template" \
-F from=+13125550101 \
-F file=@invoice-4821.pdf \
| jq -er '.id') && \
curl --fail-with-body -sS -X POST "https://us1.platform.bird.com/v1/whatsapp/messages" \
-H "Authorization: Bearer $BIRD_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"to\": \"+14155550100\",
\"from\": \"+13125550101\",
\"template\": {
\"slug\": \"order_invoice\",
\"language\": \"en\",
\"parameters\": {
\"header_file_id\": \"$FILE_ID\",
\"invoice_number\": \"4821\"
}
}
}"For a media service message, pass file_id from the upload above in place of url using the same sender:
{
"from": "+13125550101",
"to": "+14155550100",
"document": { "file_id": "waf_01kyb2m4xq7whs0d8n3prv6tez", "caption": "Your invoice" }
}Key rules for uploaded files:
- Scoped to one sender: send from the same
fromnumber used on upload. For a group message, upload with the group's number and omitfromwhen sending. - 30-day retention: files expire after 30 days, and sends are rejected during the final 24 hours so media doesn't expire mid-dispatch. Upload again with a fresh
Idempotency-Keyto replace an expired file. - Safe retries: pass an
Idempotency-Keyheader on uploads so retries reuse the original upload. - Unsupported surfaces: Bird-managed templates (
bird_) do not support media headers (author your own media template instead), and Broadcasts require a publicheader_urlrather than a file ID.
For carousel templates, supply one file ID per card with header_file_id_1, header_file_id_2, and so on. Document messages and document headers default to the uploaded filename (shortened to 100 characters while keeping the extension). For upload limits, multipart field order, and reading or downloading stored files, see Create WhatsApp file, Get WhatsApp file, and Download WhatsApp file content.
Quoting a message
Set in_reply_to_message_id to a WhatsApp message ID from the same conversation that reached WhatsApp within the last 15 days to display your message as a quoted reply. Quoting works on both templates and service messages, and unresolvable or not-yet-handed-off quotes fail before charging.
{
"to": "+16505551234",
"from": "+13124495648",
"in_reply_to_message_id": "wam_01kya19eknftrs2s6p82asmvnh",
"text": { "body": "Yes, that slot is still free." }
}Inbound replies populate in_reply_to_message_id on a best-effort basis, and outgoing metadata doesn't copy onto inbound replies. See Receiving WhatsApp messages for correlating customer replies reliably.
Tags and metadata
Attach custom context with tags, metadata, and reference. Bird returns these fields on API reads and includes them on every webhook event:
tags: up to 20{ "name", "value" }labels for low-cardinality reporting dimensions (such as a campaign). Filter messages by tag or break down delivery on the Metrics page.metadata: an arbitrary JSON object (up to 2 KB) for per-send context you don't need to filter on.reference: a string (up to 255 characters) for exact-match lookup via?reference=on the message list.
{
"tags": [{ "name": "campaign", "value": "order-confirmations" }],
"metadata": { "order_id": "ord_8271" },
"reference": "ord_8271"
}Asynchronous delivery and 202 responses
A valid request returns 202 Accepted with a message ID and status: accepted after Bird durably queues the send.
- Immediate rejections: validation errors (invalid recipient, unknown template, parameter mismatch, or closed service window) fail immediately with
422, and insufficient wallet balance fails with402. - Async lifecycle: an accepted message moves to
sentand thendeliveredorfailed, or terminates directly fromacceptedasrejected(for example, insufficient balance or suppression) orfailed(if WhatsApp rejects submission). Read receipts setread_atand emit awhatsapp.readevent without changingstatus. Track updates through events, webhooks, or GET /v1/whatsapp/messages/{id}. - Passcode redaction: for authentication templates, the API redacts filled passcode values from the
202response and later reads.
Retrying safely
Send a unique Idempotency-Key header per logical message so retries after timeouts or dropped connections return the original response instead of sending and charging twice. Replayed responses include an Idempotency-Replay header. See Idempotency for key format and retention.
Receiving the reply
Inbound messages share the same API resource as outbound messages and reset the customer service window. See Receiving WhatsApp messages to read replies, download inbound media, and handle the whatsapp.received webhook.
Cost and billing
WhatsApp messages are priced by category and recipient country (see WhatsApp pricing). Each message is charged in two steps, reflected in the message's cost object:
| Field | What it is | When it lands |
|---|---|---|
transaction_amount | Bird's outbound handling fee | When Bird processes the accepted send, before dispatch |
passthrough_amount | Meta's share of the message price | When a billable delivered or read receipt arrives |
amount | Sum of the components recorded so far | Updates as each component lands |
currency_code | Your organization wallet's currency | With the first component |
Both amounts are decimal strings, net of tax.
Note: Until September 30th 2026, Meta does not charge a fee for service messages or for utility templates delivered inside an open customer service window. From October 1st 2026, Meta charges for both outside a free entry point window, with 1,000 free service messages per business phone number per month. See October 2026 pricing changes.
- How charges behave on failure: Bird's fee fails closed. If your wallet cannot cover it after acceptance, the message ends
rejectedwith no charge and never reaches WhatsApp. Meta's fee is billed from the delivery or read receipt (using the category Meta reports, such as authentication-international) even if your wallet balance drops below zero. - Reading message cost:
coststartsnullon the202response and updates as each charge lands. Webhook events do not include cost. Read it withGET /v1/whatsapp/messages/{id}. - Financial reconciliation: treat message
costfields as projections that can lag or omit a component. Reconcile posted wallet debits in Billing and payments > Spend (see WhatsApp metrics).
Next steps
- Create WhatsApp message API reference: full request and response schemas
- Service messages: send text, media, and interactive content inside the customer service window
- Templates: browse templates and supply variables
- Receiving WhatsApp messages: read replies and fetch inbound media
- Message status webhooks: receive delivery and failure updates
- Idempotency: retry safely with
Idempotency-Key
Related resources
Continue with the documentation, guides and examples for this topic.