Lewati ke konten utama

Pesan

Kirim Pesan​

Kirim pesan teks ke customer lewat WhatsApp, Instagram, atau Messenger.

POST /api/v1/public/messages/send

Parameter​

ParameterTipeWajibKeterangan
phone_numberstringtidakNomor telepon customer. Gunakan ini untuk mencari customer di channel mana pun.
customer_idstringtidakCustomer ID (CUID). Alternatif dari phone_number.
instagram_usernamestringtidakUsername Instagram. Cara pencarian alternatif.
channelstringya"whatsapp", "instagram", atau "messenger"
message_typestringyaWhatsApp: "text", "image", "document", "audio", "video", "template". Instagram: "text", "image", "media_share". Messenger: "text", "image", "video", "audio", "file".
contentstringtidakIsi pesan teks (wajib untuk pesan teks)
media_urlstringtidakURL media untuk pesan image/video/audio/file
reply_to_message_idstringtidakKhusus WhatsApp. Kutip/balas pesan sebelumnya — isi dengan wamid pesan masuk (data.message_id atau data.raw.context.id dari webhook). Pesan asli akan tampil sebagai kutipan di atas balasan Anda.
whatsapp_phone_number_idstringtidakID nomor telepon WhatsApp. Gunakan untuk menentukan nomor bisnis mana yang mengirim pesan. Jika tidak diisi, ditentukan otomatis dari nomor yang terhubung dengan customer atau nomor utama.
instagram_account_idstringtidakID akun Instagram. Wajib jika customer punya percakapan dengan lebih dari satu akun Instagram.
facebook_page_idstringtidakID Facebook Page. Wajib jika customer punya percakapan dengan lebih dari satu Facebook Page.
info

Catatan: Minimal salah satu dari phone_number, customer_id, atau instagram_username wajib diisi untuk mengidentifikasi customer.

peringatan

Multi-Akun / Multi-Nomor: Untuk WhatsApp, gunakan whatsapp_phone_number_id untuk menentukan nomor bisnis mana yang mengirim pesan. Jika dikosongkan, API otomatis memakai nomor yang terhubung dengan customer atau nomor utama Anda. Untuk Instagram/Messenger, isi instagram_account_id atau facebook_page_id jika customer punya lebih dari satu percakapan.

Contoh Request​

curl -X POST "https://chat.api.co.id/api/v1/public/messages/send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "text",
"content": "Hello! This is a test message.",
"whatsapp_phone_number_id": "clyyy9876543210"
}'

Response​

{
"success": true,
"data": {
"message_id": "msg_xyz789",
"customer_id": "clxxx1234567890",
"whatsapp_phone_number_id": "clyyy9876543210",
"status": "sent",
"channel": "whatsapp",
"timestamp": "2025-01-07T10:30:00.000Z"
}
}
info

whatsapp_phone_number_id di response menunjukkan nomor bisnis mana yang dipakai untuk mengirim pesan. Ini berguna untuk melacak nomor yang dipakai jika Anda punya beberapa nomor WhatsApp yang terhubung.

Balas / kutip pesan sebelumnya (WhatsApp)​

Tambahkan reply_to_message_id agar pesan Anda tampil sebagai balasan yang mengutip pesan sebelumnya. Gunakan wamid dari pesan masuk — tersedia di payload webhook sebagai data.message_id (atau data.raw.context.id jika customer membalas salah satu pesan Anda).

curl -X POST "https://chat.api.co.id/api/v1/public/messages/send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "6281234567890",
"channel": "whatsapp",
"message_type": "text",
"content": "Betul kak, untuk treatment itu harganya Rp 150.000 😊",
"reply_to_message_id": "wamid.HBgMNjI4MTIzNDU2Nzg5"
}'
info

Berlaku untuk semua tipe pesan WhatsApp (text, image, document, dll.) — cukup tambahkan reply_to_message_id di samping payload biasa Anda. Pesan yang dirujuk harus pesan terbaru di percakapan yang sama; wamid yang sudah sangat lama mungkin tidak tampil sebagai kutipan.

