Baatzo API v1 reference

Baatzo API v1

Send one approved WhatsApp template to one number, read how it went, and get a signed webhook each time its status changes. On Pro, the full API also manages contacts and their consent, reads templates, runs campaigns, sends Marketing templates and posts webhooks for events such as a customer's message or an opt-out. API messages appear in the contact's chat in Baatzo, marked API, and cost what any message costs: Meta's charge, which Meta bills you directly, plus Baatzo's fee from your message credit.

View as Markdown Open in ChatGPT Open in Claude

Base URL
https://api.baatzo.com
Plans
API v1 on Starter, Growth and Pro; the full API on Pro; the sandbox on every plan
Format
JSON over HTTPS

API v1 (sending Utility and Authentication templates, reading them, the status webhook, exports and the consent certificate) works on Starter, Growth and Pro. Contacts, templates, campaigns, Marketing sends and event webhooks are the full API, part of Pro. On another plan they answer 403 plan_required.

Keys and scopes

An Owner or Admin with two-step verification on makes keys in the Baatzo web app, under Settings, Developers. A key is shown once: keep it on your server, never in an app or a web page. Baatzo stores only a hash of it, so a lost key is revoked and replaced. A revoked key stops working on the next request. To replace a key without downtime, press Roll beside it: you get a new key with the same name, scopes and countries, and the old one keeps working for 24 hours. A key can be rolled once.

Send it in the Authorization header:

Authorization: Bearer bz_live_K7Q2M9XA_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ScopePlansAllows
messages:sendStarter, Growth, ProPOST /v1/messages with a Utility or Authentication template
messages:readStarter, Growth, ProGET /v1/messages/{id}; on the MCP server, the templates and the credit balance
contacts:readStarter, Growth, ProGET /v1/contacts/{id}/consent-certificate; on the MCP server, listing contacts. On Pro also GET /v1/contacts, GET /v1/contacts/{id}, GET /v1/tags and GET /v1/lists
contacts:writeStarter, Growth, ProOn the MCP server, adding and updating contacts. On Pro also adding, changing, tagging, listing, opting out and erasing contacts, and recording consent
data:exportStarter, Growth, ProPOST /v1/exports, GET /v1/exports and the download
templates:readProGET /v1/templates, GET /v1/templates/{id} and its status
campaigns:readProGET /v1/campaigns, GET /v1/campaigns/{id} and its results
campaigns:writeProCreating, estimating, scheduling, sending and cancelling campaigns
messages:send_marketingProPOST /v1/messages with a Marketing template, to contacts with a recorded marketing consent. The key needs messages:send too
webhooks:manageProChoosing the webhook's event types, reading the delivery log and replaying deliveries

A key cannot be made with a Pro scope on another plan. After a downgrade, the key stays but its Pro operations answer 403 plan_required until the plan returns. A key without the scope an operation needs gets 403 forbidden with details.reason missing_scope.

A new key sends only to Indian numbers. The workspace Owner can add countries to a key in Settings, Developers. This stops bots that request codes to numbers abroad from running up your Meta bill.

Sandbox keys start bz_test_ and work everywhere, on every plan (see Sandbox).

Limits and retries

Sandbox

Build and test before your WhatsApp number is connected or Meta has approved anything. In Settings, Developers, create a sandbox key: it is free on every plan, up to 5 per workspace, and starts bz_test_. It holds messages:send and messages:read only; contacts, consent certificates, exports and the whole full API need a live key.

Authorization: Bearer bz_test_K7Q2M9XA_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Send toWhat happens
+919000000001message.failed after about 2 seconds with Meta's error 131026 (message undeliverable) and its plain explanation.
+919000000002Sent and delivered, never read.
Any other numberSent, delivered and read.

Import into Postman

The whole of API v1 is one OpenAPI 3.1 document. In Postman, click Use resources or import in the sidebar, then the Import tab, and enter this address:

https://api.baatzo.com/docs/openapi.json

Set the collection's bearer token to a sandbox key and give each send a new Idempotency-Key.

Send a message

POST/v1/messages

Sends one approved template to one number. Needs messages:send. A Marketing template also needs messages:send_marketing, on Pro (see Marketing sends).

FieldTypeNotes
tostringRequired. The number in E.164, such as +919829012345.
template.namestringRequired. An approved template of your workspace: Utility or Authentication, or Marketing with messages:send_marketing.
template.languagestringRequired. The template's language code exactly as in Baatzo, such as en or en_IN.
fromstringMeta's phone number ID of the sending number. Needed only when the workspace has more than one number for the template.
variables.bodyobjectEach variable by name (or number, for a numbered template). For Authentication: { "code": "482913" }, 1 to 15 letters and digits. Up to 1,024 characters each, with no line breaks or tabs.
variables.header.documentobject{ "link", "filename" } for a template with a document header, such as a PDF report. The link must be https, at most 2,048 characters, with no user name or password. WhatsApp fetches the file; Baatzo does not.
variables.header.image, variables.header.videoobject{ "link" } for a Utility or Marketing template with an image or video header. The same rules for the link as for a document.
variables.buttonsarray{ "index", "url" } for a URL button with a variable, { "index", "copy_code" } for a copy-code button. Without index, the position in the array.
referencestringYour own id, up to 64 characters, returned in reads and webhooks.

A login code

