KirimChat menyediakan Public API dan Webhooks untuk integrasi dengan sistem eksternal seperti CRM, e-commerce, atau automation tools.
Overview
Fitur Developer
| Fitur | Deskripsi |
|---|---|
| API Keys | Autentikasi untuk akses API |
| Public API | REST API untuk kirim pesan, manage customer |
| Webhooks | Notifikasi real-time untuk events |
| Event Logs | Monitoring dan debugging |
Subscription Requirement
Fitur Developer memerlukan paket BASIC atau lebih tinggi.
API Keys
API Key digunakan untuk autentikasi saat mengakses Public API.
Membuat API Key
- Buka Developers > API Keys
- Klik Create API Key
- Isi nama untuk identifikasi
- Pilih expiration (1-365 hari)
- Klik Create
- Copy dan simpan key - hanya ditampilkan sekali!
Format API Key
Code
Status API Key
| Status | Deskripsi |
|---|---|
| Active | Key aktif dan bisa digunakan |
| Expiring | Akan expired dalam 30 hari |
| Expired | Sudah tidak bisa digunakan |
Revoke API Key
- Temukan key di daftar
- Klik Revoke
- Konfirmasi
- Key langsung tidak aktif
Batasan
- Maksimal 5 API keys per user
- Expiration: 1-365 hari
- Tidak bisa melihat full key setelah dibuat
Autentikasi API
Semua request ke Public API harus menyertakan header:
Code
Contoh Request
Code
Public API Endpoints
Base URL: https://api-prod.kirim.chat/api/v1/public
Untuk dokumentasi lengkap semua endpoint, request/response schema, dan contoh interaktif, lihat API Reference.
Endpoint Overview
| Endpoint | Method | Deskripsi |
|---|---|---|
/health | GET | Health check & verifikasi API key |
/customers | POST | Buat customer baru |
/customers | GET | List customers dengan filter & pagination |
/customers/{customerId} | GET | Get customer by ID |
/customers/phone/{phoneNumber} | GET | Get customer by phone number |
/messages/send | POST | Kirim pesan (text, template, media, interactive) |
/messages/{messageId}/status | GET | Cek status pesan |
/messages/{messageId}/read | POST | Mark message as read |
/conversations/{customerIdentifier}/typing | POST | Kirim typing indicator |
/templates | GET | List WhatsApp templates |
/templates/{templateId} | GET | Get template by ID |
/accounts/instagram | GET | List connected Instagram accounts |
/accounts/messenger | GET | List connected Facebook Pages |
Contoh: Send Text Message
Code
Contoh: Send Template Message
Code
Contoh: Send Media Message
Code
Response Format
Code
Rate Limits
| Channel | Limit |
|---|---|
| 60 msg/min | |
| 180 msg/hour | |
| Messenger | 180 msg/hour |
| Typing Indicator | 1 req/3 sec per customer |
Error Responses
Code
Error Codes
| Code | HTTP | Deskripsi |
|---|---|---|
| ValidationError | 400 | Input tidak valid |
| NotFound | 404 | Resource tidak ditemukan |
| Unauthorized | 401 | API key invalid |
| Forbidden | 403 | Tidak punya akses |
| RateLimitExceeded | 429 | Rate limit tercapai |
| WindowClosed | 400 | Jendela 24 jam tertutup |
| ConfigurationError | 400 | Channel tidak terkonfigurasi |
| InternalError | 500 | Server error |
Webhooks
Webhooks mengirim notifikasi real-time ke endpoint Anda saat event terjadi.
Membuat Webhook
- Buka Developers > Webhooks
- Klik Create Webhook
- Isi:
- Name - Nama untuk identifikasi
- URL - Endpoint HTTPS Anda
- Events - Event yang ingin disubscribe
- Channels - Channel filter (opsional)
- Klik Create
- Simpan secret - untuk verifikasi signature
Event Types
| Event | Deskripsi |
|---|---|
message.received | Pesan masuk dari customer |
message.sent | Pesan berhasil dikirim |
message.delivered | Pesan sampai ke device |
message.read | Pesan dibaca customer |
message.failed | Pengiriman pesan gagal |
Channel Filter
- whatsapp - Hanya event WhatsApp
- instagram - Hanya event Instagram
- messenger - Hanya event Messenger
- all - Semua channel
Webhook Payload
Code
Signature Verification
Setiap request webhook menyertakan header signature:
Code
Verifikasi dengan HMAC-SHA256:
Code
Test Webhook
- Buka webhook yang sudah dibuat
- Klik Test
- Endpoint akan menerima test payload
- Lihat response status dan latency
Delivery Logs
Lihat history pengiriman webhook:
- Timestamp
- Event type
- Response status
- Latency
- Error message (jika gagal)
- Retry count
Retention: 7 hari
Retry Policy
Jika webhook gagal (non-2xx response):
- Retry hingga 5 kali
- Exponential backoff
- Webhook di-disable setelah consecutive failures
Mengedit Webhook
- Klik webhook dari daftar
- Edit URL, events, atau channels
- Save
Menghapus Webhook
- Klik ikon delete
- Konfirmasi
- Webhook langsung tidak aktif
Batasan
- Maksimal 3 webhook endpoints per user
- URL harus HTTPS (HTTP hanya untuk development)
- Timeout: 10 detik
Integrasi Tools
n8n
- Install n8n
- Buat workflow baru
- Gunakan HTTP Request node
- Masukkan API key di header Authorization
Zapier
- Buat Zap baru
- Gunakan Webhook trigger untuk menerima event
- Gunakan HTTP action untuk kirim pesan
Custom Integration
Gunakan library HTTP di bahasa pemrograman Anda:
- Node.js: axios, fetch
- Python: requests
- PHP: Guzzle
- Go: net/http
Best Practices
API Keys
- Jangan expose - Simpan di environment variable
- Rotate berkala - Buat key baru dan revoke yang lama
- Monitor usage - Cek last used timestamp
- Separate keys - Gunakan key berbeda untuk environment berbeda
Webhooks
- Respond cepat - Return 200 dalam kurang dari 5 detik
- Process async - Queue heavy processing
- Verify signature - Selalu validasi signature
- Handle duplicates - Gunakan event_id untuk dedup
- Monitor logs - Cek delivery logs secara berkala
Error Handling
- Implement retry - Untuk transient errors
- Log errors - Untuk debugging
- Alert on failures - Notifikasi jika banyak error
- Graceful degradation - Handle API downtime
Contoh Kode
Node.js
Code
Python
Code