# Baatzo API v1 > The Baatzo API sends one approved Utility or Authentication WhatsApp template to one number, reads how it went, exports a workspace's data, and posts a signed webhook each time a message's status changes. It is part of the Starter, Growth and Pro plans; sandbox keys (bz_test_) work on every plan. The MCP server at https://api.baatzo.com/mcp offers the same operations to AI assistants, with OAuth sign-in or an API key. Baatzo is a WhatsApp Business Platform product of Aashita Technosoft Private Limited, Jaipur (https://baatzo.com). Base URL: https://api.baatzo.com. JSON over HTTPS. Every error is `{ "code", "message", "details" }`: act on `code`; `message` is for people and may change. API messages appear in the contact's chat in Baatzo, marked API, and cost what any message costs: Meta's charge, which Meta bills to the business's own WhatsApp Business Account directly, plus Baatzo's fee from the workspace's message credit. Marketing templates cannot be sent through API v1. Campaign endpoints, marketing sends and webhooks for events other than message status come later. Contacts can be read and added through the MCP server. ## Authentication 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. Roll a key to replace it without downtime: the new key has the same scopes and the old one works for 24 hours more. Send it as a bearer token: `Authorization: Bearer bz_live_<8-character prefix>_<32 characters>` (`bz_test_` for a sandbox key). Scopes: - `messages:send`: POST /v1/messages - `messages:read`: GET /v1/messages/{id}; on the MCP server, the templates and the credit balance - `contacts:read`: GET /v1/contacts/{id}/consent-certificate; on the MCP server, listing contacts - `contacts:write`: on the MCP server, adding and updating contacts - `data:export`: POST /v1/exports, GET /v1/exports and the download A new key sends only to Indian numbers. The workspace Owner can add countries to a key in Settings, Developers. Limits: each key may send 10 messages a second, with bursts to 20, and read 20 times a second. Over that, the answer is 429 `rate_limited` with a Retry-After header in seconds. Every answer carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (also as X-RateLimit-*) for the key's bucket, and X-Request-Id, which support asks for. More than 20 requests a minute with a wrong key from one address are refused the same way for a minute. Idempotency: `Idempotency-Key` is required on every send. The same key with the same body gets the first answer, with nothing sent twice; keys are kept for 24 hours. The same key with a different body is 422 `idempotency_key_reused`. Baatzo retries a Utility send itself when WhatsApp asks it to wait. It never retries an Authentication send, because it does not keep the code: on a temporary error the answer is 503 `retry_later`, and your login flow sends a fresh code. ## Libraries Both read the key you pass in, keep `Idempotency-Key` for you (pass your own to make a retry safe), and check webhook signatures. - Node.js 20 or later: `npm install @baatzo/node` (https://www.npmjs.com/package/@baatzo/node). `const baatzo = new Baatzo(process.env.BAATZO_API_KEY)`; `await baatzo.messages.send({ to, template: { name, language }, variables: { body: { ... } }, reference }, { idempotencyKey })`; `await baatzo.messages.get(id)`; `verifyWebhook(rawBody, header, secret)`. - Python 3.10 or later: `pip install baatzo` (https://pypi.org/project/baatzo/). `baatzo = Baatzo(api_key=os.environ["BAATZO_API_KEY"])`; `baatzo.messages.send(to=..., template={"name": ..., "language": ...}, variables={"body": {...}}, reference=..., idempotency_key=...)`; `baatzo.messages.get(id)`; `verify_webhook(raw_body, header, secret)`. - Any other language: plain HTTPS and JSON, below. ## Endpoints - [POST /v1/messages](https://api.baatzo.com/docs#send): send one approved Utility or Authentication template to one number. Needs `messages:send` and an `Idempotency-Key` header. Body: `to` (E.164, such as +919829012345), `template.name`, `template.language` (exactly as in Baatzo, such as en or en_IN), optional `from` (Meta's phone number ID, needed only when the workspace has more than one number for the template), `variables.body` (each variable by name or number; for Authentication `{ "code": "482913" }`, 1 to 15 letters and digits), `variables.header.document` (`{ "link", "filename" }`, https only), `variables.buttons` (`{ "index", "url" }` or `{ "index", "copy_code" }`) and `reference` (your own id, up to 64 characters). Answers 201 `accepted` (WhatsApp took it), 201 `failed` or `withheld` (refused for good, with WhatsApp's code and a plain explanation in English and Hindi, no Baatzo fee), 202 `queued` (a Utility send WhatsApp asked to wait; Baatzo retries it) or 202 `unknown` (WhatsApp did not answer in time; the webhook settles it; do not send again with a new Idempotency-Key). - [GET /v1/messages/{id}](https://api.baatzo.com/docs#read): a message's status, `status_rank`, `reference`, template and category, times (`accepted_at`, `sent_at`, `delivered_at`, `read_at`, `failed_at`), charge and, on failure, the error with a plain explanation. Needs `messages:read`. `charge.baatzo_fee_paise` is Baatzo's fee, taken from message credit only when Meta charges for the message; `charge.meta_charge_estimate` is an estimate from Meta's published rate, because Meta bills its own charge directly. - [POST /v1/exports](https://api.baatzo.com/docs#exports): export the whole workspace into 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). Needs `data:export` and an `Idempotency-Key` of 8 to 100 letters, digits, - or _. Answers 202 with the export queued; the key's creator gets an email when it is ready. One export of everything is built at a time (409 `export_in_progress`). - [GET /v1/exports](https://api.baatzo.com/docs#exports): list exports, newest first, with cursor pagination (`cursor`, `limit`). Needs `data:export`. - [GET /v1/exports/{id}/download](https://api.baatzo.com/docs#exports): download a ready export. A ready export can be downloaded for 7 days, then it is deleted (410 `export_expired`). Needs `data:export`. - [GET /v1/contacts/{id}/consent-certificate](https://api.baatzo.com/docs#consent): 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. Needs `contacts:read`. It is for your records, not legal advice. - [POST /mcp](https://api.baatzo.com/docs/mcp.html): the Baatzo MCP server (see below). ## Sandbox Build and test before the 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 and exports need a live key (another scope is refused with 400 `sandbox_scope_not_allowed`, and other operations answer 403 `forbidden` with reason `sandbox_scope`). POST /v1/messages takes the same body and headers, checks them the same way and answers at once with `"sandbox": true` and a made-up wamid starting `wamid.SANDBOX`. Nothing reaches WhatsApp and nothing is charged; the message does not appear in the inbox. Any template name is accepted; if the workspace has a template with that name and language, its category is checked as on a live key, and Marketing is refused. The status webhook then gets `message.sent` after about 1 second, `message.delivered` after about 3 and `message.read` after about 8, signed like live events, with `"sandbox": true` in the event and in `data`, and the header `Baatzo-Sandbox: 1`. A sandbox key reads sandbox messages only, and a live key never sees them. Opt-outs are not checked. Sandbox messages are kept 30 days. Test numbers: +919000000001 gets `message.failed` after about 2 seconds with Meta's error 131026 (message undeliverable); +919000000002 is sent and delivered, never read; any other number is sent, delivered and read. ## MCP server and OAuth - [MCP server guide](https://api.baatzo.com/docs/mcp.html): address `https://api.baatzo.com/mcp`, Streamable HTTP, stateless (GET and DELETE answer 405). It is API v1 over the Model Context Protocol, with the same scopes, limits and error codes, and it sees only the one Baatzo workspace. Tools: `list_templates` (`messages:read`; templates with category, status, the variables each needs and whether the API can send it), `send_template_message` (`messages:send`; the body of POST /v1/messages plus a required `idempotency_key`), `get_message_status` (`messages:read`), `list_contacts` (`contacts:read`; newest first, with marketing and utility consent; `search` matches a name or number), `upsert_contact` (`contacts:write`; adds a contact by E.164 number or updates its name and custom fields; never records consent) and `get_credit_balance` (`messages:read`; Baatzo message credit in paise and rupees). A refusal is a tool error whose structured content is `{ "error": { "code", "message", "details" } }`. Sign in with OAuth: give the app only the address. Apps that follow the MCP authorization specification (Claude, ChatGPT, Cursor and others) open Baatzo in the browser; an Owner or Admin with two-step verification, in a workspace on Starter, Growth or Pro, chooses the workspace and the permissions and presses Allow. The app sends to Indian numbers only and never to the sandbox. It stays connected until removed in Settings, Developers, Connected apps, or 30 days unused; access lasts an hour at a time and renews itself. For app builders: protected resource metadata at `/.well-known/oauth-protected-resource/mcp` (a 401 from /mcp names it in WWW-Authenticate), authorization server metadata at `/.well-known/oauth-authorization-server`, dynamic registration at `POST /oauth/register` (public clients only, https redirect URIs or http to localhost, 127.0.0.1 or [::1]), the authorization code grant with PKCE (S256) and `resource=https://api.baatzo.com/mcp`. Refresh tokens rotate on every use; presenting a used one again disconnects the app. `POST /oauth/revoke` disconnects it. Or use a key: `Authorization: Bearer `, a sandbox key first, with only the scopes the assistant's tools need. Claude Code: `claude mcp add --transport http baatzo https://api.baatzo.com/mcp`. ## Webhooks Set one HTTPS URL for the 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. Event types: `message.sent`, `message.delivered`, `message.read`, `message.failed`, and `webhook.test` from the test button. The body is `{ "id", "type", "created_at", "data": { "message_id", "reference", "wamid", "status", "status_rank", "charge", "error" } }`. Payloads never carry template variables or codes. Answer any 2xx within 5 seconds. Otherwise Baatzo retries after 1, 5, 15 and 30 minutes, then 1, 2, 4 and 8 hours, and a last time 24 hours after the first attempt. Owners and Admins get one email a day while deliveries fail. Events can arrive out of order or more than once: drop a repeat by `id`, and ignore a status whose `status_rank` is lower than one you already have. Baatzo calls only public addresses and does not follow redirects. Replays from the delivery log carry the same event id, a fresh timestamp and the header `Baatzo-Replay: 1`. Signature: the header is `Baatzo-Signature: t=,v1=`, where v1 is the HMAC-SHA256 of the timestamp, a full stop and the raw body, keyed with the `whsec_` secret. Check it on the raw bytes before parsing the JSON, compare in constant time, and refuse a timestamp more than 5 minutes off. For 24 hours after a secret is rotated, the header carries two v1 values: accept the event if either matches. - [verify-signature.js](https://api.baatzo.com/docs/verify-signature.js): the check in Node.js, ready to copy; also [Python](https://api.baatzo.com/docs/verify-signature.py) and [PHP](https://api.baatzo.com/docs/verify-signature.php). ## Reference - [API reference](https://api.baatzo.com/docs): the human-readable reference, with every error code and status. - [OpenAPI document](https://api.baatzo.com/docs/openapi.json): API v1 and its webhook as OpenAPI 3.1; import this address into Postman. - [Everything in one file](https://api.baatzo.com/docs/llms-full.txt): the three pages below in full, as Markdown. - Pages as Markdown: [reference](https://api.baatzo.com/docs/index.md), [MCP server](https://api.baatzo.com/docs/mcp.md), [changelog and version policy](https://api.baatzo.com/docs/changelog.md). Statuses, with `status_rank`: `queued` (0 to 1, not with WhatsApp yet), `unknown` (1, WhatsApp did not answer in time), `accepted` (2), `held` (3, WhatsApp is checking it before delivery), `sent` (4), `delivered` (5), `read` (6), `failed` and `withheld` (7, not delivered; withheld messages are held back by Meta and not charged). Error codes: `unauthenticated` 401, `forbidden` 403, `plan_required` 403 (the workspace is on Template Studio), `idempotency_key_required` 400, `invalid_request` 422, `template_not_found` 404, `template_not_approved` 422, `category_not_allowed` 422 (Marketing, including a template Meta has moved to Marketing), `recipient_not_allowed` 422, `recipient_opted_out` 422, `insufficient_credit` 402, `sending_paused` 409, `idempotency_key_reused` 422, `request_in_progress` 409, `rate_limited` 429, `retry_later` 503, `not_found` 404, `idempotency_key_invalid` 400, `idempotency_in_progress` 409, `export_in_progress` 409, `export_expired` 410. ## Optional - [Baatzo website for AI assistants](https://baatzo.com/llms.txt): what Baatzo is, its plans and prices in INR, and every page. - [Developers page](https://baatzo.com/developers): Embedded Signup, how Baatzo handles Meta's webhooks, and agency workspaces.