curl https://api.baatzo.com/v1/messages \
  -H "Authorization: Bearer $BAATZO_API_KEY" \
  -H "Idempotency-Key: login-88213-1" \
  -H "Content-Type: application/json" \
  -d '{ "to": "+919829012345",
        "template": { "name": "login_code", "language": "en" },
        "variables": { "body": { "code": "482913" } },
        "reference": "login-88213" }'
// Node.js 18 or later: fetch is built in.
const res = await fetch('https://api.baatzo.com/v1/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BAATZO_API_KEY}`,
    'Idempotency-Key': 'login-88213-1',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: '+919829012345',
    template: { name: 'login_code', language: 'en' },
    variables: { body: { code: '482913' } },
    reference: 'login-88213',
  }),
});
const answer = await res.json();
if (!res.ok) throw new Error(`${answer.code}: ${answer.message}`);
# Python 3.9 or later, with: pip install requests
import os
import requests

res = requests.post(
    "https://api.baatzo.com/v1/messages",
    headers={
        "Authorization": f"Bearer {os.environ['BAATZO_API_KEY']}",
        "Idempotency-Key": "login-88213-1",
    },
    json={
        "to": "+919829012345",
        "template": {"name": "login_code", "language": "en"},
        "variables": {"body": {"code": "482913"}},
        "reference": "login-88213",
    },
    timeout=30,
)
answer = res.json()
if not res.ok:
    raise RuntimeError(f"{answer['code']}: {answer['message']}")
<?php
// PHP 8.0 or later, with the curl extension.
$ch = curl_init('https://api.baatzo.com/v1/messages');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('BAATZO_API_KEY'),
        'Idempotency-Key: login-88213-1',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'to' => '+919829012345',
        'template' => ['name' => 'login_code', 'language' => 'en'],
        // PHP writes an empty array as [], which the API refuses: leave out a part with no variables.
        'variables' => ['body' => ['code' => '482913']],
        'reference' => 'login-88213',
    ]),
]);
$raw = curl_exec($ch);
if ($raw === false) {
    throw new RuntimeException(curl_error($ch));
}
$answer = json_decode($raw, true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
    throw new RuntimeException("{$answer['code']}: {$answer['message']}");
}

A report with a PDF