Kirim Template​

Kirim pesan template WhatsApp yang sudah disetujui. Template tidak memerlukan messaging window 24 jam.

POST /api/v1/public/messages/send

Parameter​

ParameterTipeWajibKeterangan
phone_numberstringyaNomor telepon penerima dalam format E.164
channelstringyaHarus "whatsapp"
message_typestringyaHarus "template"
template.namestringyaNama template sesuai yang terdaftar di Meta
template.language.codestringyaKode bahasa (mis. "en_US", "id")
template.componentsarraytidakVariabel template untuk header, body, button
whatsapp_phone_number_idstringtidakTentukan nomor bisnis pengirim. Jika dikosongkan, ditentukan otomatis.

Contoh dengan Variabel Body​

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "template",
"whatsapp_phone_number_id": "clyyy9876543210",
"template": {
"name": "order_confirmation",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John Doe" },
{ "type": "text", "text": "INV-12345" }
]
}
]
}
}

Template dengan Media di Header​

Untuk template dengan header berupa gambar, video, atau dokumen, tambahkan komponen header berisi URL media.

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "template",
"template": {
"name": "promo_with_image",
"language": { "code": "id" },
"components": [
{
"type": "header",
"parameters": [
{ "type": "image", "image": { "link": "https://example.com/promo.jpg" } }
]
},
{
"type": "body",
"parameters": [
{ "type": "text", "text": "FLASH SALE" },
{ "type": "text", "text": "50%" }
]
}
]
}
}

Tipe media header yang didukung:

  • image - JPEG, PNG (maks 5MB)
  • video - MP4 (maks 16MB)
  • document - PDF, DOC (maks 100MB)

Template dengan Button URL Dinamis​

Untuk template dengan button URL dinamis (URL berisi {{1}}), tambahkan komponen button.

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "template",
"template": {
"name": "order_tracking",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "INV-12345" }
]
},
{
"type": "button",
"sub_type": "url",
"index": 0,
"parameters": [
{ "type": "text", "text": "tracking-abc123" }
]
}
]
}
}

Template dengan Button Salin Kode​

Untuk template marketing dengan button salin kode (kode kupon, kode promo).

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "template",
"template": {
"name": "promo_code",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "FLASH SALE" }
]
},
{
"type": "button",
"sub_type": "copy_code",
"index": 0,
"parameters": [
{ "type": "coupon_code", "coupon_code": "SAVE20OFF" }
]
}
]
}
}

Template Autentikasi (OTP)​

Untuk template autentikasi dengan kode OTP. Sertakan body sekaligus button salin kode.

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "template",
"template": {
"name": "otp_verification",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "123456" }
]
},
{
"type": "button",
"sub_type": "copy_code",
"index": 0,
"parameters": [
{ "type": "coupon_code", "coupon_code": "123456" }
]
}
]
}
}
peringatan

Untuk template autentikasi, selalu sertakan OTP di parameter body DAN di button salin kode agar pengguna bisa melihat sekaligus menyalin kodenya.

Referensi Parameter Komponen​

Tipe KomponenTipe ParameterKegunaan
headertext, image, video, documentVariabel atau media header
bodytext, currency, date_timeVariabel teks body
button (url)textAkhiran URL dinamis
button (copy_code)coupon_codeKode kupon/OTP yang disalin
info

Template harus sudah disetujui Meta sebelum digunakan. Field components bersifat opsional dan hanya diperlukan jika template Anda punya variabel.

Buat Template​

Buat template pesan WhatsApp baru lewat API (langkah 1 dari 2). Endpoint ini hanya menyimpan record template — panggil Ajukan Template berikutnya untuk mengirimnya ke Meta agar disetujui.

POST /api/v1/public/templates

Body Parameter​

