İçeriğe geç
ZZenWapp Docs

API referansı

Webhooks

Gerçek zamanlı olay teslimatı için webhook URL yönetimi, test ve secret rotasyonu.

get/webhooks

Webhook ayarını getir

Gerekli yetki: API anahtarı doğrulaması

İstek örneği

curl -X GET "https://api.zenwapp.com/api/v1/whatsapp/external/webhooks" \
  -H "Authorization: Bearer $ZENWAPP_API_KEY"

Yanıt 200

{
  "success": true,
  "data": {
    "url": "https://partner.example.com/zenwapp/webhook",
    "events": [
      "message.received",
      "message.status"
    ],
    "is_active": true,
    "timeout_seconds": 30
  }
}

Yanıt kodları

  • 200Aktif webhook ayarı
post/webhooks

Webhook tanımla/güncelle

Production ortamında webhook URL'i **HTTPS olmak zorundadır**. Geçersiz event adı gönderilirse istek reddedilir ve geçerli event listesi yanıtta döner.

Gerekli yetki: API anahtarı doğrulaması

Gövde alanları

urlzorunlustring
eventsstring[]Değerler: message.received, message.sent, message.status, connection.connected, connection.disconnectedVarsayılan: ["message.received","message.sent","message.status"]
timeout_secondsintegerVarsayılan: 30

İstek örneği

curl -X POST "https://api.zenwapp.com/api/v1/whatsapp/external/webhooks" \
  -H "Authorization: Bearer $ZENWAPP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://partner.example.com/zenwapp/webhook","events":["message.received","message.status"],"timeout_seconds":30}'

Yanıt 400

{
  "error": "validation_error",
  "message": "Missing required field: to"
}

Yanıt kodları

  • 200Webhook kaydedildi
  • 400Gövde veya sorgu parametreleri geçersiz
delete/webhooks

Webhook'u devre dışı bırak

Gerekli yetki: API anahtarı doğrulaması

İstek örneği

curl -X DELETE "https://api.zenwapp.com/api/v1/whatsapp/external/webhooks" \
  -H "Authorization: Bearer $ZENWAPP_API_KEY"

Yanıt kodları

  • 200Devre dışı bırakıldı
post/webhooks/test

Test olayı gönder

Kayıtlı webhook URL'ine örnek bir olay gönderir. İmza doğrulama kurulumunuzu canlı trafikten önce sınamak için kullanın.

Gerekli yetki: API anahtarı doğrulaması

İstek örneği

curl -X POST "https://api.zenwapp.com/api/v1/whatsapp/external/webhooks/test" \
  -H "Authorization: Bearer $ZENWAPP_API_KEY"

Yanıt kodları

  • 200Test olayı gönderildi
post/webhooks/rotate-secret

Secret'ı yenile

İmzalama secret'ını yeniler ve yanıtta **yalnızca bir kez** döndürür. Yeni secret devreye girdiği anda eski imzalar geçersiz olur.

Gerekli yetki: API anahtarı doğrulaması

İstek örneği

curl -X POST "https://api.zenwapp.com/api/v1/whatsapp/external/webhooks/rotate-secret" \
  -H "Authorization: Bearer $ZENWAPP_API_KEY"

Yanıt 200

{
  "success": true,
  "secret": "whsec_..."
}

Yanıt kodları

  • 200Yeni secret