Webhooks

Instead of polling events, a bot can receive the exact same events (message.create, message.update, message.delete) as HTTP POST deliveries to an HTTPS endpoint you configure in Ayarlar → Geliştirici → Webhook.

Endpoint requirements#

  • HTTPS only. Plain http:// URLs and URLs containing credentials are rejected.

  • Public destinations only (SSRF protection). localhost, .local, .internal, loopback, RFC 1918 private ranges, CGNAT (100.64.0.0/10), link-local (169.254.0.0/16, fe80::/10), and IPv6 ULA (fc00::/7) are blocked both at save time and before each delivery after DNS resolution.

  • Redirects are not followed; respond with any 2xx status within 10 seconds.

Headers#

Every webhook delivery carries:

HeaderMeaning
X-Yuva-EventEvent type (message.create, message.update, message.delete, or webhook.test).
X-Yuva-DeliveryUnique delivery ID (whd_…).
X-Yuva-Signaturet=<unix_seconds>,v1=<hex_hmac_sha256>

Signature verification#

When you save a webhook for the first time (or rotate its secret), Yuva generates a 256-bit ywh_ secret and shows it once. Compute the HMAC-SHA256 of <t>.<raw_body> with that secret and compare in constant time; reject timestamps older than 5 minutes to prevent replay attacks.

import { verifyWebhook } from "yuva-bot";const ok = verifyWebhook(rawBody, req.headers["x-yuva-signature"], process.env.YUVA_WEBHOOK_SECRET!);

Retries and auto-disable#

  • Failed deliveries (non-2xx, timeout or network error) are retried 5 times with increasing delays: 1s, 10s, 1m, 10m, 1h.

  • After 50 consecutive failures, the webhook is automatically disabled and the bot owner receives an in-app notice. Fix your endpoint and re-enable it in the Developer panel.

  • Use Test olayı gönder in the Developer panel at any time to send a webhook.test payload immediately.