API & SDK

REST API yang
meta-compatible

Path /v1 mirror persis WhatsApp Cloud API. Migrasi dari Meta langsung jalan, plus dapat TypeScript SDK gratis, OpenAPI spec public, dan auto-retry yang sane.

40+ Endpoints
7 Tipe pesan
100% TypeScript
OpenAPI 3.1 Spec public
TypeScript SDK

SDK yang behave seperti library production

Auto-retry, idempotency, pagination, typed errors. Tidak perlu reinvent kalau cukup bun add @kirimdev/sdk.

Cross-runtime, Web Standard APIs only

Target resmi Node 18+, Bun 1.2+, dan Deno. Web Standard APIs only (fetch, AbortSignal, crypto.randomUUID) — no node-fetch, no polyfill drama.

  • Auto-retry untuk 429, 502/503/504, network error — honor Retry-After
  • Idempotency key auto-generated untuk setiap POST — retry-safe
  • Typed error hierarchy 8-class: InvalidRequestError, AuthenticationError, RateLimitError, NotFoundError, ConflictError, dan lainnya
  • Async iterable pagination — tinggal for await ... of
send-message.ts
import { Kirim } from '@kirimdev/sdk'

const kirim = new Kirim({
  apiKey: process.env.KIRIM_API_KEY!
})

// Scope ke phone_number_id — sama persis path /v1
const phone = kirim.phoneNumbers('106540352242922')

const msg = await phone.messages.send({
  messaging_product: 'whatsapp',
  to: '+628123456789',
  type: 'text',
  text: { body: 'Hai!' }
})

// Auto-retry 429/5xx, idempotency key di-set otomatis
console.log(msg.id) // msg_abc123

REST API tanpa SDK pun bisa

Punya stack non-JS? Tidak masalah. Endpoint clean, schema discoverable via OpenAPI 3.1 spec, bisa di-import langsung ke Postman, Insomnia, atau code-gen ke bahasa lain.

  • Bearer auth — header Authorization: Bearer kdv_live_...
  • OpenAPI spec public di GET /v1/openapi.json
  • Idempotency-Key header support — send aman di-retry
  • Cross-org access return 404, bukan 403 — no enumeration leak
send.sh
# Bearer auth — satu API key untuk REST, SDK, dan MCP
curl -X POST https://api.kirimdev.com/v1/$PHONE_ID/messages \
  -H "Authorization: Bearer $KIRIM_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "+628123456789",
    "type": "template",
    "template": {
      "name": "order_confirmation",
      "language": { "code": "id" },
      "components": [...]
    }
  }'
Endpoints

Lengkap, scoped per WhatsApp account

Path /v1/{phone_number_id}/... mirror persis Meta. Messages, contacts, conversations, templates — semua di satu base URL.

POST /v1/{phone}/messages
GET /v1/{phone}/messages
GET /v1/{phone}/messages/{id}/media
GET /v1/{phone}/conversations
PATCH /v1/{phone}/conversations/{id}
POST /v1/{phone}/contacts
GET /v1/{phone}/templates
POST /v1/webhook_subscriptions
GET /v1/webhook_deliveries
GET /v1/accounts
POST /v1/customers
GET /v1/me
list-conversations.ts
// Async iterable — auto-follow next_cursor
for await (const conv of phone.conversations.list({
  status: 'open',
  limit: 50
})) {
  console.log(conv.id, conv.contact.phone_number)
}

Pagination yang tidak bikin sakit kepala

Cursor-based, async iterable. Tidak ada offset, tidak ada race condition, tidak ada page-N-not-found.

Bekerja sama untuk messages, conversations, contacts, templates, dan webhook deliveries — pattern yang konsisten di seluruh API.

Built-in

Detail yang biasanya kelewat

Auto-retry

Exponential backoff untuk 429 dan 5xx. Retry-After dihormati. Default maxRetries: 2, configurable.

Idempotency keys

Auto-set via crypto.randomUUID() di setiap POST. Aman di-retry, tidak akan dobel-send.

7 tipe pesan

Text, image, video, document, audio, template, interactive (buttons, list, CTA URL). Semua via satu endpoint.

Cross-org safe

Akses resource lintas organisasi return 404, bukan 403. Tidak ada enumeration leak.

Rate limit per-org

Token bucket di-share antara REST + MCP. Header X-RateLimit-* di setiap response.

Read receipts

Mark inbound message as read, plus optional typing indicator — semua via satu POST /messages call.

Build hari ini, ship besok

Daftar gratis, generate API key, install SDK — kirim pesan pertama dalam 5 menit.