ParameterTipeWajibKeterangan
template_namestringyaHanya huruf kecil, angka, dan underscore. Harus unik per bahasa.
categorystringya"MARKETING", "UTILITY", atau "AUTHENTICATION"
languagestringtidakKode bahasa (default "en_US"), mis. "id"
bodystringyaTeks body pesan. Gunakan {{1}}, {{2}}, ... untuk variabel (berurutan mulai dari 1).
variablesstring[]tidakContoh nilai untuk setiap placeholder {{n}}. Jumlahnya harus sama dengan jumlah placeholder.
headerobjecttidak{ type: TEXT|IMAGE|VIDEO|DOCUMENT, text, media_handle }. Header media memerlukan media_handle dari resumable upload (bukan URL publik).
footerstringtidakTeks footer, maks 60 karakter.
buttonsobject[]tidakArray berisi { type: QUICK_REPLY|URL|PHONE_NUMBER|OTP, text, url, phone_number }.
whatsapp_phone_number_idstringtidakTargetkan WABA dari nomor tertentu. Default ke nomor utama yang terhubung.
info

Response mengembalikan id template baru dengan status: "PENDING". Template belum dikirim ke Meta — teruskan id tersebut ke Ajukan Template. Untuk template AUTHENTICATION, Meta membuat body secara otomatis (tanpa footer; hanya button OTP).

Contoh Request​

curl -X POST "https://chat.api.co.id/api/v1/public/templates" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template_name": "order_update",
"category": "UTILITY",
"language": "id",
"body": "Halo {{1}}, pesanan {{2}} Anda sedang diproses.",
"variables": ["Budi", "INV-12345"]
}'

Response​

{
"success": true,
"data": {
"id": "cmxxx1234567890",
"template_name": "order_update",
"language": "id",
"status": "PENDING",
"category": "UTILITY",
"created_at": "2026-06-19T10:00:00.000Z"
}
}

Ajukan Template ke Meta​

Ajukan template yang sudah dibuat ke Meta untuk disetujui (langkah 2 dari 2). Gunakan id template yang dikembalikan oleh Buat Template.

POST /api/v1/public/templates/:id/submit

info

Jika berhasil, template mendapat meta_template_id dan tetap berstatus PENDING selama ditinjau Meta (beberapa menit hingga 24 jam). Cek Daftar Template / Detail Template secara berkala untuk melihat status akhirnya. Jika Meta menolak, response mengembalikan error dan template menjadi REJECTED beserta alasannya.

Contoh Request​

curl -X POST "https://chat.api.co.id/api/v1/public/templates/TEMPLATE_ID/submit" \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"success": true,
"data": {
"id": "cmxxx1234567890",
"template_name": "order_update",
"language": "id",
"status": "PENDING",
"category": "UTILITY",
"meta_template_id": "1234567890123456",
"submitted_at": "2026-06-19T10:00:05.000Z"
}
}

Daftar Template​

Ambil semua template pesan WhatsApp milik pengguna yang terautentikasi. Gunakan ini untuk mencari template yang tersedia beserta status persetujuannya.

GET /api/v1/public/templates

Query Parameter​

ParameterTipeWajibKeterangan
statusstringtidakFilter berdasarkan status: "APPROVED", "PENDING", "REJECTED", "PAUSED", "DISABLED"
categorystringtidakFilter berdasarkan kategori: "MARKETING", "UTILITY", "AUTHENTICATION"
whatsapp_phone_number_idstringtidakFilter template berdasarkan WABA dari nomor telepon
limitnumbertidakJumlah hasil maksimum (1-500, default 100)
offsetnumbertidakLewati N hasil untuk pagination (default 0)
info

Gunakan endpoint ini untuk mencari name template Anda dan memastikan statusnya APPROVED sebelum mengirim. Filter dengan status=APPROVED untuk melihat template yang siap dipakai saja.

Contoh Request​

