Skip to content

Cloudflare.Alerting reference

Source: src/Cloudflare/Alerting/NotificationPolicy.ts

A Cloudflare Notifications policy.

A notification policy connects an alert type (the event Cloudflare watches for) to one or more destinations — email addresses, webhook destinations, or PagerDuty services — optionally narrowed by filters.

Email notifications for Universal SSL events

yield* Cloudflare.Alerting.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
mechanisms: { email: [{ id: "ops@example.com" }] },
});

Disabled policy with a description

yield* Cloudflare.Alerting.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
enabled: false,
description: "Paused during migration",
mechanisms: { email: [{ id: "ops@example.com" }] },
});
const webhook = yield* Cloudflare.Alerting.NotificationWebhook("AlertsHook", {
url: "https://alerts.example.com/cf",
});
yield* Cloudflare.Alerting.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
mechanisms: { webhooks: [{ id: webhook.webhookId }] },
});
yield* Cloudflare.Alerting.NotificationPolicy("HealthAlerts", {
alertType: "health_check_status_notification",
mechanisms: { email: [{ id: "ops@example.com" }] },
filters: {
healthCheckId: [healthCheckId],
newHealth: ["Unhealthy"],
},
});

Source: src/Cloudflare/Alerting/Silence.ts

A Cloudflare Notifications silence window.

A silence suppresses notification dispatches for a NotificationPolicy between startTime and endTime — e.g. during a planned maintenance window. The window times are explicit ISO8601 props supplied by you; Cloudflare requires the start time to be within 90 days of now.

Note: the create API returns no id, so the provider resolves the created silence by listing and matching on (policyId, startTime, endTime). Two silences sharing the exact same policy and window are indistinguishable.

const policy = yield* Cloudflare.Alerting.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
mechanisms: { email: [{ id: "ops@example.com" }] },
});
yield* Cloudflare.Alerting.Silence("MaintenanceWindow", {
policyId: policy.policyId,
startTime: "2026-07-01T00:00:00Z",
endTime: "2026-07-01T04:00:00Z",
});

Window times are mutable — changing them updates the existing silence.

yield* Cloudflare.Alerting.Silence("MaintenanceWindow", {
policyId: policy.policyId,
startTime: "2026-07-01T00:00:00Z",
endTime: "2026-07-01T08:00:00Z",
});

Source: src/Cloudflare/Alerting/Webhook.ts

A Cloudflare Notifications webhook destination.

Webhook destinations receive alert notifications dispatched by 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.

NotificationWebhook: Creating a Webhook destination

Section titled “NotificationWebhook: Creating a Webhook destination”

Generic webhook with a generated name

const webhook = yield* Cloudflare.Alerting.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.Alerting.NotificationWebhook("AlertsHook", {
name: "production-alerts",
url: "https://alerts.example.com/cf",
secret: yield* Config.Redacted("WEBHOOK_SECRET"),
});

NotificationWebhook: Using with a Notification policy

Section titled “NotificationWebhook: Using with a Notification policy”
yield* Cloudflare.Alerting.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
mechanisms: { webhooks: [{ id: webhook.webhookId }] },
});