Lewati ke konten utama

Percakapan

Daftar Percakapan​

Ambil semua percakapan (customer) beserta pesan terakhir, jumlah pesan belum dibaca, dan info channel.

GET /api/v1/public/conversations

Query Parameter​

ParameterTipeWajibKeterangan
limitnumbertidakJumlah percakapan yang dikembalikan (1-200, default 50)
cursorstringtidakCustomer ID untuk pagination (dari next_cursor di response sebelumnya)
channelstringtidakFilter berdasarkan channel: "whatsapp", "instagram", atau "messenger"

Contoh Request​

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

Response​

{
"success": true,
"data": [
{
"customer_id": "clxxx1234567890",
"phone_number": "628123456789",
"name": "John Doe",
"email": "[email protected]",
"instagram_username": null,
"tags": ["vip", "loyal"],
"is_window_active": true,
"window_expires_at": "2026-01-08T10:30:00.000Z",
"unread_count": 3,
"whatsapp_phone_number": {
"id": "clyyy9876543210",
"display_phone_number": "+62 812-3456-7890",
"verified_name": "My Business"
},
"instagram": null,
"messenger": null,
"last_message": {
"id": "msg_xyz789",
"content": "Hello, I need help!",
"message_type": "TEXT",
"direction": "INBOUND",
"status": "DELIVERED",
"timestamp": "2026-01-07T10:30:00.000Z"
},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-07T10:30:00.000Z"
}
],
"pagination": {
"has_more": true,
"next_cursor": "clxxx1234567890",
"limit": 50
}
}
info

Gunakan next_cursor dari objek pagination sebagai query parameter cursor untuk mengambil halaman berikutnya.

Ambil Pesan​

Ambil riwayat pesan untuk percakapan/customer tertentu.

GET /api/v1/public/conversations/:customerId/messages

URL Parameter​

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

Query Parameter​

ParameterTipeWajibKeterangan
limitnumbertidakJumlah pesan yang dikembalikan (1-200, default 50)
cursorstringtidakString tanggal ISO untuk pagination (dari next_cursor di response sebelumnya)
directionstringtidakFilter berdasarkan arah: "inbound" atau "outbound"

Contoh Request​

curl -X GET "https://chat.api.co.id/api/v1/public/conversations/628123456789/messages?limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"success": true,
"data": {
"customer": {
"id": "clxxx1234567890",
"phone_number": "628123456789",
"name": "John Doe",
"instagram_username": null
},
"messages": [
{
"id": "msg_abc123",
"message_type": "TEXT",
"direction": "INBOUND",
"content": "Hello, I need help!",
"media_url": null,
"status": "READ",
"timestamp": "2026-01-07T10:30:00.000Z",
"source": "WHATSAPP_APP",
"wam_id": "wamid.xxx",
"whatsapp_phone_number_id": "clyyy9876543210",
"error": null
},
{
"id": "msg_def456",
"message_type": "TEXT",
"direction": "OUTBOUND",
"content": "Hi! How can I help you?",
"media_url": null,
"status": "DELIVERED",
"timestamp": "2026-01-07T10:31:00.000Z",
"source": "API",
"wam_id": "wamid.yyy",
"whatsapp_phone_number_id": "clyyy9876543210",
"error": null
}
]
},
"pagination": {
"has_more": false,
"next_cursor": null,
"limit": 50
}
}
info

Pesan dikembalikan dalam urutan kronologis terbalik (terbaru lebih dulu). Gunakan parameter cursor dengan nilai next_cursor untuk memuat pesan yang lebih lama.

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.

  • GET/api/v1/public/conversationsList Conversations
  • GET/api/v1/public/conversations/{customerId}/messagesGet Messages
Apakah halaman ini membantu?