// Node.js 18 or later: fetch is built in.
const res = await fetch('https://api.baatzo.com/v1/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BAATZO_API_KEY}`,
    'Idempotency-Key': `report-${report.id}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: '+919829012345',
    template: { name: 'mock_test_report', language: 'en' },
    variables: {
      body: { parent_name: 'Asha', student: 'Ravi' },
      header: { document: { link: report.pdfUrl, filename: 'Mock test 4.pdf' } },
    },
    reference: `report-${report.id}`,
  }),
});
const answer = await res.json();
if (res.status === 429 || res.status === 503) {
  // Wait Retry-After seconds. For a 503 on a code, send a new code.
}
# Python 3.9 or later, with: pip install requests
res = requests.post(
    "https://api.baatzo.com/v1/messages",
    headers={
        "Authorization": f"Bearer {os.environ['BAATZO_API_KEY']}",
        "Idempotency-Key": f"report-{report.id}",
    },
    json={
        "to": "+919829012345",
        "template": {"name": "mock_test_report", "language": "en"},
        "variables": {
            "body": {"parent_name": "Asha", "student": "Ravi"},
            "header": {"document": {"link": report.pdf_url, "filename": "Mock test 4.pdf"}},
        },
        "reference": f"report-{report.id}",
    },
    timeout=30,
)
answer = res.json()
if res.status_code in (429, 503):
    ...  # Wait Retry-After seconds. For a 503 on a code, send a new code.
// The same curl call as the login code, with this body.
$body = json_encode([
    'to' => '+919829012345',
    'template' => ['name' => 'mock_test_report', 'language' => 'en'],
    'variables' => [
        'body' => ['parent_name' => 'Asha', 'student' => 'Ravi'],
        'header' => ['document' => ['link' => $report->pdfUrl, 'filename' => 'Mock test 4.pdf']],
    ],
    'reference' => "report-{$report->id}",
]);
// On 429 or 503, wait Retry-After seconds. For a 503 on a code, send a new code.

Answers

201 Created
{ "id": "0193f6c2-7a1e-7c55-9d1b-4f2b6c1d9a10", "status": "accepted", "reference": "login-88213" }
HTTPstatusMeans
201acceptedWhatsApp took the message. Webhooks follow as it is sent, delivered and read.
201failed, withheldWhatsApp refused it for good. error carries WhatsApp's code and a plain explanation in English and Hindi. No Baatzo fee.
202queuedA Utility or Marketing send WhatsApp asked to wait. Baatzo retries it; the webhook tells you how it ends.
202unknownWhatsApp did not answer in time. It may still deliver; the webhook settles it. Do not send again with a new Idempotency-Key.

Read a message

GET/v1/messages/{id}

Any message sent through the API in your workspace. Needs messages:read.

curl https://api.baatzo.com/v1/messages/0193f6c2-7a1e-7c55-9d1b-4f2b6c1d9a10 \
  -H "Authorization: Bearer $BAATZO_API_KEY"

{ "id": "0193f6c2-7a1e-7c55-9d1b-4f2b6c1d9a10",
  "status": "delivered", "status_rank": 5, "reference": "login-88213",
  "template": { "name": "login_code", "language": "en", "category": "authentication" },
  "created_at": "2027-01-28T09:15:00.120Z",
  "times": { "accepted_at": "…", "sent_at": "…", "delivered_at": "…", "read_at": null, "failed_at": null },
  "charge": { "category": "authentication", "baatzo_fee_paise": 2, "state": "chargeable",
              "meta_charge_estimate": { "amount_micro_rupees": "115000", "is_estimate": true } },
  "error": null }

Meta bills its own charge to your WhatsApp Business account; meta_charge_estimate is an estimate from Meta's published rate. baatzo_fee_paise is Baatzo's fee, taken from your message credit only when Meta charges for the message.

Export everything

POST/v1/exports
GET/v1/exports
GET/v1/exports/{id}/download

Your whole workspace in one zip: contacts, their consent history and the whole consent ledger, messages, templates (JSON), every invoice and credit note (PDF), a campaigns summary and the automations (JSON). It is the same export as Settings, Export everything. Needs data:export. The POST needs an Idempotency-Key of 8 to 100 letters, digits, - or _; it answers 202 with the export queued, and the key's creator gets an email when it is ready. A ready export can be downloaded for 7 days, then it is deleted. One export of everything is built at a time (409 export_in_progress).

curl -X POST https://api.baatzo.com/v1/exports \
  -H "Authorization: Bearer $BAATZO_API_KEY" -H "Idempotency-Key: export-2027-02-01"

202 Accepted
{ "export": { "id": "0193f6d1-…", "status": "queued", "everything": true, "contacts": null,
              "created_at": "…", "completed_at": null, "expires_at": null, "download_url": null } }

curl https://api.baatzo.com/v1/exports -H "Authorization: Bearer $BAATZO_API_KEY"
{ "exports": [ { "id": "0193f6d1-…", "status": "ready", "download_url": "/v1/exports/0193f6d1-…/download", … } ],
  "next_cursor": null }
GET/v1/contacts/{id}/consent-certificate

A PDF of one contact's consent ledger: who they are, their consent now, and every opt-in and opt-out with its date, source, the statement shown, the IP address and the person or key that recorded it where Baatzo has them, each with its record id. Needs contacts:read. It is for your records, not legal advice. The workspace's whole ledger is a CSV in the web app (Settings, Business, Your data).

The full API (Pro)

Contacts, templates, campaigns, Marketing sends and event webhooks are the full API. They are part of the Pro plan (and Enterprise). On Starter or Growth every full API operation answers 403 plan_required with details.upgradeTo, the plan to move to; a sandbox key gets 403 forbidden with details.reason sandbox_scope.

Contacts

GET/v1/contacts
POST/v1/contacts
GET/v1/contacts/{id}
PATCH/v1/contacts/{id}
DELETE/v1/contacts/{id}

Reads need contacts:read, changes contacts:write. GET /v1/contacts lists newest first and filters by q (a name or a number), tag_id, list_id, marketing and utility (granted, withdrawn or none); it also answers total.

POST /v1/contacts adds a contact or updates the one with the same number. It needs an Idempotency-Key, and answers 201 with "created": true for a new contact, 200 for an update. Consent grants in the same request are recorded after the contact is saved.

FieldTypeNotes
phonestringE.164, such as +919829012345. Give phone or bsuid.
bsuidstringWhatsApp's user ID, for a person known by username only.
name, usernamestringUp to 120 and 40 characters. null clears one.
attributesobjectCustom field values by field key, such as { "city": "Jaipur" }: text up to 500 characters, a number, or null to clear.
tag_ids, list_idsarrayUp to 50 ids each, of tags and lists that exist.
consentarrayUp to 2 grants, each as in Recording consent.
curl https://api.baatzo.com/v1/contacts \
  -H "Authorization: Bearer $BAATZO_API_KEY" \
  -H "Idempotency-Key: signup-asha-20261128" \
  -H "Content-Type: application/json" \
  -d '{ "phone": "+919829012345", "name": "Asha Verma",
        "attributes": { "city": "Jaipur" },
        "consent": [ { "purpose": "marketing", "collected_via": "web_form",
                       "statement": "Send me offers on WhatsApp.",
                       "captured_at": "2026-11-28T15:30:00+05:30", "ip": "203.0.113.7" } ] }'

201 Created
{ "created": true,
  "contact": { "id": "0193b1c2-4d5e-7f60-8a1b-2c3d4e5f6a70", "name": "Asha Verma", "phone": "+919829012345",
               "source": "api", "consent": { "marketing": "granted", "utility": "none", "marketing_opted_out_at": null },
               "us_number": false, "unreachable_until": null, "tags": [], "lists": [], … },
  "consent_records": [ { "id": "0193b1c3-…", "purpose": "marketing", "action": "grant", "source": "api",
                         "collected_via": "web_form", "captured_at": "2026-11-28T10:00:00.000Z",
                         "recorded_at": "2026-11-28T10:00:01.000Z" } ] }
// Node.js 18 or later: fetch is built in.
const res = await fetch('https://api.baatzo.com/v1/contacts', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BAATZO_API_KEY}`,
    'Idempotency-Key': `signup-${form.id}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    phone: form.phone,
    name: form.name,
    consent: [{
      purpose: 'marketing',
      collected_via: 'web_form',
      statement: form.consentText, // the exact words beside the tick box
      captured_at: new Date(form.submittedAt).toISOString(),
      ip: form.ip,
    }],
  }),
});
const answer = await res.json();
if (!res.ok) throw new Error(`${answer.code}: ${answer.message}`);

PATCH /v1/contacts/{id} changes phone, bsuid, name, username, attributes, tag_ids or list_ids; a field you leave out keeps its value, and tag_ids and list_ids replace the contact's tags and lists. A number another contact already has is 409 contact_exists. Consent is never changed here.

DELETE /v1/contacts/{id} answers 204. It is the DPDP erasure the web app does: the contact, its tags, lists and files go for good. Its opt-outs stay as one-way hashes, so a person who said stop is never messaged again, even if they are added once more. Their consent records stay in the ledger without the contact.

POST/v1/contacts/{id}/consents
POST/v1/contacts/{id}/opt-out

Consent is per purpose, marketing or utility, and lives in a ledger that is only ever added to. A send never records consent for Marketing: record it first, from your own evidence. POST /v1/contacts/{id}/consents takes one record with action grant or withdraw, needs contacts:write and an Idempotency-Key, and answers 201 with the record and the contact.

FieldNotes
purposeRequired. marketing or utility.
actionRequired on /consents. grant or withdraw. Each item of consent in POST /v1/contacts is a grant.
collected_viaRequired for a grant. How the person agreed: web_form, paper_form, whatsapp, ctwa_ad (a Click-to-WhatsApp ad), in_person, phone_call or other.
statementRequired for a grant. The words the person agreed to, up to 1,000 characters, exactly as they saw or heard them.
captured_atRequired for a grant. When they agreed, ISO 8601 with its offset, such as 2026-11-28T15:30:00+05:30. A withdrawal without it is dated now.
ipThe IPv4 or IPv6 address they agreed from, when you have one.
noteUp to 500 characters, for your own records.

Tags and lists

GET/v1/tags
GET/v1/lists
POST/v1/contacts/{id}/tags
DELETE/v1/contacts/{id}/tags/{tagId}
POST/v1/contacts/{id}/lists
DELETE/v1/contacts/{id}/lists/{listId}

GET /v1/tags answers up to 500 tags by name, each with its number of contacts; GET /v1/lists up to 500 lists, each with kind static or segment (a saved filter). Tags and lists are made in the web app. POST /v1/contacts/{id}/tags takes { "tag_ids": [...] } (1 to 50), POST /v1/contacts/{id}/lists takes { "list_id" }; each change answers 200 with the contact.

Templates

GET/v1/templates
GET/v1/templates/{id}
GET/v1/templates/{id}/status

Read only, with templates:read: templates are written and submitted to Meta in the web app, where the rules check and the category advice run. The list is newest first and filters by status (draft, pending, approved, rejected, paused, disabled or all, the default), category, name and language.

Each template carries the version Meta reviewed: its category, status, quality, variables (the names to fill, or code for Authentication), header, body, footer and buttons, and sendable: true when POST /v1/messages can send it. GET /v1/templates/{id}/status answers the review state alone, with requested_category, rejected_reason and paused_until. The template.status_changed event tells you when Meta decides.

curl "https://api.baatzo.com/v1/templates?status=approved&category=marketing" \
  -H "Authorization: Bearer $BAATZO_API_KEY"

{ "templates": [ { "id": "0193a1b2-3c4d-7e5f-8a6b-7c8d9e0f1a2b", "name": "diwali_offer", "language": "en",
                   "category": "marketing", "status": "approved", "quality": "green", "sendable": true,
                   "variables": ["name", "code"], "header": { "format": "image", "text": null },
                   "body": "Hi {{name}}, use {{code}} for 20% off this Diwali.", … } ],
  "next_cursor": null }

Campaigns

GET/v1/campaigns
POST/v1/campaigns
GET/v1/campaigns/{id}
GET/v1/campaigns/{id}/stats
POST/v1/campaigns/{id}/estimate
POST/v1/campaigns/{id}/schedule
POST/v1/campaigns/{id}/send
POST/v1/campaigns/{id}/cancel

The campaign builder of the web app, step by step. Reads need campaigns:read, the rest campaigns:write. Everything the web app checks is checked: the template is approved and not Authentication (send codes one by one with POST /v1/messages), Marketing goes only to contacts with a marketing consent and no later opt-out and never to +1 numbers, quiet hours and the ban shield apply, and the credit for every recipient is reserved before anything goes.

  1. POST /v1/campaigns makes a draft and sends nothing. It needs an Idempotency-Key and answers 201 with the campaign and variables_needed. Give name, template_id or template { name, language }, an audience of at least one of list_ids, segment_ids and tag_ids (up to 20 each), and variables: each variable as { "source": "name" | "phone" | "field" | "text", "field", "fallback" }. A recipient whose variable stays empty is skipped, never sent a broken message. from picks the sending number by Meta's phone number ID; header_media { link, file_name } fills a media header.
  2. POST /v1/campaigns/{id}/estimate answers who can get it, who is left out and why (duplicates, no_identity, opted_out, no_consent, us_number, unreachable, missing_variables), Meta's charge at most (an estimate), Baatzo's fee with GST, the messaging limit forecast, quiet hours and whether your credit covers it. It changes nothing.
  3. POST /v1/campaigns/{id}/schedule with scheduled_at (ISO 8601 with its offset, 5 minutes to 90 days ahead), or POST /v1/campaigns/{id}/send to send now. Both need an Idempotency-Key, confirm the estimate and reserve the credit. When the credit does not cover everyone, the answer is 402 insufficient_credit; with "start_anyway": true it starts with the part the credit covers. When nobody can get it, 422 nothing_to_send.
  4. Send now holds the campaign for 30 seconds (status held, until held_until). POST /v1/campaigns/{id}/cancel in that time stops it with nothing sent. A draft or a scheduled campaign also ends at once and its credit goes back; one that is sending stops after the messages Meta already has.
  5. GET /v1/campaigns/{id}/stats answers the counters the web app shows: recipients, queued, sent, delivered, read, replied, held, failed, withheld, skipped and cancelled, with reasons, Baatzo's fee and Meta's charge so far. campaign.finished posts them when it ends.

A campaign in a state that does not allow the step is 409 campaign_state, with the reason in details.reason (such as campaign_locked within 5 minutes of its start). A paused number or a spending limit reached is 409 sending_paused. Statuses: draft, held, scheduled, preparing, sending, paused, paused_no_credit, cancelling, cancelled, completed and failed. GET /v1/campaigns filters by status: draft, active, finished or all.

curl https://api.baatzo.com/v1/campaigns \
  -H "Authorization: Bearer $BAATZO_API_KEY" \
  -H "Idempotency-Key: diwali-2026-draft" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Diwali offer 2026",
        "template": { "name": "diwali_offer", "language": "en" },
        "audience": { "list_ids": ["0193b1c2-0000-7a00-8000-0000000000a1"] },
        "variables": { "name": { "source": "name", "fallback": "there" },
                       "code": { "source": "text", "fallback": "DIWALI20" } },
        "header_media": { "link": "https://cdn.example.com/diwali.jpg" } }'

201 Created
{ "campaign": { "id": "0193c0d1-2e3f-7a4b-8c5d-6e7f8a9b0c1d", "status": "draft", … },
  "variables_needed": ["name", "code"] }
// Node.js 18 or later. Estimate, then schedule for 10 am India time.
const call = (path, body, idempotencyKey) =>
  fetch(`https://api.baatzo.com/v1${path}`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.BAATZO_API_KEY}`,
      'Content-Type': 'application/json',
      ...(idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : {}),
    },
    body: JSON.stringify(body ?? {}),
  }).then(async (res) => {
    const answer = await res.json();
    if (!res.ok) throw new Error(`${answer.code}: ${answer.message}`);
    return answer;
  });

