D
API Reference

API Reference

Daftar lengkap endpoint POST /v1/* di backend-go. Dikelompokkan per fungsi — chat inbound, chat lifecycle, send outbound, notif, broadcast, ticket. Plus varian tenant _admin dan _crm.

backend-go menyajikan ~70 endpoint POST /v1/* dalam 3 varian tenant. Semua route memakai JSON body (kecuali callback_message dan escalation yang memakai multipart).

Autentikasi

KategoriAuthPengecualian
Default (/v1/*)✅ JWT Bearer wajibcallback_message dipanggil WA gateway, skip auth
Admin (/v1/*_admin)❌ skip authSemua 16 route admin di excluded paths
CRM (/v1/*_crm)❌ skip authSemua 16 route crm di excluded paths
IP allowlist❌ skip authIP di ALLOWED_IPS bypass semua route

Lihat Auth & JWT untuk detail middleware.

Header umum

http
Authorization: Bearer <jwt>
Content-Type: application/json

Untuk escalation (request-escalate, request-escalate):

http
Authorization: Bearer <jwt>
Content-Type: multipart/form-data

Response envelope

Tidak ada standardisasi — shape berbeda per handler. Pola umum:

json
// Sukses
{"result": true, "message": "...", "data": {...}}

// Error bisnis (status 200)
{"result": false, "message": "..."}

// Error validasi (status 422)
{"errors": [{"field": "...", "tag": "...", "message": "..."}]}

// Error auth (status 401)
{"status": "error", "message": "Unauthenticated"}

// Broadcast scheduler (pengecualian — pakai "status" bukan "result")
{"status": "success", "message": "..."}

Grup endpoint

GrupHalamanEndpointTenant varian
Chat InboundChat Inboundcallback_message, chat_inbox, chat_inbox_position, chat_list, chat_markread, chat_newinbox, chat_inboxdetail✅ admin, crm
Chat LifecycleChat Lifecyclehandle_chat, chat_finish, chat_open, chat_pending, chat_move, chats/request-escalate, chats/finish-escalate✅ admin, crm
Send OutboundSend Outboundsend_message, send_image, send_document, send_audio, send_video, send_link, send_location, send_express✅ admin, crm
NotificationsNotificationsreadall_notif, get_notif, get_totalnotif, markread_notif, getdetail_notif❌
BroadcastBroadcastsend_broadcast, broadcast/scheduler✅ crm
TicketTicketchange_ticket_status❌ (CRM context)
Tenant VariantsTenant VariantsPerbedaan _admin / _crm vs default—

Struktur payload

Sebagian besar handler memakai shared struct Payload (handlers/chat.go:22-72) atau ChatLivePayload (handlers/chat_live.go:34-61). Lihat per-halaman untuk field yang dipakai.

Daftar endpoint lengkap

Default tenant

EndpointGrup
POST /v1/callback_messageInbound (webhook WA gateway)
POST /v1/chat_inboxInbound
POST /v1/chat_inbox_positionInbound
POST /v1/chat_listInbound
POST /v1/chat_markreadInbound
POST /v1/chat_newinboxInbound
POST /v1/chat_inboxdetailInbound
POST /v1/handle_chatLifecycle
POST /v1/chat_finishLifecycle
POST /v1/chat_openLifecycle
POST /v1/chat_pendingLifecycle
POST /v1/chat_moveLifecycle
POST /v1/chat_requesthandleLifecycle (alias chats/request-escalate)
POST /v1/chat_finishhandleLifecycle (alias chats/finish-escalate)
POST /v1/chats/request-escalateLifecycle
POST /v1/chats/finish-escalateLifecycle
POST /v1/send_messageOutbound
POST /v1/send_imageOutbound
POST /v1/send_documentOutbound
POST /v1/send_audioOutbound
POST /v1/send_videoOutbound
POST /v1/send_linkOutbound
POST /v1/send_locationOutbound
POST /v1/send_expressOutbound
POST /v1/readall_notifNotif
POST /v1/get_notifNotif
POST /v1/get_totalnotifNotif
POST /v1/markread_notifNotif
POST /v1/getdetail_notifNotif
POST /v1/send_broadcastBroadcast
POST /v1/broadcast/schedulerBroadcast
POST /v1/change_ticket_statusTicket

Admin tenant (_admin suffix)

16 route — mirror dari default untuk chat inbound + lifecycle + send. Skip auth. Lihat Tenant Variants.

CRM tenant (_crm suffix)

16 route — mirror default + broadcast crm + change_ticket_status. Skip auth. Saat ini panic (MongoClientCrm nil). Lihat Tenant Variants dan Tech Debt.

Catatan

  • Semua endpoint POST — tidak ada GET/PUT/DELETE di /v1
  • Route naming snake_case, kecuali chats/request-escalate dan chats/finish-escalate (kebab-case + slash)
  • Tidak ada versioning selain /v1 — tidak ada /v2
  • Root GET / return {"Dazo":"App"} (health check, no auth)