curl -X GET "https://chat.api.co.id/api/v1/public/templates?status=APPROVED&limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"success": true,
"data": [
{
"id": "cmxxx1234567890",
"template_name": "otp_verification",
"language": "en_US",
"status": "APPROVED",
"category": "AUTHENTICATION",
"content": "{{1}} is your verification code.",
"header_type": null,
"header_content": null,
"footer_content": null,
"buttons": [
{
"type": "OTP",
"text": "Copy Code"
}
],
"variables": ["123456"],
"has_variables": true,
"created_at": "2026-04-03T09:52:02.297Z",
"updated_at": "2026-04-03T09:52:02.297Z"
}
],
"pagination": {
"total": 1,
"limit": 100,
"offset": 0,
"has_more": false
}
}

Detail Template​

Ambil satu template berdasarkan ID, termasuk semua komponen, button, dan metadata.

GET /api/v1/public/templates/:templateId

URL Parameter​

ParameterTipeWajibKeterangan
templateIdstringyaID template (CUID) dari endpoint daftar

Contoh Request​

curl -X GET "https://chat.api.co.id/api/v1/public/templates/cmxxx1234567890" \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"success": true,
"data": {
"id": "cmxxx1234567890",
"template_name": "promo_with_image",
"language": "id",
"status": "APPROVED",
"category": "MARKETING",
"content": "Hi {{1}}, get {{2}} off on your next purchase!",
"header_type": "IMAGE",
"header_content": "https://example.com/promo.jpg",
"footer_content": "Reply STOP to unsubscribe",
"buttons": [
{
"type": "URL",
"text": "Shop Now",
"url": "https://example.com/shop/{{1}}"
}
],
"variables": ["John", "50%"],
"has_variables": true,
"created_at": "2026-04-03T09:52:02.297Z",
"updated_at": "2026-04-03T09:52:02.297Z"
}
}

Kirim Media​

Kirim file gambar, dokumen, audio, atau video.

POST /api/v1/public/messages/send

Tipe Media yang Didukung per Channel​

WhatsApp

  • image — JPEG, PNG (maks 5MB)
  • document — PDF, DOC, DOCX (maks 100MB)
  • audio — MP3, OGG (maks 16MB)
  • video — MP4 (maks 16MB)

Instagram

  • image — JPEG, PNG
  • media_share — Bagikan media yang sudah ada

Messenger

  • image — JPEG, PNG, GIF
  • video — MP4
  • audio — MP3, WAV
  • file — Semua tipe file

Contoh​

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "image",
"media_url": "https://example.com/image.jpg",
"caption": "Check out this image!",
"whatsapp_phone_number_id": "clyyy9876543210"
}

Kirim Pesan Interaktif​

Kirim pesan interaktif WhatsApp dengan button CTA URL, Reply button, atau List Menu.

POST /api/v1/public/messages/send

info

Khusus WhatsApp: Pesan interaktif hanya tersedia untuk channel WhatsApp dan memerlukan messaging window 24 jam yang masih aktif.

Tipe Interaktif​

CTA URL Button

Kirim pesan dengan button URL yang bisa diklik. Cocok untuk mengarahkan customer ke website Anda, link pelacakan, atau resource eksternal.

Reply Button

Kirim pesan dengan maksimal 3 quick reply button. Cocok untuk survei, konfirmasi, atau memandu pilihan customer.

List Menu

Kirim pesan dengan list menu berisi hingga 10 section dan 10 item per section. Ideal untuk katalog produk, menu layanan, atau skenario apa pun yang membutuhkan pilihan terstruktur.

Contoh CTA URL Button​

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "interactive",
"whatsapp_phone_number_id": "clyyy9876543210",
"interactive": {
"type": "cta_url",
"body": {
"text": "Check out our latest products!"
},
"footer": {
"text": "Tap the button below"
},
"action": {
"name": "cta_url",
"parameters": {
"display_text": "Visit Store",
"url": "https://example.com/store"
}
}
}
}

