D
API Reference

Chat Inbound

Endpoint chat inbound — callback_message (webhook WA gateway), chat_inbox, chat_list, chat_markread, chat_newinbox, chat_inboxdetail, chat_inbox_position. Detail request param dan response.

Endpoint untuk menerima dan membaca pesan masuk. callback_message adalah webhook yang dipanggil WA gateway; sisanya dipanggil frontend.

POST /v1/callback_message

Webhook yang dipanggil WhatsApp gateway :5002 saat pesan masuk atau status berubah. Skip auth (excluded path).

Handler: handlers/chat_callback.go:89 CallbackMessage

Payload: shared Payload struct (handlers/chat.go:22-72)

Branching: handler punya 2 path berdasarkan Result + Report:

ResultReportPath
truefalseNew message — proses pesan masuk
truetrueStatus update — update status_ack
false(any)Reject — {"result": false, "message": "Callback result false"}

Request body (new message path)

FieldTipeWajibDeskripsi
instanceIDstring✅Device instance ID
resultbool✅Harus true
reportbool✅false untuk new message
textstring❌Konten pesan (text)
numberstring✅Nomor pengirim (62812...@s.whatsapp.net / ...@g.us)
fromMebool❌Apakah pesan dari device sendiri
idstring❌Pesan ID WA
namestring❌Nama pengirim
timestampint64❌Timestamp WA
typestring❌Jenis pesan (chat/image/video/document/audio/extendedtext)
latitudestring❌Lat (untuk location)
longitudestring❌Lng (untuk location)
captionstring❌Caption media
matchedTextstring❌Text match (link preview)
quoteMsgstring❌Pesan yang di-quote
profilepicstring❌URL foto profil
participantnamestring❌Nama participant (group)
rawMessagestring❌Raw message blob
locationAddressstring❌Alamat lokasi
locationNamestring❌Nama lokasi

Response (new message, sukses)

json
{
  "result": true,
  "data": {
    "newChatInbox": { /* ChatInboxStruct */ },
    "chat_list": { /* ChatListStruct */ },
    "chat_order": { /* ChatOrderStruct */ },
    "handle_gudang": { /* HandleGudangStruct */ },
    "customer": { /* CustomerStruct */ },
    "history": { /* ChatHistoryStruct */ }
  }
}

Response (new message, error)

json
{"result": false, "message": "<err>"}

Request body (status update path)

FieldTipeWajibDeskripsi
numberstring✅Nomor pengirim
instanceIDstring✅Device instance
idstring✅Pesan ID
statusstring✅Status baru: sent/delivered/viewed/played
resultbool✅Harus true
reportbool✅Harus true

Response (status update, sukses)

json
{"result": true, "message": "updated status"}

Response (status update, error)

KondisiBody
Field wajib kosong{"result": false, "message": "missing required fields"}
Format nomor invalid{"result": false, "message": "invalid number format"}
Status tidak valid{"result": false, "message": "message update not valid"}
Update gagal{"result": false, "message": "<err>"}
BodyParser gagal400 {"error": "<err>"}

POST /v1/chat_inbox

Ambil inbox pesan untuk satu percakapan.

Handler: handlers/chat_live.go:216 GetInbox

Auth: JWT wajib

Request body

FieldTipeWajibDeskripsi
nohpstring✅Nomor customer
instancestring✅Device instance
teamstring✅Team ID
limitstring❌Jumlah pesan
offsetstring❌Offset pagination
customerIdstring❌Customer ID filter

Response (sukses)

json
{
  "result": true,
  "data": [/* ChatInboxStruct[] */],
  "chat_list": {/* ChatListStruct */},
  "chat_order": {/* ChatOrderStruct */},
  "customer": {/* CustomerStruct */},
  "chat_device": {/* DeviceStruct */},
  "handle_gudang": {/* HandleGudangStruct */},
  "history": {/* ChatHistoryStruct */}
}

Response (error)

json
{"result": false, "message": "<err>"}

Error sources: GetTeam, GetDevice, GetChatInbox, GetChatlistBynohp.


POST /v1/chat_inbox_position

Ambil posisi (offset) pesan tertentu dalam inbox.

Handler: handlers/chat_live.go:425 GetMessagePosition

Request body

FieldTipeWajibDeskripsi
pesan_idstring✅Pesan ID target
nohpstring✅Nomor customer
instancestring✅Device instance

Response (sukses)

json
{
  "result": true,
  "offset": 42,
  "waktu": "2024-01-15 10:30"
}

Response (error)

KondisiBody
BodyParser gagal{"result": false, "message": "<err>"}
Pesan tidak ditemukan{"result": false, "message": "pesan tidak ditemukan"}
Count gagal{"result": false, "message": "<err>"}

POST /v1/chat_list

Ambil daftar percakapan (chat list).

Handler: handlers/chat_live.go:488 GetListChat

Request body

FieldTipeWajibDeskripsi
nohpstring✅(tidak dipakai langsung, tapi wajib di struct)
instancestring✅Device instance
teamstring✅Team ID
not_group*string❌Filter group chat ("true" = exclude group)
keywordstring❌Search keyword
statusstring❌Filter status chat
searchstring❌Search term
searchTypestring❌Search type
filterobject❌Filter data kompleks

Response (sukses)

json
{
  "result": true,
  "data": [/* ChatListStruct[] */],
  "indexlist": ["id1", "id2"]
}

Response (error)

json
{"result": false, "message": "<err>"}

Error sources: GetTeam, GetChatList, GetChatlistOrderAttrsBatch.


POST /v1/chat_markread

Tandai pesan sebagai sudah dibaca.

Handler: handlers/chat_live.go:1369 MarkAsReadMessage

Request body

FieldTipeWajibDeskripsi
nohpstring✅Nomor customer
instancestring✅Device instance
teamstring✅Team ID

Response (sukses)

json
{"result": true, "message": "success mark as read"}

Response (error)

json
{"result": false, "message": "<err>"}

POST /v1/chat_newinbox

Ambil pesan baru untuk percakapan (mirip chat_inbox tapi untuk pesan yang belum dilihat).

Handler: handlers/chat_live.go:114 GetNewMessage

Request body

FieldTipeWajibDeskripsi
chatIdstring❌Chat ID spesifik
nohpstring✅Nomor customer
instancestring✅Device instance
teamstring✅Team ID
customerIdstring❌Customer ID

Response (sukses)

Shape sama dengan chat_inbox — 8 key (result, data, chat_list, chat_order, customer, chat_device, handle_gudang, history).

Response (error)

json
{"result": false, "message": "<err>"}

Error sources: GetTeam, GetDevice, GetSingleChatInbox, customer fetch, GetChatlistBynohp, history fetch.


POST /v1/chat_inboxdetail

Ambil detail satu pesan inbox.

Handler: handlers/chat_live.go:403 GetInboxDetail

Request body

FieldTipeWajibDeskripsi
chatInboxIdstring✅ChatInbox ID

Response (sukses)

json
{
  "result": true,
  "data": {/* ChatInboxStruct */}
}

Response (error)

json
{"result": false, "message": "<err>"}

Kembali ke