## Create a Notification policy `client.Alerting.Policies.New(ctx, params) (*PolicyNewResponse, error)` **post** `/accounts/{account_id}/alerting/v3/policies` Creates a new Notification policy. ### Parameters - `params PolicyNewParams` - `AccountID param.Field[string]` Path param: The account id - `AlertType param.Field[PolicyNewParamsAlertType]` Body param: Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values. - `const PolicyNewParamsAlertTypeAbuseReportAlert PolicyNewParamsAlertType = "abuse_report_alert"` - `const PolicyNewParamsAlertTypeAccessCustomCertificateExpirationType PolicyNewParamsAlertType = "access_custom_certificate_expiration_type"` - `const PolicyNewParamsAlertTypeAdvancedDDoSAttackL4Alert PolicyNewParamsAlertType = "advanced_ddos_attack_l4_alert"` - `const PolicyNewParamsAlertTypeAdvancedDDoSAttackL7Alert PolicyNewParamsAlertType = "advanced_ddos_attack_l7_alert"` - `const PolicyNewParamsAlertTypeAdvancedHTTPAlertError PolicyNewParamsAlertType = "advanced_http_alert_error"` - `const PolicyNewParamsAlertTypeBGPHijackNotification PolicyNewParamsAlertType = "bgp_hijack_notification"` - `const PolicyNewParamsAlertTypeBillingUsageAlert PolicyNewParamsAlertType = "billing_usage_alert"` - `const PolicyNewParamsAlertTypeBlockNotificationBlockRemoved PolicyNewParamsAlertType = "block_notification_block_removed"` - `const PolicyNewParamsAlertTypeBlockNotificationNewBlock PolicyNewParamsAlertType = "block_notification_new_block"` - `const PolicyNewParamsAlertTypeBlockNotificationReviewRejected PolicyNewParamsAlertType = "block_notification_review_rejected"` - `const PolicyNewParamsAlertTypeBotTrafficBasicAlert PolicyNewParamsAlertType = "bot_traffic_basic_alert"` - `const PolicyNewParamsAlertTypeBrandProtectionAlert PolicyNewParamsAlertType = "brand_protection_alert"` - `const PolicyNewParamsAlertTypeBrandProtectionDigest PolicyNewParamsAlertType = "brand_protection_digest"` - `const PolicyNewParamsAlertTypeClickhouseAlertFwAnomaly PolicyNewParamsAlertType = "clickhouse_alert_fw_anomaly"` - `const PolicyNewParamsAlertTypeClickhouseAlertFwEntAnomaly PolicyNewParamsAlertType = "clickhouse_alert_fw_ent_anomaly"` - `const PolicyNewParamsAlertTypeCloudforceOneRequestNotification PolicyNewParamsAlertType = "cloudforce_one_request_notification"` - `const PolicyNewParamsAlertTypeCNIMaintenanceNotification PolicyNewParamsAlertType = "cni_maintenance_notification"` - `const PolicyNewParamsAlertTypeCustomAnalytics PolicyNewParamsAlertType = "custom_analytics"` - `const PolicyNewParamsAlertTypeCustomBotDetectionAlert PolicyNewParamsAlertType = "custom_bot_detection_alert"` - `const PolicyNewParamsAlertTypeCustomSSLCertificateEventType PolicyNewParamsAlertType = "custom_ssl_certificate_event_type"` - `const PolicyNewParamsAlertTypeDedicatedSSLCertificateEventType PolicyNewParamsAlertType = "dedicated_ssl_certificate_event_type"` - `const PolicyNewParamsAlertTypeDeviceConnectivityAnomalyAlert PolicyNewParamsAlertType = "device_connectivity_anomaly_alert"` - `const PolicyNewParamsAlertTypeDosAttackL4 PolicyNewParamsAlertType = "dos_attack_l4"` - `const PolicyNewParamsAlertTypeDosAttackL7 PolicyNewParamsAlertType = "dos_attack_l7"` - `const PolicyNewParamsAlertTypeExpiringServiceTokenAlert PolicyNewParamsAlertType = "expiring_service_token_alert"` - `const PolicyNewParamsAlertTypeFailingLogpushJobDisabledAlert PolicyNewParamsAlertType = "failing_logpush_job_disabled_alert"` - `const PolicyNewParamsAlertTypeFbmAutoAdvertisement PolicyNewParamsAlertType = "fbm_auto_advertisement"` - `const PolicyNewParamsAlertTypeFbmDosdAttack PolicyNewParamsAlertType = "fbm_dosd_attack"` - `const PolicyNewParamsAlertTypeFbmVolumetricAttack PolicyNewParamsAlertType = "fbm_volumetric_attack"` - `const PolicyNewParamsAlertTypeHealthCheckStatusNotification PolicyNewParamsAlertType = "health_check_status_notification"` - `const PolicyNewParamsAlertTypeHostnameAopCustomCertificateExpirationType PolicyNewParamsAlertType = "hostname_aop_custom_certificate_expiration_type"` - `const PolicyNewParamsAlertTypeHTTPAlertEdgeError PolicyNewParamsAlertType = "http_alert_edge_error"` - `const PolicyNewParamsAlertTypeHTTPAlertOriginError PolicyNewParamsAlertType = "http_alert_origin_error"` - `const PolicyNewParamsAlertTypeImageNotification PolicyNewParamsAlertType = "image_notification"` - `const PolicyNewParamsAlertTypeImageResizingNotification PolicyNewParamsAlertType = "image_resizing_notification"` - `const PolicyNewParamsAlertTypeIncidentAlert PolicyNewParamsAlertType = "incident_alert"` - `const PolicyNewParamsAlertTypeLoadBalancingHealthAlert PolicyNewParamsAlertType = "load_balancing_health_alert"` - `const PolicyNewParamsAlertTypeLoadBalancingPoolEnablementAlert PolicyNewParamsAlertType = "load_balancing_pool_enablement_alert"` - `const PolicyNewParamsAlertTypeLogoMatchAlert PolicyNewParamsAlertType = "logo_match_alert"` - `const PolicyNewParamsAlertTypeMagicTunnelHealthCheckEvent PolicyNewParamsAlertType = "magic_tunnel_health_check_event"` - `const PolicyNewParamsAlertTypeMagicWANTunnelHealth PolicyNewParamsAlertType = "magic_wan_tunnel_health"` - `const PolicyNewParamsAlertTypeMaintenanceEventNotification PolicyNewParamsAlertType = "maintenance_event_notification"` - `const PolicyNewParamsAlertTypeMTLSCertificateStoreCertificateExpirationType PolicyNewParamsAlertType = "mtls_certificate_store_certificate_expiration_type"` - `const PolicyNewParamsAlertTypePagesEventAlert PolicyNewParamsAlertType = "pages_event_alert"` - `const PolicyNewParamsAlertTypeRadarNotification PolicyNewParamsAlertType = "radar_notification"` - `const PolicyNewParamsAlertTypeRealOriginMonitoring PolicyNewParamsAlertType = "real_origin_monitoring"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewCodeChangeDetections PolicyNewParamsAlertType = "scriptmonitor_alert_new_code_change_detections"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewHosts PolicyNewParamsAlertType = "scriptmonitor_alert_new_hosts"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousHosts PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_hosts"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousScripts PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_scripts"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousURL PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_url"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PolicyNewParamsAlertType = "scriptmonitor_alert_new_max_length_resource_url"` - `const PolicyNewParamsAlertTypeScriptmonitorAlertNewResources PolicyNewParamsAlertType = "scriptmonitor_alert_new_resources"` - `const PolicyNewParamsAlertTypeSecondaryDNSAllPrimariesFailing PolicyNewParamsAlertType = "secondary_dns_all_primaries_failing"` - `const PolicyNewParamsAlertTypeSecondaryDNSPrimariesFailing PolicyNewParamsAlertType = "secondary_dns_primaries_failing"` - `const PolicyNewParamsAlertTypeSecondaryDNSWarning PolicyNewParamsAlertType = "secondary_dns_warning"` - `const PolicyNewParamsAlertTypeSecondaryDNSZoneSuccessfullyUpdated PolicyNewParamsAlertType = "secondary_dns_zone_successfully_updated"` - `const PolicyNewParamsAlertTypeSecondaryDNSZoneValidationWarning PolicyNewParamsAlertType = "secondary_dns_zone_validation_warning"` - `const PolicyNewParamsAlertTypeSecurityInsightsAlert PolicyNewParamsAlertType = "security_insights_alert"` - `const PolicyNewParamsAlertTypeSentinelAlert PolicyNewParamsAlertType = "sentinel_alert"` - `const PolicyNewParamsAlertTypeStreamLiveNotifications PolicyNewParamsAlertType = "stream_live_notifications"` - `const PolicyNewParamsAlertTypeSyntheticTestLatencyAlert PolicyNewParamsAlertType = "synthetic_test_latency_alert"` - `const PolicyNewParamsAlertTypeSyntheticTestLowAvailabilityAlert PolicyNewParamsAlertType = "synthetic_test_low_availability_alert"` - `const PolicyNewParamsAlertTypeTrafficAnomaliesAlert PolicyNewParamsAlertType = "traffic_anomalies_alert"` - `const PolicyNewParamsAlertTypeTunnelHealthEvent PolicyNewParamsAlertType = "tunnel_health_event"` - `const PolicyNewParamsAlertTypeTunnelUpdateEvent PolicyNewParamsAlertType = "tunnel_update_event"` - `const PolicyNewParamsAlertTypeUniversalSSLEventType PolicyNewParamsAlertType = "universal_ssl_event_type"` - `const PolicyNewParamsAlertTypeWebAnalyticsMetricsUpdate PolicyNewParamsAlertType = "web_analytics_metrics_update"` - `const PolicyNewParamsAlertTypeZoneAopCustomCertificateExpirationType PolicyNewParamsAlertType = "zone_aop_custom_certificate_expiration_type"` - `Enabled param.Field[bool]` Body param: Whether or not the Notification policy is enabled. - `Mechanisms param.Field[Mechanism]` Body param: List of IDs that will be used when dispatching a notification. IDs for email type will be the email address. - `Name param.Field[string]` Body param: Name of the policy. - `AlertInterval param.Field[string]` Body param: Optional specification of how often to re-alert from the same incident, not support on all alert types. - `Description param.Field[string]` Body param: Optional description for the Notification policy. - `Filters param.Field[PolicyFilter]` Body param: Optional filters that allow you to be alerted only on a subset of events for that alert type based on some criteria. This is only available for select alert types. See alert type documentation for more details. ### Returns - `type PolicyNewResponse struct{…}` - `ID string` UUID ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/alerting" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) policy, err := client.Alerting.Policies.New(context.TODO(), alerting.PolicyNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AlertType: cloudflare.F(alerting.PolicyNewParamsAlertTypeUniversalSSLEventType), Enabled: cloudflare.F(true), Mechanisms: cloudflare.F(alerting.MechanismParam{ }), Name: cloudflare.F("SSL Notification Event Policy"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", policy.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ```