Dokumentasi DMT WhatsApp API

Base URL: http://10.4.100.12:3000
← Kembali ke Dashboard

1. Autentikasi

Sertakan header x-api-key pada setiap request ke endpoint /api/*:

x-api-key: API_KEY_ANDA
Content-Type: application/json

2. Endpoint Utama

GET/health — Cek status service (tanpa API key).

GET/api/sessions — Daftar sender WA & statistik harian.

GET/api/status?sessionId=billing-utama — Cek status koneksi.

POST/api/check-number — Cek nomor terdaftar di WA.

POST/api/send-text — Kirim teks lewat antrean anti-ban.

curl -X POST http://10.4.100.12:3000/api/send-text \
  -H "Content-Type: application/json" \
  -H "x-api-key: API_KEY_ANDA" \
  -d '{
    "sessionId": "billing-utama",
    "to": "081234567890",
    "message": "{Halo|Hai} Pak Budi, pembayaran internet DMT lunas!",
    "priority": "high"
  }'

POST/api/send-media — Kirim PDF invoice / gambar / dokumen via URL.

curl -X POST http://10.4.100.12:3000/api/send-media \
  -H "Content-Type: application/json" \
  -H "x-api-key: API_KEY_ANDA" \
  -d '{
    "sessionId": "billing-utama",
    "to": "081234567890",
    "type": "document",
    "url": "http://10.4.100.x/invoices/INV-001.pdf",
    "fileName": "Invoice-DMT.pdf",
    "caption": "Berikut invoice tagihan internet DMT Anda."
  }'

POST/api/send-template — Kirim memakai template billing (tagihan-bulanan, pengingat-jatuh-tempo, info-isolir, konfirmasi-lunas).

curl -X POST http://10.4.100.12:3000/api/send-template \
  -H "Content-Type: application/json" \
  -H "x-api-key: API_KEY_ANDA" \
  -d '{
    "sessionId": "billing-utama",
    "to": "081234567890",
    "templateId": "konfirmasi-lunas",
    "priority": "high",
    "variables": { "nama": "Budi", "id_pelanggan": "DMT-001", "nominal": "Rp 250.000" }
  }'

POST/api/send-bulk — Kirim tagihan massal (HTTP 202 langsung kembali, diproses bertahap di background).

curl -X POST http://10.4.100.12:3000/api/send-bulk \
  -H "Content-Type: application/json" \
  -H "x-api-key: API_KEY_ANDA" \
  -d '{
    "sessionId": "billing-utama",
    "templateId": "tagihan-bulanan",
    "priority": "normal",
    "items": [
      { "to": "081234567890", "variables": { "nama": "Budi", "id_pelanggan": "DMT-001", "paket": "30 Mbps", "nominal": "Rp 250.000", "jatuh_tempo": "20/12/2026" } }
    ]
  }'

3. Webhook & Verifikasi Signature

Event dikirim ke Webhook URL dengan header x-webhook-signature: sha256=... dan x-webhook-event (message.received, message.sent, system.circuit_open).

// Contoh verifikasi di PHP (Billing DMT)
$payload = file_get_contents('php://input');
$sig = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '';
$expected = 'sha256=' . hash_hmac('sha256', $payload, 'WEBHOOK_SECRET_ANDA');
if (!hash_equals($expected, $sig)) { http_response_code(401); exit('Invalid'); }