const { estimate } = await call(`/campaigns/${id}/estimate`);
console.log(estimate.eligible, estimate.excluded, estimate.credit.enough);
await call(`/campaigns/${id}/schedule`, { scheduled_at: '2026-12-05T10:00:00+05:30' }, `diwali-2026-schedule`);

Marketing sends

On Pro, POST /v1/messages sends a Marketing template to one person when the key has messages:send_marketing as well as messages:send. The body is the same as any send. A template with an image or video header takes variables.header.image or variables.header.video as { "link" }.

curl https://api.baatzo.com/v1/messages \
  -H "Authorization: Bearer $BAATZO_API_KEY" \
  -H "Idempotency-Key: diwali-asha-1" \
  -H "Content-Type: application/json" \
  -d '{ "to": "+919829012345",
        "template": { "name": "diwali_offer", "language": "en" },
        "variables": { "body": { "name": "Asha", "code": "DIWALI20" },
                       "header": { "image": { "link": "https://cdn.example.com/diwali.jpg" } } },
        "reference": "diwali-asha" }'

201 Created
{ "id": "0193f6c2-…", "status": "accepted", "reference": "diwali-asha" }

Status events

Set one HTTPS URL for your workspace in Settings, Developers. Baatzo posts an event each time a message sent through the API is sent, delivered, read or fails. The page shows the signing secret once (it starts whsec_), sends a test event, and lists 30 days of deliveries.

