Percakapan
Daftar Percakapan
Ambil semua percakapan (customer) beserta pesan terakhir, jumlah pesan belum dibaca, dan info channel.
GET /api/v1/public/conversations
Query Parameter
| Parameter | Tipe | Wajib | Keterangan |
|---|---|---|---|
limit | number | tidak | Jumlah percakapan yang dikembalikan (1-200, default 50) |
cursor | string | tidak | Customer ID untuk pagination (dari next_cursor di response sebelumnya) |
channel | string | tidak | Filter berdasarkan channel: "whatsapp", "instagram", atau "messenger" |
Contoh Request
- cURL
- JavaScript
- Python
curl -X GET "https://chat.api.co.id/api/v1/public/conversations?limit=50&channel=whatsapp" \
-H "Authorization: Bearer YOUR_API_KEY"
const response = await fetch("https://chat.api.co.id/api/v1/public/conversations?limit=50", {
headers: {
"Authorization": "Bearer YOUR_API_KEY"
}
});
const { data, pagination } = await response.json();
import requests
response = requests.get(
"https://chat.api.co.id/api/v1/public/conversations",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={"limit": 50, "channel": "whatsapp"}
)
result = response.json()
conversations = result["data"]
pagination = result["pagination"]
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
| Parameter | Tipe | Wajib | Keterangan |
|---|---|---|---|
customerId | string | ya | Customer ID (CUID), nomor telepon, atau username Instagram |
Query Parameter
| Parameter | Tipe | Wajib | Keterangan |
|---|---|---|---|
limit | number | tidak | Jumlah pesan yang dikembalikan (1-200, default 50) |
cursor | string | tidak | String tanggal ISO untuk pagination (dari next_cursor di response sebelumnya) |
direction | string | tidak | Filter berdasarkan arah: "inbound" atau "outbound" |
Contoh Request
- cURL (nomor telepon)
- cURL (ID)
- JavaScript
- Python
curl -X GET "https://chat.api.co.id/api/v1/public/conversations/628123456789/messages?limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X GET "https://chat.api.co.id/api/v1/public/conversations/clxxx1234567890/messages?limit=50&direction=inbound" \
-H "Authorization: Bearer YOUR_API_KEY"
const customerId = "628123456789"; // or customer CUID
const response = await fetch(
`https://chat.api.co.id/api/v1/public/conversations/${customerId}/messages?limit=50`,
{
headers: { "Authorization": "Bearer YOUR_API_KEY" }
}
);
const { data, pagination } = await response.json();
const { customer, messages } = data;
import requests
customer_id = "628123456789" # or customer CUID
response = requests.get(
f"https://chat.api.co.id/api/v1/public/conversations/{customer_id}/messages",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={"limit": 50}
)
result = response.json()
messages = result["data"]["messages"]
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?