API Documentation
Panduan lengkap integrasi API Cetar AI untuk developer.
Unified Developer API
Integrasikan WhatsApp, Telegram, Messenger, dan Instagram ke dalam aplikasi Anda hanya dengan satu API tunggal. Kelola pesan keluar dan terima notifikasi real-time dengan mudah.
Rate Limits
Maksimal 60 request per menit untuk setiap API Key yang aktif.
Base URL
https://api.cetar.ai/v1Protocols
Sistem API kami hanya menerima request dengan format JSON via HTTPS.
Authentication
All API requests must include your API Key in the Authorization header as a Bearer token.
NEVER SHARE YOUR API KEY WITH ANYONE OR DISPLAY IT ON THE CLIENT SIDE (BROWSER).
HEADER FORMAT
Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxxTOKEN TYPE
Bearer Token
TOKEN LOCATION
Request Header
Kirim Teks (Unofficial)
POSTKirim pesan teks ke nomor tujuan. Khusus untuk WhatsApp Unofficial (Scan QR / Pairing Code) atau Telegram.
Endpoint: POST https://api.cetar.ai/v1/messages
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"channel": "whatsapp",
"type": "text",
"to": "6281234567890",
"content": {
"text": "Halo! Ini pesan teks dari Cetar API."
}
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Nomor tujuan to pakai kode negara tanpa '+' atau '0'. Contoh: 6281234567890. Untuk Telegram, set channel ke "telegram".
Kirim Tombol (Unofficial)
POSTKirim pesan interaktif berisi tombol aksi (khusus WhatsApp Unofficial). Maksimal 3 tombol per pesan dengan tipe berbeda: Quick Reply, CTA URL, atau Copy Code.
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"channel": "whatsapp",
"type": "button",
"to": "6281234567890",
"media_url": "https://contoh.com/promo.jpg",
"content": {
"title": "๐ PROMO SPESIAL",
"text": "Apakah Anda ingin mengambil diskon 50% hari ini?",
"footer": "Berlaku hingga besok",
"buttons": [
{
"id": "AMBIL_PROMO",
"text": "Ya, Ambil!"
},
{
"type": "cta_url",
"text": "Kunjungi Website",
"url": "https://www.cetar.ai"
},
{
"type": "cta_copy",
"text": "Salin Kode",
"copy_code": "PROMO50"
}
]
}
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Tips Media (WhatsApp Unofficial)
Untuk menyisipkan gambar di atas tombol, tambahkan media_url di root JSON (sejajar dengan channel). Sistem otomatis menampilkan media di atas tombol.
Parameter Objek content
title: (Opsional) Teks tebal di bagian paling atas pesan.text: (Wajib) Teks utama deskripsi pesan Anda.footer: (Opsional) Teks kecil abu-abu di bagian bawah pesan.buttons: (Wajib) Array tombol. Format per tipe:Quick Reply (Default){ "id": "btn_id", "text": "Balas Sekarang" }CTA URL{ "type": "cta_url", "text": "Buka Link", "url": "https://google.com" }CTA Copy{ "type": "cta_copy", "text": "Salin Kode", "copy_code": "PROMO50" }
Kirim Template (Unofficial)
POSTKirim pesan yang sudah Anda desain di menu Broadcast โ Template (Balasan Cepat). Sistem otomatis menyisipkan variabel dan menggabungkan media/tombol yang telah diatur di dashboard.
Endpoint: POST https://api.cetar.ai/v1/send-template
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"to": "6281234567890",
"template_id": 123,
"variables": [
"Budi Santoso",
"Rp 500.000"
]
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/send-template',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Penjelasan Parameter
to: (Wajib) Nomor WhatsApp tujuan.template_id: (Wajib) ID Template, dapat disalin dari halaman Broadcast โ Template.variables: (Opsional) Array pengganti variabel {{1}}, {{2}}, dst sesuai urutan.
Kirim Media (Unofficial)
POSTKirim Gambar (JPG/PNG), Video (MP4), atau Dokumen (PDF). Pastikan URL media dapat diakses publik.
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"channel": "whatsapp",
"type": "image",
"to": "6281234567890",
"media_url": "https://contoh.com/gambar.jpg",
"content": {
"caption": "๐ Promo Spesial Hari Ini! Diskon 50%."
}
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;media_url: (Wajib) Tautan langsung ke file media.content.caption: (Opsional) Teks keterangan di bawah media.
Cek Nomor WA
POSTValidasi apakah sebuah nomor terdaftar aktif di WhatsApp. Parameter session_id bersifat opsional jika API Key Anda hanya terhubung ke 1 device WhatsApp.
Endpoint: POST https://api.cetar.ai/v1/check-number
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"channel": "whatsapp",
"phone": "6281234567890"
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/check-number',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Contoh Respons API
API mengembalikan JSON dengan field is_registered bernilai true atau false.
{
"success": true,
"message": "Nomor terdaftar di WhatsApp.",
"data": {
"phone": "6281234567890",
"jid": "[email protected]",
"is_registered": true
}
}Kirim Teks (Meta Official)
POSTBalas pesan dengan teks/media biasa tanpa template. Hanya berlaku dalam Jendela 24-Jam Meta.
Endpoint: POST https://api.cetar.ai/v1/meta/messages
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"to": "6281234567890",
"type": "text",
"text": "Halo! Ini balasan cepat via WhatsApp Official API."
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/meta/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Respons: { "success": true, "data": { "status": "queued", "job_id": "..." } }. Pesan diproses lewat antrian lalu dikirim ke Meta.
Kirim Media (Meta Official)
POSTKirim Gambar, Video, Dokumen, atau Audio tanpa template. Hanya berlaku dalam Jendela 24-Jam percakapan aktif Meta.
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"to": "6281234567890",
"type": "image",
"media_url": "https://contoh.com/promo.jpg",
"text": "๐ Promo Spesial Hari Ini! Diskon 50%."
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/meta/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;type:"image","video","document", atau"audio".media_url: (Wajib) Tautan publik ke file media (https://).text: (Opsional) Caption media.
Kirim Template (Meta Official)
POSTGunakan saat memulai percakapan baru di luar jendela 24-jam. Wajib pakai template yang sudah disetujui Meta.
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"to": "6281234567890",
"type": "template",
"template_name": "hello_world",
"language": "id",
"components": {
"header_image": "https://contoh.com/promo.jpg",
"body_variables": [
"Budi Santoso",
"Rp 500.000",
"25 Maret 2026"
]
}
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/meta/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Penjelasan Payload Template
template_name: (Wajib) Nama template persis seperti di Meta Business Manager.language: (Wajib) Kode bahasa, misalidatauen_US.components.header_image: (Opsional) URL gambar untuk header IMAGE. Bisa jugaheader_video/header_document.components.body_variables: (Opsional) Array pengganti variabel {{1}}, {{2}}, dst. Urutan harus sesuai.
Sinkronisasi Template: Agar isi template tampil lengkap di Inbox, sinkronkan dulu di menu Pengaturan โ WhatsApp Official โ Sinkronisasi Template.
Kirim Interaktif (Meta Official)
POSTKirim pesan interaktif (tombol reply, list menu) bergaya WhatsApp Official. Hanya dalam jendela 24-jam. Isi objek content diteruskan 100% ke Meta.
<?php
$curl = curl_init();
// Payload JSON
$payload = '{
"to": "6281234567890",
"type": "interactive",
"content": {
"type": "button",
"header": {
"type": "text",
"text": "๐ PROMO SPESIAL"
},
"body": {
"text": "Apakah Anda ingin mengambil diskon 50% hari ini?"
},
"footer": {
"text": "Berlaku hingga besok"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "AMBIL_PROMO",
"title": "Ya, Ambil!"
}
},
{
"type": "reply",
"reply": {
"id": "TOLAK_PROMO",
"title": "Tidak, Makasih"
}
}
]
}
}
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.cetar.ai/v1/meta/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Katalog Payload Interaktif Meta
Ganti objek action agar tombol membuka website:
"action": {
"name": "cta_url",
"parameters": {
"display_text": "Kunjungi Website",
"url": "https://www.cetar.ai"
}
}Ganti objek action agar tombol menyalin kode promo:
"action": {
"name": "copy_code",
"parameters": {
"display_text": "Salin Kode",
"id": "PROMO2026"
}
}Ganti seluruh objek content dengan format list (maksimal 10 opsi):
{
"type": "list",
"header": { "type": "text", "text": "Menu Utama" },
"body": { "text": "Silakan pilih layanan di bawah ini." },
"footer": { "text": "Cetar Automation" },
"action": {
"button": "Lihat Daftar Menu",
"sections": [
{
"title": "Produk & Layanan",
"rows": [
{ "id": "MENU_PRODUK", "title": "Daftar Produk", "description": "Lihat katalog lengkap" },
{ "id": "MENU_HARGA", "title": "Pricelist", "description": "Daftar harga terbaru" }
]
}
]
}
}Webhooks (Terima Pesan)
Terima data secara real-time ke server Anda setiap kali ada pesan masuk. Gunakan Webhook ini untuk membuat sistem Auto-Reply, Chatbot AI, atau merekam data ke database Anda.
1Format Webhook WA Unofficial
Jika aplikasi Anda ditautkan dengan WhatsApp Unofficial, sistem kami akan mengirimkan JSON ini ke URL Anda:
{
"event": "message.received",
"channel": "whatsapp",
"session_id": "SESSION_12345",
"data": {
"message_id": "msg_987654321",
"from": "6281234567890",
"sender_name": "Budi Santoso",
"type": "text",
"text": "Halo, saya butuh bantuan!",
"media_url": null,
"button_id": null,
"timestamp": 1709650000
}
}2Format Webhook WA Official (Meta)
Jika aplikasi Anda ditautkan dengan Meta Official, sistem kami akan langsung mem-forward JSON asli (Struktur Entry/Changes/Messages) dari server Meta:
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "1234567890",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "628123456789",
"phone_number_id": "987654321"
},
"contacts": [
{
"profile": { "name": "Budi Santoso" },
"wa_id": "6281234567890"
}
],
"messages": [
{
"from": "6281234567890",
"id": "wamid.HBgNNjI4M...",
"timestamp": "1709650000",
"text": { "body": "Halo, mau pesan!" },
"type": "text"
}
]
},
"field": "messages"
}
]
}
]
}Error Codes
Jika terjadi kesalahan saat request API, sistem akan mengembalikan salah satu dari status HTTP berikut berserta detailnya di body JSON.
Unauthorized
API Key tidak valid, sudah kadaluarsa, atau Header Authorization tidak disertakan.
Forbidden
Paket langganan Anda tidak mendukung fitur ini, atau IP address terblokir.
Unprocessable Entity
Payload JSON tidak valid, ada field wajib yang kosong, atau nomor tujuan salah format.
Too Many Requests
Anda melebihi batas Rate Limit (60 request per menit).
Internal Server Error
Kesalahan pada server kami. Tim kami akan segera menanganinya.