Semua endpoint mengembalikan JSON
{ success, data } atau
{ success:false, error }. Endpoint bertanda Perlu API Key butuh header
x-api-key: API_KEY atau Authorization: Bearer API_KEY — kirim
lewat query ?key= khusus untuk tag img (foto pengaduan).
Kalau webSetting.apiKey di config.json masih kosong, endpoint tsb
terbuka tanpa proteksi. Endpoint kirim/edit pesan menjawab 503 selama bot belum
tersambung ke WhatsApp.
Status & Pairing
GET/api/public-infoPublik
Nama bot & koperasi — aman dibuka siapa saja.
curl http://localhost:3000/api/public-info
GET/api/statusPublik
Status koneksi WhatsApp bot saat ini.
curl http://localhost:3000/api/status
GET/api/qrPublik
Pairing code / QR image (data URL) untuk login WhatsApp. Dipakai /qr.html.
curl http://localhost:3000/api/qr
GET/api/verify-keyPerlu API Key
Cek cepat validitas API Key — dipakai layar login /index.html, /logs.html & /pengaduan.html.
curl http://localhost:3000/api/verify-key \
-H "x-api-key: API_KEY_ANDA"
Log Aplikasi
GET/api/logsPerlu API Key
Isi file log aplikasi (logs.log/stderr.log/stdout.log, mana yang ada) dari folder aplikasi — bukan seluruh file, cuma bagian terakhirnya. Query opsional: ?lines= (default 300, maks 2000). Dipakai /logs.html supaya bisa lihat log tanpa File Manager.
curl "http://localhost:3000/api/logs?lines=200" \
-H "x-api-key: API_KEY_ANDA"
Kirim Pesan (WA Sender)
POST/api/send-textPerlu API Key
Body JSON: { number, message }. Nomor boleh format bebas (dinormalisasi otomatis) atau JID lengkap.
curl -X POST http://localhost:3000/api/send-text \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"number":"628123456789","message":"Halo dari API!"}'
POST/api/send-imagePerlu API Key
Multipart form-data: number, caption (opsional), image (file).
curl -X POST http://localhost:3000/api/send-image \
-H "x-api-key: API_KEY_ANDA" \
-F "number=628123456789" \
-F "caption=Halo!" \
-F "image=@/path/ke/foto.jpg"
POST/api/send-documentPerlu API Key
Multipart form-data: number, caption (opsional), document (file, maks. 25MB).
curl -X POST http://localhost:3000/api/send-document \
-H "x-api-key: API_KEY_ANDA" \
-F "number=628123456789" \
-F "document=@/path/ke/dokumen.pdf"
POST/api/edit-messagePerlu API Key
Body JSON: { jid, key, text }. Mengedit pesan yang SUDAH terkirim (harus dikirim oleh bot ini sendiri) — key didapat dari field data.key pada respons /api/send-text, /api/send-image, atau /api/send-document sebelumnya. Dipakai fitur edit di /index.html.
curl -X POST http://localhost:3000/api/edit-message \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"jid":"628123456789@s.whatsapp.net","key":{"id":"...","remoteJid":"628123456789@s.whatsapp.net","fromMe":true},"text":"Pesan yang sudah diedit"}'
Pemantauan Pengaduan
GET/api/pengaduanPerlu API Key
Query opsional: ?status=Baru|Diproses|Selesai dan ?q= (cari ID/nama/alamat/isi aduan). Balasan menyertakan meta berisi rekap jumlah per status.
curl http://localhost:3000/api/pengaduan?status=Baru \
-H "x-api-key: API_KEY_ANDA"
GET/api/pengaduan/:idPerlu API Key
Detail lengkap satu pengaduan, termasuk riwayat tanggapan dan fotoUrls.
curl http://localhost:3000/api/pengaduan/PGD-20260908-A1B2 \
-H "x-api-key: API_KEY_ANDA"
GET/api/pengaduan/:id/foto/:indexPerlu API Key
File foto lampiran ke-index (mulai dari 0). Boleh lewat ?key= di query supaya bisa dipakai langsung sebagai src tag img.
curl "http://localhost:3000/api/pengaduan/PGD-20260908-A1B2/foto/0?key=API_KEY_ANDA" -o foto.jpg
POST/api/pengaduan/:id/statusPerlu API Key
Body JSON: { status: "Baru"|"Diproses"|"Selesai" }. Pelapor otomatis diberi tahu lewat WhatsApp.
curl -X POST http://localhost:3000/api/pengaduan/PGD-20260908-A1B2/status \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"status":"Diproses"}'
POST/api/pengaduan/:id/tanggapanPerlu API Key
Body JSON: { teks }. Tanggapan tersimpan sebagai riwayat & otomatis terkirim ke pelapor lewat WhatsApp.
curl -X POST http://localhost:3000/api/pengaduan/PGD-20260908-A1B2/tanggapan \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"teks":"Sudah kami tindaklanjuti, terima kasih."}'
GET/api/pengaduan/exportPerlu API Key
Download rekap semua pengaduan. Query: ?format=csv (default) atau ?format=xlsx. Dipakai tombol Export di /dashboard.html.
curl "http://localhost:3000/api/pengaduan/export?format=xlsx&key=API_KEY_ANDA" -o pengaduan.xlsx
Dashboard & Audit Log
GET/api/statsPerlu API Key
Data untuk grafik: total, rekap per status, dan tren 6 bulan terakhir. Dipakai /dashboard.html.
curl http://localhost:3000/api/stats -H "x-api-key: API_KEY_ANDA"
GET/api/audit-logPerlu API Key
Riwayat aksi admin (ubah status, tanggapan, broadcast). Query opsional: ?limit= (default 200, maks 2000).
curl http://localhost:3000/api/audit-log?limit=50 -H "x-api-key: API_KEY_ANDA"
GET/api/telegram/testPerlu API Key
Cek token+chatId Telegram valid (telegramSetting di config.json). Dipakai /dashboard.html.
curl http://localhost:3000/api/telegram/test -H "x-api-key: API_KEY_ANDA"
GET/api/telegram/chatsPerlu API Key
Daftar chat/grup Telegram yang baru-baru ini kirim pesan ke bot (lewat getUpdates) -- supaya chatId bisa dipilih dari daftar di /dashboard.html, tidak perlu cari manual.
curl http://localhost:3000/api/telegram/chats -H "x-api-key: API_KEY_ANDA"
POST/api/telegram/chat-idPerlu API Key
Body JSON: { chatId }. Simpan chatId terpilih ke config.json.
curl -X POST http://localhost:3000/api/telegram/chat-id \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"chatId":"-1001234567890"}'
Kontak & Broadcast
GET/api/contacts/personalPerlu API Key
Nomor pribadi yang pernah chat bot (dikumpulkan otomatis, bukan kontak HP).
curl http://localhost:3000/api/contacts/personal -H "x-api-key: API_KEY_ANDA"
GET/api/contacts/groupsPerlu API Key
Semua grup WA yang bot ini ikuti, diambil live dari WhatsApp (bukan cache). Butuh bot dalam status tersambung.
curl http://localhost:3000/api/contacts/groups -H "x-api-key: API_KEY_ANDA"
POST/api/broadcastPerlu API Key
Body JSON: { targets: [jid,...], message }. Mengembalikan { jobId } segera -- pesan dikirim satu per satu di background dengan jeda antar kiriman (hindari risiko banned).
curl -X POST http://localhost:3000/api/broadcast \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"targets":["628123456789@s.whatsapp.net"],"message":"Pengumuman..."}'
GET/api/broadcast/:jobIdPerlu API Key
Progres pengiriman broadcast: { total, sent, failed, done, results }.
curl http://localhost:3000/api/broadcast/bc_abc123 -H "x-api-key: API_KEY_ANDA"
Backup Telegram (Mapping WA -> Telegram)
GET/api/bridge/mappingsPerlu API Key
Daftar mapping grup/chat WA yang di-backup ke Telegram.
curl http://localhost:3000/api/bridge/mappings -H "x-api-key: API_KEY_ANDA"
POST/api/bridge/mappingsPerlu API Key
Body JSON: { waJid, waName, telegramChatId, telegramName, enabled }. Tambah/perbarui mapping -- upsert berdasarkan waJid.
curl -X POST http://localhost:3000/api/bridge/mappings \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"waJid":"628111@g.us","waName":"Grup Pengurus","telegramChatId":"-100999","telegramName":"Backup Pengurus","enabled":true}'
DELETE/api/bridge/mappings/:waJidPerlu API Key
Hapus mapping. waJid di-encode (mis. 628111%40g.us).
curl -X DELETE "http://localhost:3000/api/bridge/mappings/628111%40g.us" -H "x-api-key: API_KEY_ANDA"
Backup Project
POST/api/backup/send-nowPerlu API Key
Zip seluruh project (kode+config+data+media, kecuali session & node_modules) dan kirim ke Telegram sekarang juga -- di luar jadwal otomatis (koperasiSetting.autoBackupIntervalHours). Butuh Telegram sudah dikonfigurasi.
curl -X POST http://localhost:3000/api/backup/send-now -H "x-api-key: API_KEY_ANDA"
Setelan & Admin
GET/api/settingsPerlu API Key
Status mode public & allowGroup saat ini.
curl http://localhost:3000/api/settings -H "x-api-key: API_KEY_ANDA"
POST/api/settingsPerlu API Key
Body JSON: { public?, allowGroup? } (boolean, kirim salah satu atau keduanya).
curl -X POST http://localhost:3000/api/settings \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"allowGroup":false}'
GET/api/adminsPerlu API Key
Daftar nomor admin/pengurus bot.
curl http://localhost:3000/api/admins -H "x-api-key: API_KEY_ANDA"
POST/api/adminsPerlu API Key
Body JSON: { number }. Format bebas (dinormalisasi otomatis, sama seperti .addadmin).
curl -X POST http://localhost:3000/api/admins \
-H "x-api-key: API_KEY_ANDA" \
-H "Content-Type: application/json" \
-d '{"number":"0812-3456-7890"}'
DELETE/api/admins/:numberPerlu API Key
Hapus admin (nomor sudah dalam format 62xxx). Tidak bisa menghapus admin terakhir.
curl -X DELETE http://localhost:3000/api/admins/6281234567890 -H "x-api-key: API_KEY_ANDA"
Buku Kontak
GET/api/contactbookPerlu API Key
Daftar kontak (profileName, savedName, groups). Query opsional: ?q= (cari nama/nomor), ?group= (filter per JID grup).
curl http://localhost:3000/api/contactbook?q=budi -H "x-api-key: API_KEY_ANDA"
POST/api/contactbook/sync-groupsPerlu API Key
Tarik semua peserta dari semua grup (live dari WA) dan catat ke buku kontak. Nama menyusul otomatis lewat event WhatsApp, tidak instan.
curl -X POST http://localhost:3000/api/contactbook/sync-groups -H "x-api-key: API_KEY_ANDA"