# Table of Contents - [Introduction — kirim.dev docs](#introduction-kirim-dev-docs) - [Sending messages — kirim.dev docs](#sending-messages-kirim-dev-docs) - [Templates — kirim.dev docs](#templates-kirim-dev-docs) - [Rate limits — kirim.dev docs](#rate-limits-kirim-dev-docs) - [Webhooks — kirim.dev docs](#webhooks-kirim-dev-docs) - [Media — kirim.dev docs](#media-kirim-dev-docs) - [Errors — kirim.dev docs](#errors-kirim-dev-docs) --- # Introduction — kirim.dev docs Menu Introduction ============ kirim.dev is a developer platform for the WhatsApp API. You call a REST API from your own code to send messages, templates, and interactive replies, and to receive events over webhooks. It is infrastructure — not an inbox, broadcast tool, or CRM. The request and response shapes are the **WhatsApp Cloud API's**, unchanged. What you send is forwarded to Meta byte for byte, so Meta's official reference describes every field — this documentation covers what's specific to kirim.dev: the base URL, authentication, and which endpoints are available. 1\. Connect a number -------------------- In the [dashboard](https://app.kirim.dev/) , connect a WhatsApp number — onboard one through Embedded Signup, or bring your own WhatsApp Business account. Coexistence numbers are supported. Once the number is`connected`, it can send. 2\. Create an API key --------------------- Create a key in the dashboard under **API Keys**. Keys look like `kd_live_…` (or`kd_test_…` for testing). The key is shown once — store it somewhere safe. It authenticates every request; your Meta token stays encrypted in our vault and never touches your code. 3\. Base URL ------------ Send requests to `https://api.kirim.dev`. The path is the Cloud API path, including the version segment: https://api.kirim.dev/v23.0/{PHONE_NUMBER_ID}/messages The version segment is Meta's, e.g. `v23.0`. Pin the version you tested against — kirim.dev forwards it to Meta unchanged and never rewrites it for you. It must be a full Cloud API version like`v23.0`, not a bare `v1`. 4\. Authentication ------------------ Pass your kirim.dev API key as a bearer token. Do not send your Meta token — kirim.dev supplies that for you. header Authorization: Bearer kd_live_a1B2c3D4xY7z... Keys come in two modes. A `kd_live_…` key and a `kd_test_…` key authenticate and forward the same way — the mode is a label so you can separate keys used by your test and production code in the dashboard, not a sandbox. Both send real messages against the number they are used with. 5\. Your first request ---------------------- Send a text message: send-message.sh curl -X POST https://api.kirim.dev/v23.0/{PHONE_NUMBER_ID}/messages \ -H "Authorization: Bearer $KIRIM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messaging_product": "whatsapp", "to": "62812XXXXXXX", "type": "text", "text": { "body": "Hello from kirim.dev 👋" } }' Replace `{PHONE_NUMBER_ID}` with your connected number's phone number id (from the dashboard) and`62812XXXXXXX` with the recipient in international format (digits only, no `+`). A successful call returns the message id, exactly as Meta returns it. Responses & limits ------------------ Responses are Meta's, forwarded byte for byte — status code, headers, and body. kirim.dev adds a`RateLimit-Remaining` header so you can pace yourself, and on a throttle a `Retry-After`. See [Rate limits](https://kirim.dev/docs/rate-limits/) for the details. A request body is capped at **100 MB**, matching Meta's media limit; a larger body is refused with a`413` before any call to Meta is made. What's next ----------- * [Sending messages](https://kirim.dev/docs/messages/) — text, media, interactive. * [Templates](https://kirim.dev/docs/templates/) — create and send message templates. * [Media](https://kirim.dev/docs/media/) — upload and send images, documents, and more. * [Webhooks](https://kirim.dev/docs/webhooks/) — receive inbound messages and status events. * [Rate limits](https://kirim.dev/docs/rate-limits/) — throughput tiers and throttle headers. * [Errors](https://kirim.dev/docs/errors/) — how failures are reported. --- # Sending messages — kirim.dev docs Menu Sending messages ================ Send text, media, and interactive messages to a WhatsApp user from a connected number. Endpoint -------- POST https://api.kirim.dev/v23.0/{PHONE_NUMBER_ID}/messages `{PHONE_NUMBER_ID}` is the connected number's phone number id. Authenticate with your kirim.dev API key (see [Introduction](https://kirim.dev/docs/) ). The `to` field is the recipient in international format — digits only, no leading `+`. Text ---- text message { "messaging_product": "whatsapp", "to": "62812XXXXXXX", "type": "text", "text": { "body": "Hello 👋" } } Interactive (buttons) --------------------- interactive message { "messaging_product": "whatsapp", "to": "62812XXXXXXX", "type": "interactive", "interactive": { "type": "button", "body": { "text": "Confirm your order?" }, "action": { "buttons": [\ { "type": "reply", "reply": { "id": "yes", "title": "Yes" } },\ { "type": "reply", "reply": { "id": "no", "title": "No" } }\ ] } } } Every message `type` the Cloud API supports works the same way — image, document, location, contacts, list messages, and more. Set the `type` and the matching object, and send. Payload details:Full field reference for every message type is in [Meta's Cloud API reference →](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages) Mark as read & typing --------------------- The same endpoint marks an inbound message as read (and shows a typing indicator) — set `status`instead of `type`: mark as read { "messaging_product": "whatsapp", "status": "read", "message_id": "wamid.HBgL..." } Response -------- A successful send returns Meta's response unchanged, including the message id: { "messaging_product": "whatsapp", "contacts": [{ "input": "62812XXXXXXX", "wa_id": "62812XXXXXXX" }], "messages": [{ "id": "wamid.HBgL..." }] } --- # Templates — kirim.dev docs Menu Templates ========= Create, list, and delete message templates, then send them. Note that template management is rooted at the**WhatsApp Business Account id** (WABA id), not the phone number id — mirroring Meta. Create a template ----------------- POST https://api.kirim.dev/v23.0/{WABA_ID}/message_templates create template { "name": "order_confirmation", "language": "en_US", "category": "UTILITY", "components": [\ { "type": "BODY", "text": "Hi {{1}}, your order {{2}} is confirmed." }\ ] } Newly created templates start in `PENDING` and must be approved by Meta before they can be sent. Supported methods on this endpoint: `GET` (list), `POST` (create), `DELETE`. List templates -------------- GET https://api.kirim.dev/v23.0/{WABA_ID}/message_templates Send a template --------------- Sending a template is a `messages` call with `type: "template"` against the phone number id: send template { "messaging_product": "whatsapp", "to": "62812XXXXXXX", "type": "template", "template": { "name": "order_confirmation", "language": { "code": "en_US" }, "components": [\ { "type": "body", "parameters": [\ { "type": "text", "text": "Andi" },\ { "type": "text", "text": "A-1024" }\ ] }\ ] } } Payload details:Template components, categories, and button types are documented in [Meta's Cloud API reference →](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates) --- # Rate limits — kirim.dev docs Menu Rate limits =========== kirim.dev paces your traffic just under Meta's ceilings, so a burst is turned into a short, well-signalled wait here rather than a hard rejection from Meta mid-campaign. The limits are the ones Meta enforces — kirim.dev does not add a stricter cap of its own. Sending messages ---------------- Sends are limited **per connected phone number**, at that number's messaging throughput tier. Each number has its own budget, so one busy number never slows another. | Tier | Throughput | Notes | | --- | --- | --- | | Standard | 80 messages/sec | Meta's default for a connected number. | | Low | 20 messages/sec | Numbers on a reduced tier. | | High | 1,000 messages/sec | Numbers Meta has raised to the top tier. | A number's tier is Meta's, visible in the dashboard. Newly connected numbers start on the standard tier; Meta raises it automatically as your quality and volume grow. Reads (template listings) ------------------------- Listing templates and other read calls do not consume a number's messaging throughput, but they draw on the WhatsApp Business Account's shared request budget — Meta allows **5,000 requests per hour per WABA**(about 1.4 per second sustained). A short burst at startup is fine; only sustained traffic is held near that rate. What a throttle looks like -------------------------- When you exceed a limit, kirim.dev returns `429` with the headers that tell you how long to wait. Read them and pace yourself rather than retrying blindly into another `429`: 429 response HTTP/1.1 429 Too Many Requests Retry-After: 7 RateLimit-Remaining: 0 RateLimit-Reset: 7 Content-Type: application/json { "error": { "message": "Sending too fast for this phone number. Retry in 7s.", "type": "KirimThrottleException", "code": 429 } } * `Retry-After` — seconds to wait before the next request will be accepted. * `RateLimit-Remaining` — requests left in the current window (`0` at a refusal). * `RateLimit-Reset` — seconds until the budget refills. `RateLimit-Remaining` is sent on **successful** responses too, so you can slow down before you hit the limit rather than only learning of it at the `429`. If the limiter is unavailable ----------------------------- Rate limiting fails open: if the limiter cannot be reached, your request is forwarded rather than refused. Meta's own ceiling still applies, so you are never left unprotected — you may briefly see Meta's `429`instead of kirim.dev's. --- # Webhooks — kirim.dev docs Menu Webhooks ======== Register HTTPS endpoints to receive WhatsApp events — inbound messages, delivery and read statuses, and more. kirim.dev verifies Meta's signature, then delivers each event to your endpoints, retrying on failure and signing every delivery so you can trust it. Register an endpoint -------------------- Add an endpoint from the [dashboard](https://app.kirim.dev/) under **Webhooks**. You provide a URL and the fields to subscribe to; kirim.dev returns a **signing secret shown once** — store it, it is not shown again. * `url` — your HTTPS endpoint. It must return a `2xx` quickly. * `fields` — the events to receive, e.g. `messages`, `statuses` (1–40 fields). * Optionally scope an endpoint to a single connected number; otherwise it receives events for all of them. What a delivery looks like -------------------------- Each event is a POST to your URL. The body is the WhatsApp webhook payload, unchanged: POST /your-endpoint POST https://your-app.example.com/webhooks Content-Type: application/json webhook-id: msg_2a9f... webhook-timestamp: 1720000000 webhook-signature: v1,K5oScU9s7Yx... X-Meta-Signature-256: sha256=... { "object": "whatsapp_business_account", "entry": [ { "changes": [ { "field": "messages", "value": { ... } } ] } ] } Verifying the signature ----------------------- Deliveries are signed with the [Standard Webhooks](https://www.standardwebhooks.com/) scheme, so any Standard Webhooks library verifies them. The signature covers `id.timestamp.payload`, which also protects against replay. verify.ts import { Webhook } from "standardwebhooks"; const wh = new Webhook(process.env.KIRIM_WEBHOOK_SECRET); // throws if the signature or timestamp is invalid const event = wh.verify(rawRequestBody, { "webhook-id": req.headers["webhook-id"], "webhook-timestamp": req.headers["webhook-timestamp"], "webhook-signature": req.headers["webhook-signature"], }); Headers on every delivery: * `webhook-id` — unique id for this event (use it to deduplicate). * `webhook-timestamp` — unix seconds; reject deliveries far outside your tolerance. * `webhook-signature` — `v1,`. * `X-Meta-Signature-256` — Meta's original signature, forwarded for BYOA verification. Retries & delivery history -------------------------- A delivery that does not get a `2xx` is retried with backoff over several hours. You can see each endpoint's delivery history — status, attempts, and the response it got — and replay a delivery from the dashboard. An endpoint that keeps failing is disabled automatically, and shown as such before it happens. Payload details:The structure of the event payload (entry, changes, value) and every field you can subscribe to are documented in [Meta's Cloud API reference →](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components) --- # Media — kirim.dev docs Menu Media ===== Send images, documents, audio, video, and stickers — either by uploading first, or by a public link. Upload media ------------ Upload returns a media id you can reuse across messages: POST https://api.kirim.dev/v23.0/{PHONE_NUMBER_ID}/media Send a `multipart/form-data` body with the file and its `type`, exactly as the Cloud API expects. Send by media id ---------------- image by id { "messaging_product": "whatsapp", "to": "62812XXXXXXX", "type": "image", "image": { "id": "MEDIA_ID" } } Send by link ------------ Skip the upload and reference a publicly reachable URL: image by link { "messaging_product": "whatsapp", "to": "62812XXXXXXX", "type": "image", "image": { "link": "https://example.com/photo.jpg" } } Retrieve media -------------- To fetch a media object's metadata and authenticated download URL — for example, media received on an inbound message — call the media id directly. Because a media id does not identify a number on its own, you must pass the connected number as a `phone_number_id` query parameter so kirim.dev knows which account credential to use; omitting it returns a `400`. retrieve media GET https://api.kirim.dev/v23.0/{MEDIA_ID}?phone_number_id={PHONE_NUMBER_ID} Download inbound media ---------------------- Use the `url` returned by the metadata request and send the same `kd_live_…` bearer key. The URL points to kirim.dev, which obtains a fresh temporary URL from Meta and streams the file without storing or caching it. Do not download the `lookaside.fbsbx.com` URL from the webhook directly: Meta requires its own access token there and will reject a kirim.dev key with `401`. download media curl -L \ -H "Authorization: Bearer $KIRIM_API_KEY" \ "https://api.kirim.dev/v23.0/{MEDIA_ID}/content?phone_number_id={PHONE_NUMBER_ID}" \ --output media.bin Payload details:Supported media types, size limits, and the upload format are in [Meta's Cloud API reference →](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media) --- # Errors — kirim.dev docs Menu Errors ====== Errors use the same envelope shape as Meta's Cloud API, so a client that already handles Cloud API errors keeps working. There are two sources: Meta's errors, passed through ----------------------------- If Meta rejects a request — a bad payload, a rate limit, an unapproved template — that error is forwarded to you**untouched**, with Meta's own `type`, `code`, and message. Handle these exactly as you would calling Meta directly. kirim.dev's own errors ---------------------- Errors raised by kirim.dev rather than Meta — including authentication, billing, throughput, transport, and response-processing failures — carry a `Kirim*` type so you can tell them apart from Meta's, while keeping the familiar envelope: error envelope { "error": { "message": "This account has no active subscription. Subscribe in the dashboard.", "type": "KirimBillingException", "code": 402 } } | HTTP | type | When | | --- | --- | --- | | 401 | KirimAuthException | Missing or invalid API key. | | 402 | KirimBillingException | No active subscription for this account. | | 404 | KirimRoutingException | Unknown or unsupported route, or an account you do not own. | | 413 | KirimRequestTooLarge | Request body exceeds the size limit. | | 422 | KirimAccountException | The number is not connected yet. | | 429 | KirimThrottleException | Sending too fast for this number; retry after the given delay. | | 502 | KirimUpstreamException | Could not reach Meta. The request was not sent. | | 502 | KirimUpstreamResponseException | Meta responded, but its media metadata could not be processed. | | 503 | KirimUpstreamException | Temporarily unable to serve the request. | On a `429`, respect the `Retry-After` header — the limiter paces you below Meta's ceiling to reduce the chance of a rejection mid-campaign. ---