📲 WA Gateway · Docs

Dokumentasi API

Kirim pesan WhatsApp lewat HTTP, termasuk tombol interaktif (salin kode, link, balas cepat, daftar pilihan). Cara pakainya mirip Fonnte: satu token per device.

1. Autentikasi

Ambil token di Dashboard → Salin token. Kirim lewat header Authorization.

Authorization: TOKEN_DEVICE_KAMU

Format Bearer TOKEN, header X-Token, atau parameter token juga diterima. Base URL:

Body boleh application/json atau x-www-form-urlencoded (field buttons kirim sebagai string JSON).

2. Cek status device

GET/api/device

{ "status": true, "device": "a1b2c3d4", "name": "Toko", "status": "open", "phone": "6281234567890" }

3. Kirim pesan

POST/api/send

FieldWajibKeterangan
targetyaNomor tujuan. Format 08xx, 628xx, atau ID grup [email protected]. Banyak nomor dipisah koma (maks 200, diproses di background dengan jeda acak).
messageya*Isi pesan. Mendukung format WhatsApp (*tebal*, _miring_). *Boleh kosong jika kirim media.
footertidakTeks kecil di bawah pesan (untuk pesan bertombol).
buttonstidakArray tombol, lihat bagian 4. Maks 5.
image_urltidakGambar header (untuk pesan bertombol) atau gambar biasa.
file_urltidakURL dokumen/file. filename untuk nama file.
delaytidakJeda antar target, detik. Contoh 5 atau 3-8 (acak). Default dari .env.
typingtidakfalse untuk mematikan efek "mengetik…".

Respons sukses:

{ "status": true, "detail": "sent", "id": ["3EB0A1B2C3..."], "target": ["08123456789"], "process": "sent" }

Untuk banyak target: "detail": "queued" (dikirim bertahap di background).

4. Tombol interaktif

Setiap tombol adalah objek dengan field type:

typeFieldFungsi
copytext, codeTombol Salin Kode — menyalin code ke clipboard penerima.
urltext, urlMembuka link.
calltext, phoneMenelepon nomor (format internasional, mis. 628123...).
replytext, idQuick reply. Saat ditekan, id dikirim ke webhook.
listtext, sections[]Menu pilihan. Tiap section punya title dan rows[] (id, title, description).

Teks tombol maks 25 karakter.

"buttons": [
  { "type": "copy",  "text": "Salin Kode", "code": "482913" },
  { "type": "url",   "text": "Buka Dashboard", "url": "https://contoh.com" },
  { "type": "call",  "text": "Hubungi CS", "phone": "6281234567890" },
  { "type": "reply", "text": "Konfirmasi", "id": "confirm_123" }
]

Contoh menu list:

"buttons": [{
  "type": "list", "text": "Pilih layanan",
  "sections": [{
    "title": "Layanan",
    "rows": [
      { "id": "svc_1", "title": "Cek Pesanan",  "description": "Lacak status order" },
      { "id": "svc_2", "title": "Hubungi CS",   "description": "Chat dengan admin" }
    ]
  }]
}]
Tombol interaktif memakai fitur WhatsApp yang tidak resmi untuk akun biasa. Tampilannya bisa berbeda antar versi WhatsApp, dan di beberapa akun/versi tombol bisa tidak muncul. Selalu sertakan teks pesan yang bisa dibaca tanpa tombol (mis. kode OTP tetap ada di message).

5. Kirim OTP (tombol Salin Kode)

POST/api/send-otp — shortcut untuk OTP.

FieldWajibKeterangan
targetyaNomor tujuan.
codeyaKode OTP.
messagetidakTeks custom. Default: "Kode verifikasi Anda: *123456* …".
button_texttidakTeks tombol, default Salin Kode.

6. Webhook pesan masuk

Isi URL webhook di Dashboard → Kelola. Setiap pesan masuk dikirim sebagai POST JSON:

{
  "device": "a1b2c3d4",
  "id": "3EB0...",
  "from": "628123456789",
  "chat": "[email protected]",
  "isGroup": false,
  "pushName": "Budi",
  "timestamp": 1761577000,
  "type": "text",          // text | image | video | document | audio | button_reply | list_reply
  "text": "Halo",
  "buttonId": null         // terisi saat type = button_reply / list_reply
}

Contoh: ketika pelanggan menekan tombol reply dengan id: "confirm_123", webhook menerima type: "button_reply" dan buttonId: "confirm_123".

7. Kode error

HTTPArti
400Parameter salah / tombol tidak valid
401Token salah
409Device belum terhubung ke WhatsApp
429Rate limit 60 request/menit per token
500Gagal kirim (mis. nomor tidak terdaftar di WhatsApp)

Semua error berbentuk { "status": false, "reason": "…" }.

8. Tips agar akun aman