Contoh Reply Button​

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "interactive",
"whatsapp_phone_number_id": "clyyy9876543210",
"interactive": {
"type": "button",
"body": {
"text": "How would you rate our service?"
},
"footer": {
"text": "Your feedback helps us improve"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": { "id": "rating_good", "title": "Good" }
},
{
"type": "reply",
"reply": { "id": "rating_ok", "title": "Okay" }
},
{
"type": "reply",
"reply": { "id": "rating_bad", "title": "Bad" }
}
]
}
}
}

Contoh List Menu​

{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "interactive",
"whatsapp_phone_number_id": "clyyy9876543210",
"interactive": {
"type": "list",
"body": {
"text": "Please select a service from our menu"
},
"header": {
"type": "text",
"text": "Our Services"
},
"footer": {
"text": "Tap the button to see options"
},
"action": {
"button": "View Menu",
"sections": [
{
"title": "Hair Services",
"rows": [
{
"id": "haircut",
"title": "Haircut",
"description": "Basic haircut service"
},
{
"id": "hair_coloring",
"title": "Hair Coloring",
"description": "Full hair coloring service"
}
]
},
{
"title": "Spa Services",
"rows": [
{
"id": "massage",
"title": "Massage",
"description": "60-minute relaxing massage"
},
{
"id": "facial",
"title": "Facial Treatment",
"description": "Deep cleansing facial"
}
]
}
]
}
}
}

Parameter​

ParameterTipeWajibKeterangan
interactive.typestringya"cta_url" untuk button URL, "button" untuk reply button, atau "list" untuk list menu
interactive.body.textstringyaTeks utama pesan (maks 1024 karakter)
interactive.headerobjecttidakHeader opsional. Untuk tipe list: hanya teks (maks 60 karakter). Untuk tipe lain: text, image, video, atau document
interactive.footer.textstringtidakTeks footer opsional (maks 60 karakter)
interactive.actionobjectyaKonfigurasi aksi (parameter CTA URL, array button, atau section list)
interactive.action.buttonstringtidakUntuk tipe list: teks button untuk membuka list menu (maks 20 karakter)
interactive.action.sectionsarraytidakUntuk tipe list: array section (1-10 section)
sections[].titlestringtidakJudul section (maks 24 karakter)
sections[].rowsarrayyaArray item row di dalam section (1-10 row)
rows[].idstringyaIdentifier unik untuk row (maks 200 karakter). Dikembalikan di webhook saat pengguna memilih item ini
rows[].titlestringyaJudul row yang ditampilkan ke pengguna (maks 24 karakter)
rows[].descriptionstringtidakDeskripsi row (maks 72 karakter)

Batasan​

ElemenBatas
Teks body1024 karakter
Teks header60 karakter
Teks footer60 karakter
Judul button20 karakter
Teks tampilan CTA20 karakter
Reply buttonMaksimal 3 button
ID button256 karakter
Batasan List Menu
Teks button list20 karakter
Section list1-10 section
Row per section1-10 row
Judul section24 karakter
ID row200 karakter
Judul row24 karakter
Deskripsi row72 karakter

Indikator Mengetik​

Kirim indikator mengetik ("sedang mengetik...") ke customer sebelum mengirim pesan.

POST /api/v1/public/conversations/:customerIdentifier/typing

URL Parameter​

ParameterTipeWajibKeterangan
customerIdentifierstringyaCustomer ID (CUID), nomor telepon, atau username Instagram

Request Body (Opsional)​

ParameterTipeWajibKeterangan
channelstringtidak"whatsapp" atau "instagram". Terdeteksi otomatis jika tidak diisi.
whatsapp_phone_number_idstringtidakID nomor telepon WhatsApp. Tentukan nomor bisnis mana yang mengirim indikator mengetik.
instagram_account_idstringtidakID akun Instagram. Wajib jika customer punya percakapan dengan lebih dari satu akun Instagram.
info