POST https://your-server.example/baatzo-webhook
Baatzo-Signature: t=1801123456,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
Content-Type: application/json

{ "id": "evt_0193f6c4-…", "type": "message.delivered",
  "created_at": "2027-01-28T09:15:02Z",
  "data": { "message_id": "0193f6c2-…", "reference": "login-88213",
            "wamid": "wamid.HBgMOTE5ODI5MDEyMzQ1FQIAERgS…",
            "status": "delivered", "status_rank": 5,
            "charge": { "category": "authentication", "baatzo_fee_paise": 2, "state": "chargeable" },
            "error": null } }

Event webhooks (Pro)

On Pro, the same endpoint can also take events about your workspace, not only about API messages. Each one is signed with the same Baatzo-Signature, retried on the same schedule, kept in the same 30-day delivery log and can be replayed. Baatzo writes an event only when your endpoint subscribes to its type and your plan has the full API, so an event you did not choose is never sent later. The body is always { "id", "type", "created_at", "data" }; drop a repeat by id. No payload carries a template variable, a code or a hash.

TypeFires when
message.receivedA customer sends a message to one of your numbers. Once per WhatsApp message, even when Meta repeats its webhook.
contact.opted_inA contact's consent for marketing or utility becomes granted, from any source: the web app, an import, the API or a WhatsApp reply.
contact.opted_outA contact withdraws consent for marketing or utility, such as by replying STOP.
template.status_changedMeta's review moves a template: approved, rejected, paused, disabled or moved to another category.
campaign.finishedA campaign completes, is cancelled or fails, with its results at that moment.
payment_link.paidRazorpay reports one of your payment links paid in full. Payment links in Baatzo are coming soon; the event fires once they are live.
conversation.assignedA person, a keyword rule or the round robin gives a chat to a team member.

