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.
Creating a policy
Section titled “Creating a policy”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" }] },});Webhook destinations
Section titled “Webhook destinations”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 }] },});Filters
Section titled “Filters”yield* Cloudflare.NotificationPolicy("HealthAlerts", { alertType: "health_check_status_notification", mechanisms: { email: [{ id: "ops@example.com" }] }, filters: { healthCheckId: [healthCheckId], newHealth: ["Unhealthy"], },});