API Dökümanı

WhatsApp API Gateway — REST endpoint referansı

🔑 Güvenlik (Authentication)

Mesaj gönderme (/api/wa/send), hesapları listeleme (/api/accounts) ve loglar gibi sistem geneli verilere iki yolla erişilir: (1) API istemcileri için .env dosyasındaki APP_SECRET değeri X-Secret başlığında gönderilir; (2) yönetim paneline giriş yapmış tarayıcılar wa_admin çerezi ile yetkilenir. Hedef oturum X-Account-Phone başlığı ile seçilir.

X-Secret: <APP_SECRET>
X-Account-Phone: 905XXXXXXXXX (Sadece mesaj gönderirken)

📨 Gelen Mesaj Webhook

Hesabınıza gelen WA mesajları veritabanında belirtilen webhookUrl adresine HMAC-SHA256 imzalı olarak POST edilir:

POST <webhookUrl>
X-Account-Phone: 905XXXXXXXXX
X-Signature-SHA256: <hex-hmac-sha256>
Content-Type: application/json

{
  "accountId": "cm...",
  "from": "905001234567",
  "body": "Mesaj içeriği",
  "timestamp": 1710000000,
  "opt_out": true
}
GET/api/accounts/check?phone=905...🌍 Public

Belirli bir numaranın bağlı olup olmadığını kontrol eder. Secret gerektirmez. (iframe ve public kullanım için)

Response
{"connected": true}
POST/api/sessions🌍 Public

Yeni WA oturumu başlat. Dönen sessionId ile QR'ı çekin.

Response
{"sessionId":"<cuid>"}
GET/api/sessions/{sessionId}/status🌍 Public

Oturum durumu: starting | qr | ready. Ready olduğunda phone ve secret görünür.

Response
{"status":"ready","phone":"905...","pushname":"Ad","secret":"..."}
POST/api/wa/send🔑 Yetkili

Belirtilen hesaptan mesaj gönder (APP_SECRET veya yönetim oturumu gerekir).

Body
{"phone":"905001234567","message":"Merhaba!"}
Response
{"jobId":"1","status":"queued"}
GET/api/accounts🔑 Yetkili

Tüm kayıtlı hesapları listele (APP_SECRET veya yönetim oturumu gerekir).

Response
[{"id":"...","phone":"905...","status":"ready",...}]
GET/api/logs?accountId={id}&direction=outbound&status=failed&since=2026-10-15T00:00:00Z🔑 Yetkili

Mesaj loglarını getir. Opsiyonel filtreler: status, since (ISO tarih). (APP_SECRET veya yönetim oturumu gerekir).

Response
{"logs":[...],"total":5}