message.received

{ "id": "evt_0193c2a0-1b2c-7d3e-8f4a-5b6c7d8e9f01", "type": "message.received",
  "created_at": "2026-11-28T10:05:00.000Z",
  "data": { "message_id": "0193c2a0-1b2c-7d3e-8f4a-5b6c7d8e9f00",
            "wamid": "wamid.HBgMOTE5ODI5MDEyMzQ1FQIAEhgg…",
            "conversation_id": "0193b9e0-1111-7222-8333-444455556666",
            "phone_number_id": "109876543210987",
            "contact": { "id": "0193b1c2-4d5e-7f60-8a1b-2c3d4e5f6a70", "phone": "+919829012345", "bsuid": null, "name": "Asha Verma" },
            "type": "text", "text": "Is the offer on till Sunday?",
            "reply_to_wamid": null, "received_at": "2026-11-28T10:04:59.000Z" } }

text is the message's text or a media file's caption, else null; reply_to_wamid is the message it answers, if any.

contact.opted_in

{ "id": "evt_0193c2a1-…", "type": "contact.opted_in", "created_at": "2026-11-28T10:00:01.000Z",
  "data": { "contact": { "id": "0193b1c2-4d5e-7f60-8a1b-2c3d4e5f6a70", "phone": "+919829012345", "bsuid": null, "name": "Asha Verma" },
            "purpose": "marketing" } }

contact.opted_out

{ "id": "evt_0193c2a2-…", "type": "contact.opted_out", "created_at": "2026-11-28T12:00:00.000Z",
  "data": { "contact": { "id": "0193b1c2-4d5e-7f60-8a1b-2c3d4e5f6a70", "phone": "+919829012345", "bsuid": null, "name": "Asha Verma" },
            "purpose": "marketing", "opted_out_at": "2026-11-28T11:59:58.000Z" } }

template.status_changed

{ "id": "evt_0193c2a3-…", "type": "template.status_changed", "created_at": "2026-11-21T08:00:01.000Z",
  "data": { "template_id": "0193a1b2-3c4d-7e5f-8a6b-7c8d9e0f1a2b", "name": "diwali_offer", "language": "en",
            "category": "marketing", "previous_status": "pending", "status": "approved", "reason": null } }

reason carries Meta's reason for a rejection, a pause or a new category, where Meta gives one.

campaign.finished

{ "id": "evt_0193c2a4-…", "type": "campaign.finished", "created_at": "2026-12-05T11:20:00.000Z",
  "data": { "campaign_id": "0193c0d1-2e3f-7a4b-8c5d-6e7f8a9b0c1d", "name": "Diwali offer 2026",
            "status": "completed", "failure_reason": null, "finished_at": "2026-12-05T11:20:00.000Z",
            "stats": { "recipients": 1200, "sent": 1180, "delivered": 1150, "read": 900, "replied": 64,
                       "failed": 20, "skipped": 0, "failed_by_reason": { "131026": 20 },
                       "baatzo_fee_paise": "5750",
                       "meta_charge_estimate": { "amount_micro_rupees": "992565000", "is_estimate": true }, … } } }

status is completed, cancelled or failed; stats has the same fields as GET /v1/campaigns/{id}/stats.

{ "id": "evt_0193c2a5-…", "type": "payment_link.paid", "created_at": "2026-11-28T13:00:00.000Z",
  "data": { "payment_link_id": "0193c2a5-0000-7000-8000-0000000000aa", "reference_id": "order-1042",
            "description": "Order 1042", "amount_paise": "149900", "paid_amount_paise": "149900",
            "method": "upi", "razorpay_payment_id": "pay_PQ1234567890ab",
            "contact": { "id": "0193b1c2-4d5e-7f60-8a1b-2c3d4e5f6a70", "phone": "+919829012345", "bsuid": null, "name": "Asha Verma" },
            "conversation_id": "0193b9e0-1111-7222-8333-444455556666", "paid_at": "2026-11-28T12:59:58.000Z" } }

conversation.assigned

{ "id": "evt_0193c2a6-…", "type": "conversation.assigned", "created_at": "2026-11-28T10:06:00.000Z",
  "data": { "conversation_id": "0193b9e0-1111-7222-8333-444455556666",
            "contact": { "id": "0193b1c2-4d5e-7f60-8a1b-2c3d4e5f6a70", "phone": "+919829012345", "bsuid": null, "name": "Asha Verma" },
            "assignee": { "id": "0193a000-aaaa-7bbb-8ccc-dddddddddddd", "name": "Ravi" },
            "method": "round_robin", "assigned_at": "2026-11-28T10:06:00.000Z" } }

method is manual, automation or round_robin.

Manage the webhook

GET/v1/webhook-endpoint
PUT/v1/webhook-endpoint/events
GET/v1/webhook-deliveries
GET/v1/webhook-deliveries/{id}
POST/v1/webhook-deliveries/{id}/replay

On Pro, with webhooks:manage. The address and the signing secret can be set only in the web app, by an Owner or Admin with two-step verification, never with an API key: a key can choose the events and replay them, never send them to another server.

curl -X PUT https://api.baatzo.com/v1/webhook-endpoint/events \
  -H "Authorization: Bearer $BAATZO_API_KEY" -H "Content-Type: application/json" \
  -d '{ "events": ["message.sent", "message.delivered", "message.read", "message.failed",
                   "message.received", "contact.opted_out", "campaign.finished"] }'