Rate Limit: Maksimal 1 request per 3 detik per customer. Jika terlampaui, API mengembalikan 429 dengan header Retry-After.

Contoh Request​

curl -X POST "https://chat.api.co.id/api/v1/public/conversations/628123456789/typing" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel": "whatsapp",
"whatsapp_phone_number_id": "clyyy9876543210"
}'

Contoh Instagram​

// Send typing to Instagram customer
POST /api/v1/public/conversations/ig_username/typing
Content-Type: application/json

{
"channel": "instagram",
"instagram_account_id": "your_ig_account_id"
}

Response​

{
"success": true,
"data": {
"customer_id": "clxxx1234567890",
"channel": "whatsapp",
"typing_sent": true,
"timestamp": "2026-01-26T10:30:00.000Z"
}
}

Kode Error​

KodeKeterangan
NotFoundCustomer tidak ditemukan
WindowClosedMessaging window 24 jam sudah berakhir
RateLimitExceededMaks 1 request per 3 detik per customer
ConfigurationErrorChannel tidak tersedia untuk customer
ConnectionErrorAkun WhatsApp/Instagram terputus
AmbiguousAccountCustomer punya lebih dari satu akun IG, isi instagram_account_id

Tandai Sudah Dibaca​

Tandai pesan sebagai sudah dibaca dan kirim read receipt ke customer.

POST /api/v1/public/messages/:messageId/read

URL Parameter​

ParameterTipeWajibKeterangan
messageIdstringyaID pesan (CUID) yang akan ditandai sudah dibaca
info

Penting: Hanya pesan masuk (inbound) yang bisa ditandai sudah dibaca. Mencoba menandai pesan keluar (outbound) akan mengembalikan error validasi.

peringatan

WhatsApp: Memerlukan WhatsApp Business Account yang terhubung. Pesan harus memiliki wamId yang valid.

info

Multi-Nomor: Read receipt otomatis dikirim lewat nomor WhatsApp yang sama dengan yang menerima pesan. Tidak perlu parameter tambahan.

Channel yang Didukung​

  • WhatsApp: Mengirim read receipt lewat WhatsApp API
  • Instagram: Mengirim mark_seen lewat Instagram API
  • Messenger: Tidak didukung lewat Public API

Contoh Request​

curl -X POST "https://chat.api.co.id/api/v1/public/messages/msg_xyz789/read" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"

Response Sukses​

{
"success": true,
"data": {
"message_id": "msg_xyz789",
"status": "read",
"channel": "whatsapp",
"updated_at": "2026-01-27T10:30:00.000Z"
}
}

Response Error​

404 - Pesan Tidak Ditemukan

{
"error": {
"code": "NotFound",
"message": "Message not found"
}
}

400 - Error Validasi (Pesan Outbound)

{
"error": {
"code": "ValidationError",
"message": "Only inbound messages can be marked as read"
}
}

400 - Error Konfigurasi (WhatsApp Belum Terhubung)

{
"error": {
"code": "ConfigurationError",
"message": "Cannot send read receipt: missing configuration"
}
}

Coba langsung​

tip

Tekan Try it lalu tempel API key Anda (kc_live_...) ke kolom API key (Bearer). Dapatkan key dari API Keys. Request dijalankan ke akun live Anda, jadi endpoint yang mengirim, membuat, atau menghapus akan memengaruhi data sungguhan.

  • POST/api/v1/public/messages/sendSend Message
  • GET/api/v1/public/templatesList Templates
  • POST/api/v1/public/templatesCreate Template
  • POST/api/v1/public/templates/{id}/submitSubmit Template to Meta
  • GET/api/v1/public/templates/{templateId}Get Template Detail
  • POST/api/v1/public/conversations/{customerIdentifier}/typingTyping Indicator
  • POST/api/v1/public/messages/{messageId}/readMark as Read
Apakah halaman ini membantu?