Webhook'lar
Endpoint'ler
GET /api/v1/webhooks listele
POST /api/v1/webhooks oluştur { url, events[] }
DELETE /api/v1/webhooks/:id sil
POST /api/v1/webhooks/:id/test bir test etkinliği gönderWebhook alanları
typescript
{
user: ObjectId,
team_id: ObjectId | null,
url: string, // endpoint'in
events: string[], // abone olunan etkinlik tipleri
secret: string, // oluşturmadan sonra asla dönülmez
active: boolean,
failure_count: number,
last_dispatched_at: Date | null,
last_failure_at: Date | null,
}İmzalama
Her giden webhook bir X-Sosyabot-Signature header'ı taşır — kayıtlı secret ile imzalanmış, hex-encoded, ham body'nin HMAC-SHA256'sı. Kendi tarafında doğrula:
js
import crypto from "node:crypto";
function verify(req, secret) {
const sig = req.headers["x-sosyabot-signature"];
const expected = crypto.createHmac("sha256", secret).update(req.rawBody).digest("hex");
return crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
}Yeniden deneme
Başarısız teslimler (non-2xx yanıt veya timeout içinde yanıt yok) failure_count'u artırır. Dispatcher üstel olarak backoff yapar; kalıcı başarısızlıklar sonunda webhook'u devre dışı bırakır (active: false).
Yaygın etkinlikler
post.published, post.failed, account.refresh_failed, billing.invoice.paid, billing.payment_failed, marketplace.order.created, team.invitation.accepted. Tam liste dispatcher kaynağındadır.