Verify the signature

v1 is the HMAC-SHA256 of the timestamp, a full stop and the raw body, keyed with your secret, in hex. Check it on the raw bytes before parsing the JSON, compare in constant time, and refuse a timestamp more than 5 minutes off. After you rotate the secret, both the old and the new one sign for 24 hours, so the header carries two v1 values: accept the event if either matches.

// Verifying a Baatzo status webhook (API v1). Node.js 18 or later, no packages.
//
// Baatzo sends   Baatzo-Signature: t=1801123456,v1=<hex>[,v1=<hex>]
// where each v1 is the HMAC-SHA256 of "<t>.<raw body>" keyed with your signing secret (whsec_...).
// During a secret rotation the header carries two v1 values for 24 hours; accept the request if any matches.
// Check the RAW body, byte for byte, before parsing it as JSON.

const { createHmac, timingSafeEqual } = require('crypto');

const TOLERANCE_SECONDS = 5 * 60;

/**
 * True when the header is a valid Baatzo signature of rawBody under secret, made at most 5 minutes
 * from now. rawBody is a Buffer or string, exactly as received.
 */
function verifyBaatzoSignature(rawBody, header, secret, now = Date.now()) {
  if (typeof header !== 'string' || typeof secret !== 'string') return false;
  let t = null;
  const signatures = [];
  for (const part of header.split(',')) {
    const i = part.indexOf('=');
    const k = part.slice(0, i).trim();
    const v = part.slice(i + 1).trim();
    if (k === 't' && /^\d{1,12}$/.test(v)) t = Number(v);
    if (k === 'v1' && /^[0-9a-f]{64}$/.test(v)) signatures.push(Buffer.from(v, 'hex'));
  }
  if (t === null || !signatures.length) return false;
  if (Math.abs(Math.floor(now / 1000) - t) > TOLERANCE_SECONDS) return false;
  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(String(rawBody), 'utf8');
  const expected = createHmac('sha256', secret).update(`${t}.`).update(body).digest();
  return signatures.some((s) => s.length === expected.length && timingSafeEqual(s, expected));
}

module.exports = { verifyBaatzoSignature };

// Express example: keep the raw body for the check.
//
//   app.post('/baatzo-webhook', express.raw({ type: 'application/json' }), (req, res) => {
//     if (!verifyBaatzoSignature(req.body, req.get('Baatzo-Signature'), process.env.BAATZO_WEBHOOK_SECRET)) {
//       return res.status(400).end();
//     }
//     const event = JSON.parse(req.body.toString('utf8'));
//     // Drop a repeat by event.id; ignore a status older than one you already have (event.data.status_rank).
//     res.status(200).end(); // answer within 5 seconds, then do the work
//   });
# Verifying a Baatzo status webhook (API v1). Python 3.9 or later, no packages.
#
# Baatzo sends   Baatzo-Signature: t=1801123456,v1=<hex>[,v1=<hex>]
# where each v1 is the HMAC-SHA256 of "<t>.<raw body>" keyed with your signing secret (whsec_...).
# During a secret rotation the header carries two v1 values for 24 hours; accept the request if any matches.
# Check the RAW body, byte for byte, before parsing it as JSON.

import hashlib
import hmac
import re
import time

TOLERANCE_SECONDS = 5 * 60


def verify_baatzo_signature(raw_body, header, secret, now=None):
    """True when header is a valid signature of raw_body (bytes), made at most 5 minutes from now."""
    if not isinstance(header, str) or not secret:
        return False
    t, signatures = None, []
    for part in header.split(","):
        k, _, v = (x.strip() for x in part.partition("="))
        if k == "t" and re.fullmatch(r"[0-9]{1,12}", v):
            t = int(v)
        if k == "v1" and re.fullmatch(r"[0-9a-f]{64}", v):
            signatures.append(v)
    if t is None or not signatures:
        return False
    if abs(int(time.time() if now is None else now) - t) > TOLERANCE_SECONDS:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(s, expected) for s in signatures)


# Flask example: request.get_data() is the raw body.
#
#   @app.post("/baatzo-webhook")
#   def baatzo_webhook():
#       raw = request.get_data()
#       if not verify_baatzo_signature(raw, request.headers.get("Baatzo-Signature"), os.environ["BAATZO_WEBHOOK_SECRET"]):
#           return "", 400
#       event = json.loads(raw)
#       # Drop a repeat by event["id"]; ignore a status older than one you already have (status_rank).
#       return "", 200  # answer within 5 seconds, then do the work
<?php
// Verifying a Baatzo status webhook (API v1). PHP 8.0 or later, no packages.
//
// Baatzo sends   Baatzo-Signature: t=1801123456,v1=<hex>[,v1=<hex>]
// where each v1 is the HMAC-SHA256 of "<t>.<raw body>" keyed with your signing secret (whsec_...).
// During a secret rotation the header carries two v1 values for 24 hours; accept the request if any matches.
// Check the RAW body, byte for byte, before parsing it as JSON.

const BAATZO_TOLERANCE_SECONDS = 300;

