Skip to content

NotificationWebhook

Source: src/Cloudflare/Alerting/Webhook.ts

A Cloudflare Notifications webhook destination.

Webhook destinations receive alert notifications dispatched by {@link NotificationPolicy | notification policies}. Cloudflare sends a test POST to the URL when the webhook is created or updated, so the endpoint must be live and respond with a 2xx.

Generic webhook with a generated name

const webhook = yield* Cloudflare.NotificationWebhook("AlertsHook", {
url: "https://alerts.example.com/cf",
});

Webhook with an auth secret

The secret is sent in the cf-webhook-auth header on every dispatch.

const webhook = yield* Cloudflare.NotificationWebhook("AlertsHook", {
name: "production-alerts",
url: "https://alerts.example.com/cf",
secret: alchemy.secret.env.WEBHOOK_SECRET,
});
yield* Cloudflare.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
mechanisms: { webhooks: [{ id: webhook.webhookId }] },
});