Skip to content

NotificationPolicy

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.NotificationPolicy("SslAlerts", {
alertType: "universal_ssl_event_type",
mechanisms: { email: [{ id: "ops@example.com" }] },
});

Disabled policy with a description

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