/** True when $header is a valid Baatzo signature of $rawBody, made at most 5 minutes from now. */
function verify_baatzo_signature(string $rawBody, ?string $header, string $secret, ?int $now = null): bool
{
    if ($header === null || $secret === '') {
        return false;
    }
    $t = null;
    $signatures = [];
    foreach (explode(',', $header) as $part) {
        [$k, $v] = array_map('trim', array_pad(explode('=', $part, 2), 2, ''));
        if ($k === 't' && preg_match('/^[0-9]{1,12}$/D', $v)) {
            $t = (int) $v;
        }
        if ($k === 'v1' && preg_match('/^[0-9a-f]{64}$/D', $v)) {
            $signatures[] = $v;
        }
    }
    if ($t === null || $signatures === []) {
        return false;
    }
    if (abs(($now ?? time()) - $t) > BAATZO_TOLERANCE_SECONDS) {
        return false;
    }
    $expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);
    foreach ($signatures as $signature) {
        if (hash_equals($expected, $signature)) {
            return true;
        }
    }
    return false;
}

// A webhook script: php://input is the raw body.
//
//   $raw = file_get_contents('php://input');
//   if (!verify_baatzo_signature($raw, $_SERVER['HTTP_BAATZO_SIGNATURE'] ?? null, getenv('BAATZO_WEBHOOK_SECRET'))) {
//       http_response_code(400);
//       exit;
//   }
//   $event = json_decode($raw, true);
//   // Drop a repeat by $event['id']; ignore a status older than one you already have (status_rank).
//   http_response_code(200); // answer within 5 seconds, then do the work

The same files: verify-signature.js, verify-signature.py and verify-signature.php.

Delivery log and replay

Settings, Developers lists the last 30 days of deliveries: the time, the event, the wamid, your server's HTTP status, how long it took and the attempts. Each one opens to show the payload, the status code and the first 2 KB of your server's answer.

Error codes

Every error is { "code", "message", "details" }. Act on code; message is for people and may change.

CodeHTTPWhen
unauthenticated401The key is missing, malformed, unknown or revoked.
forbidden403The key lacks the scope (details.reason is missing_scope), a sandbox key tried something other than sending and reading messages (sandbox_scope), or the workspace is suspended or closing.
plan_required403The workspace is on Template Studio, or a full API operation, a Marketing send or an event type beyond message status needs Pro (details.upgradeTo names the plan). Keys stay after a downgrade, but those requests fail until the plan returns.
idempotency_key_required400A POST that needs an Idempotency-Key has none: a send, an export, adding a contact, recording consent, creating, scheduling or sending a campaign, or a replay.
invalid_request422A field fails validation. details lists each { field, message }.
template_not_found404No template with that name and language.
template_not_approved422The template is not approved now (details.status says what it is).
category_not_allowed422The template is Marketing (including one Meta has moved to Marketing) and the key has no messages:send_marketing, or the sandbox was asked to send Marketing.
recipient_not_allowed422The number's country is not allowed for this key (details.country), or a Marketing send to a +1 number (details.reason us_number).
recipient_opted_out422The person withdrew consent for messages like this (details.purpose is marketing for a Marketing send).
insufficient_credit402Your message credit cannot cover Baatzo's fee, for one message or for every recipient of a campaign. Nothing was sent. Top up in Billing.
sending_paused409The number cannot send now; details.reason says why (for example reconnect_needed, meta_payment or, for a campaign, spend_limit_reached).
idempotency_key_reused422The same Idempotency-Key with a different body.
request_in_progress409POST /v1/messages: the first request with this Idempotency-Key is still running. Try again in a moment.
rate_limited429Over the key's limit, or too many wrong keys from your address. See Retry-After.
retry_later503An Authentication send hit a temporary WhatsApp error. Send a new code.
not_found404No such message, contact, tag, list, template, campaign, export or delivery in this workspace, or no webhook address set yet.
idempotency_key_invalid400POST /v1/exports and the full API: the Idempotency-Key is not 8 to 100 letters, digits, - or _.
idempotency_in_progress409POST /v1/exports and the full API: the first request with this key is still running.
export_in_progress409An export of everything is being built already.
export_not_ready409The export is still queued or building. Try again in a minute.
export_expired410The export's 7 days are over, or it could not be made. Make a new one.
contact_exists409PATCH /v1/contacts/{id}: another contact already has that number or WhatsApp user ID.
consent_refused422A consent grant after an opt-out has no evidence dated after that opt-out (details.reason is reopt_in_needs_evidence or consent_before_opt_out). From POST /v1/contacts, the contact is still saved (details.contact_id).
consent_required422A Marketing send to a person with no marketing consent recorded. Record it first.
recipient_unreachable422A Marketing send to a number that was not on WhatsApp when Baatzo last tried. Marketing to it waits 30 days.
campaign_state409The campaign's status does not allow this step, such as scheduling one already sent or changing one within 5 minutes of its start (details.reason).
nothing_to_send422Scheduling or sending a campaign that nobody in its audience can get. details.estimate says why.
quiet_hours409A Marketing send outside the workspace's sending hours, which campaigns keep too. details.retry_at is when they start again; details.start and details.end are the hours, India time.

Statuses

statusstatus_rankMeans
queued0 to 1Not with WhatsApp yet.
unknown1WhatsApp did not answer in time; a webhook settles it.
accepted2WhatsApp took it.
held3WhatsApp is checking it before delivery.
sent4Sent to the person's phone.
delivered5On the person's phone.
read6Opened.
failed, withheld7Not delivered. Withheld messages are held back by Meta and not charged.