# Alerting # Available Alerts ## Get Alert Types `client.Alerting.AvailableAlerts.List(ctx, query) (*AvailableAlertListResponse, error)` **get** `/accounts/{account_id}/alerting/v3/available_alerts` Gets a list of all alert types for which an account is eligible. ### Parameters - `query AvailableAlertListParams` - `AccountID param.Field[string]` The account id ### Returns - `type AvailableAlertListResponse map[string, []AvailableAlertListResponseItem]` - `Description string` Describes the alert type. - `DisplayName string` Alert type name. - `FilterOptions []unknown` Format of additional configuration options (filters) for the alert type. Data type of filters during policy creation: Array of strings. - `Type string` Use this value when creating and updating a notification policy. ### 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"), ) availableAlerts, err := client.Alerting.AvailableAlerts.List(context.TODO(), alerting.AvailableAlertListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", availableAlerts) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "Origin Monitoring": [ { "description": "High levels of 5xx HTTP errors at your origin.", "display_name": "Origin Error Rate Alert", "filter_options": [ { "AvailableValues": null, "ComparisonOperator": "==", "Key": "zones", "Range": "1-n" }, { "AvailableValues": [ { "Description": "Service-Level Objective of 99.7", "ID": "99.7" }, { "Description": "Service-Level Objective of 99.8", "ID": "99.8" } ], "ComparisonOperator": ">=", "Key": "slo", "Range": "0-1" } ], "type": "http_alert_origin_error" } ] } } ``` # Destinations # Eligible ## Get delivery mechanism eligibility `client.Alerting.Destinations.Eligible.Get(ctx, query) (*DestinationEligibleGetResponse, error)` **get** `/accounts/{account_id}/alerting/v3/destinations/eligible` Get a list of all delivery mechanism types for which an account is eligible. ### Parameters - `query DestinationEligibleGetParams` - `AccountID param.Field[string]` The account id ### Returns - `type DestinationEligibleGetResponse map[string, []DestinationEligibleGetResponseItem]` - `Eligible bool` Determines whether or not the account is eligible for the delivery mechanism. - `Ready bool` Beta flag. Users can create a policy with a mechanism that is not ready, but we cannot guarantee successful delivery of notifications. - `Type DestinationEligibleGetResponseItemType` Determines type of delivery mechanism. - `const DestinationEligibleGetResponseItemTypeEmail DestinationEligibleGetResponseItemType = "email"` - `const DestinationEligibleGetResponseItemTypePagerduty DestinationEligibleGetResponseItemType = "pagerduty"` - `const DestinationEligibleGetResponseItemTypeWebhook DestinationEligibleGetResponseItemType = "webhook"` ### 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"), ) eligible, err := client.Alerting.Destinations.Eligible.Get(context.TODO(), alerting.DestinationEligibleGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", eligible) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "foo": [ { "eligible": true, "ready": true, "type": "email" } ] } } ``` # Pagerduty ## List PagerDuty services `client.Alerting.Destinations.Pagerduty.Get(ctx, query) (*SinglePage[Pagerduty], error)` **get** `/accounts/{account_id}/alerting/v3/destinations/pagerduty` Get a list of all configured PagerDuty services. ### Parameters - `query DestinationPagerdutyGetParams` - `AccountID param.Field[string]` The account id ### Returns - `type Pagerduty struct{…}` - `ID string` UUID - `Name string` The name of the pagerduty service. ### 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"), ) page, err := client.Alerting.Destinations.Pagerduty.Get(context.TODO(), alerting.DestinationPagerdutyGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "f174e90afafe4643bbbc4a0ed4fc8415", "name": "My PagerDuty Service" } ] } ``` ## Create PagerDuty integration token `client.Alerting.Destinations.Pagerduty.New(ctx, body) (*DestinationPagerdutyNewResponse, error)` **post** `/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect` Creates a new token for integrating with PagerDuty. ### Parameters - `body DestinationPagerdutyNewParams` - `AccountID param.Field[string]` The account id ### Returns - `type DestinationPagerdutyNewResponse struct{…}` - `ID string` token in form of 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"), ) pagerduty, err := client.Alerting.Destinations.Pagerduty.New(context.TODO(), alerting.DestinationPagerdutyNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pagerduty.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "a313ba7d3e464c0ea40808fafbc3816a" } } ``` ## Delete PagerDuty Services `client.Alerting.Destinations.Pagerduty.Delete(ctx, body) (*DestinationPagerdutyDeleteResponse, error)` **delete** `/accounts/{account_id}/alerting/v3/destinations/pagerduty` Deletes all the PagerDuty Services connected to the account. ### Parameters - `body DestinationPagerdutyDeleteParams` - `AccountID param.Field[string]` The account id ### Returns - `type DestinationPagerdutyDeleteResponse struct{…}` - `Errors []DestinationPagerdutyDeleteResponseError` - `Message string` - `Code int64` - `Messages []DestinationPagerdutyDeleteResponseMessage` - `Message string` - `Code int64` - `Success DestinationPagerdutyDeleteResponseSuccess` Whether the API call was successful - `const DestinationPagerdutyDeleteResponseSuccessTrue DestinationPagerdutyDeleteResponseSuccess = true` ### 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"), ) pagerduty, err := client.Alerting.Destinations.Pagerduty.Delete(context.TODO(), alerting.DestinationPagerdutyDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pagerduty.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Connect PagerDuty `client.Alerting.Destinations.Pagerduty.Link(ctx, tokenID, query) (*DestinationPagerdutyLinkResponse, error)` **get** `/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect/{token_id}` Links PagerDuty with the account using the integration token. ### Parameters - `tokenID string` The token integration key - `query DestinationPagerdutyLinkParams` - `AccountID param.Field[string]` The account id ### Returns - `type DestinationPagerdutyLinkResponse 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"), ) response, err := client.Alerting.Destinations.Pagerduty.Link( context.TODO(), "8c71e667571b4f61b94d9e4b12158038", alerting.DestinationPagerdutyLinkParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Domain Types ### Pagerduty - `type Pagerduty struct{…}` - `ID string` UUID - `Name string` The name of the pagerduty service. # Webhooks ## List webhooks `client.Alerting.Destinations.Webhooks.List(ctx, query) (*SinglePage[Webhooks], error)` **get** `/accounts/{account_id}/alerting/v3/destinations/webhooks` Gets a list of all configured webhook destinations. ### Parameters - `query DestinationWebhookListParams` - `AccountID param.Field[string]` The account id ### Returns - `type Webhooks struct{…}` - `ID string` The unique identifier of a webhook - `CreatedAt Time` Timestamp of when the webhook destination was created. - `LastFailure Time` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `LastSuccess Time` Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. - `Name string` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `Secret string` Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body. - `Type WebhooksType` Type of webhook endpoint. - `const WebhooksTypeDatadog WebhooksType = "datadog"` - `const WebhooksTypeDiscord WebhooksType = "discord"` - `const WebhooksTypeFeishu WebhooksType = "feishu"` - `const WebhooksTypeGchat WebhooksType = "gchat"` - `const WebhooksTypeGeneric WebhooksType = "generic"` - `const WebhooksTypeOpsgenie WebhooksType = "opsgenie"` - `const WebhooksTypeSlack WebhooksType = "slack"` - `const WebhooksTypeSplunk WebhooksType = "splunk"` - `URL string` The POST endpoint to call when dispatching a notification. ### 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"), ) page, err := client.Alerting.Destinations.Webhooks.List(context.TODO(), alerting.DestinationWebhookListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "b115d5ec15c641ee8b7692c449b5227b", "created_at": "2020-10-26T18:25:04.532316Z", "last_failure": "2020-10-26T18:25:04.532316Z", "last_success": "2020-10-26T18:25:04.532316Z", "name": "Slack Webhook", "type": "slack", "url": "https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd" } ] } ``` ## Get a webhook `client.Alerting.Destinations.Webhooks.Get(ctx, webhookID, query) (*Webhooks, error)` **get** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Get details for a single webhooks destination. ### Parameters - `webhookID string` The unique identifier of a webhook - `query DestinationWebhookGetParams` - `AccountID param.Field[string]` The account id ### Returns - `type Webhooks struct{…}` - `ID string` The unique identifier of a webhook - `CreatedAt Time` Timestamp of when the webhook destination was created. - `LastFailure Time` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `LastSuccess Time` Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. - `Name string` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `Secret string` Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body. - `Type WebhooksType` Type of webhook endpoint. - `const WebhooksTypeDatadog WebhooksType = "datadog"` - `const WebhooksTypeDiscord WebhooksType = "discord"` - `const WebhooksTypeFeishu WebhooksType = "feishu"` - `const WebhooksTypeGchat WebhooksType = "gchat"` - `const WebhooksTypeGeneric WebhooksType = "generic"` - `const WebhooksTypeOpsgenie WebhooksType = "opsgenie"` - `const WebhooksTypeSlack WebhooksType = "slack"` - `const WebhooksTypeSplunk WebhooksType = "splunk"` - `URL string` The POST endpoint to call when dispatching a notification. ### 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"), ) webhooks, err := client.Alerting.Destinations.Webhooks.Get( context.TODO(), "b115d5ec15c641ee8b7692c449b5227b", alerting.DestinationWebhookGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", webhooks.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "b115d5ec15c641ee8b7692c449b5227b", "created_at": "2020-10-26T18:25:04.532316Z", "last_failure": "2020-10-26T18:25:04.532316Z", "last_success": "2020-10-26T18:25:04.532316Z", "name": "Slack Webhook", "type": "slack", "url": "https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd" } } ``` ## Create a webhook `client.Alerting.Destinations.Webhooks.New(ctx, params) (*DestinationWebhookNewResponse, error)` **post** `/accounts/{account_id}/alerting/v3/destinations/webhooks` Creates a new webhook destination. ### Parameters - `params DestinationWebhookNewParams` - `AccountID param.Field[string]` Path param: The account id - `Name param.Field[string]` Body param: The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `URL param.Field[string]` Body param: The POST endpoint to call when dispatching a notification. - `Secret param.Field[string]` Body param: Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body. ### Returns - `type DestinationWebhookNewResponse 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"), ) webhook, err := client.Alerting.Destinations.Webhooks.New(context.TODO(), alerting.DestinationWebhookNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Slack Webhook"), URL: cloudflare.F("https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", webhook.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Update a webhook `client.Alerting.Destinations.Webhooks.Update(ctx, webhookID, params) (*DestinationWebhookUpdateResponse, error)` **put** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Update a webhook destination. ### Parameters - `webhookID string` The unique identifier of a webhook - `params DestinationWebhookUpdateParams` - `AccountID param.Field[string]` Path param: The account id - `Name param.Field[string]` Body param: The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `URL param.Field[string]` Body param: The POST endpoint to call when dispatching a notification. - `Secret param.Field[string]` Body param: Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body. ### Returns - `type DestinationWebhookUpdateResponse 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"), ) webhook, err := client.Alerting.Destinations.Webhooks.Update( context.TODO(), "b115d5ec15c641ee8b7692c449b5227b", alerting.DestinationWebhookUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Slack Webhook"), URL: cloudflare.F("https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", webhook.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Delete a webhook `client.Alerting.Destinations.Webhooks.Delete(ctx, webhookID, body) (*DestinationWebhookDeleteResponse, error)` **delete** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Delete a configured webhook destination. ### Parameters - `webhookID string` The unique identifier of a webhook - `body DestinationWebhookDeleteParams` - `AccountID param.Field[string]` The account id ### Returns - `type DestinationWebhookDeleteResponse struct{…}` - `Errors []DestinationWebhookDeleteResponseError` - `Message string` - `Code int64` - `Messages []DestinationWebhookDeleteResponseMessage` - `Message string` - `Code int64` - `Success DestinationWebhookDeleteResponseSuccess` Whether the API call was successful - `const DestinationWebhookDeleteResponseSuccessTrue DestinationWebhookDeleteResponseSuccess = true` ### 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"), ) webhook, err := client.Alerting.Destinations.Webhooks.Delete( context.TODO(), "b115d5ec15c641ee8b7692c449b5227b", alerting.DestinationWebhookDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", webhook.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Domain Types ### Webhooks - `type Webhooks struct{…}` - `ID string` The unique identifier of a webhook - `CreatedAt Time` Timestamp of when the webhook destination was created. - `LastFailure Time` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `LastSuccess Time` Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. - `Name string` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `Secret string` Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body. - `Type WebhooksType` Type of webhook endpoint. - `const WebhooksTypeDatadog WebhooksType = "datadog"` - `const WebhooksTypeDiscord WebhooksType = "discord"` - `const WebhooksTypeFeishu WebhooksType = "feishu"` - `const WebhooksTypeGchat WebhooksType = "gchat"` - `const WebhooksTypeGeneric WebhooksType = "generic"` - `const WebhooksTypeOpsgenie WebhooksType = "opsgenie"` - `const WebhooksTypeSlack WebhooksType = "slack"` - `const WebhooksTypeSplunk WebhooksType = "splunk"` - `URL string` The POST endpoint to call when dispatching a notification. # History ## List History `client.Alerting.History.List(ctx, params) (*V4PagePaginationArray[History], error)` **get** `/accounts/{account_id}/alerting/v3/history` Gets a list of history records for notifications sent to an account. The records are displayed for last `x` number of days based on the zone plan (free = 30, pro = 30, biz = 30, ent = 90). ### Parameters - `params HistoryListParams` - `AccountID param.Field[string]` Path param: The account id - `Before param.Field[Time]` Query param: Limit the returned results to history records older than the specified date. This must be a timestamp that conforms to RFC3339. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of items per page. - `Since param.Field[Time]` Query param: Limit the returned results to history records newer than the specified date. This must be a timestamp that conforms to RFC3339. ### Returns - `type History struct{…}` - `ID string` UUID - `AlertBody string` Message body included in the notification sent. - `AlertType string` Type of notification that has been dispatched. - `Description string` Description of the notification policy (if present). - `Mechanism string` The mechanism to which the notification has been dispatched. - `MechanismType HistoryMechanismType` The type of mechanism to which the notification has been dispatched. This can be email/pagerduty/webhook based on the mechanism configured. - `const HistoryMechanismTypeEmail HistoryMechanismType = "email"` - `const HistoryMechanismTypePagerduty HistoryMechanismType = "pagerduty"` - `const HistoryMechanismTypeWebhook HistoryMechanismType = "webhook"` - `Name string` Name of the policy. - `PolicyID string` The unique identifier of a notification policy - `Sent Time` Timestamp of when the notification was dispatched in ISO 8601 format. ### 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"), ) page, err := client.Alerting.History.List(context.TODO(), alerting.HistoryListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "f174e90afafe4643bbbc4a0ed4fc8415", "alert_body": "SSL certificate has expired", "alert_type": "universal_ssl_event_type", "description": "Universal Certificate validation status, issuance, renewal, and expiration notices", "mechanism": "test@example.com", "mechanism_type": "email", "name": "SSL Notification Event Policy", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "sent": "2021-10-08T17:52:17.571336Z" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### History - `type History struct{…}` - `ID string` UUID - `AlertBody string` Message body included in the notification sent. - `AlertType string` Type of notification that has been dispatched. - `Description string` Description of the notification policy (if present). - `Mechanism string` The mechanism to which the notification has been dispatched. - `MechanismType HistoryMechanismType` The type of mechanism to which the notification has been dispatched. This can be email/pagerduty/webhook based on the mechanism configured. - `const HistoryMechanismTypeEmail HistoryMechanismType = "email"` - `const HistoryMechanismTypePagerduty HistoryMechanismType = "pagerduty"` - `const HistoryMechanismTypeWebhook HistoryMechanismType = "webhook"` - `Name string` Name of the policy. - `PolicyID string` The unique identifier of a notification policy - `Sent Time` Timestamp of when the notification was dispatched in ISO 8601 format. # Policies ## List Notification policies `client.Alerting.Policies.List(ctx, query) (*SinglePage[Policy], error)` **get** `/accounts/{account_id}/alerting/v3/policies` Get a list of all Notification policies. ### Parameters - `query PolicyListParams` - `AccountID param.Field[string]` The account id ### Returns - `type Policy struct{…}` - `ID string` The unique identifier of a notification policy - `AlertInterval string` Optional specification of how often to re-alert from the same incident, not support on all alert types. - `AlertType PolicyAlertType` 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 PolicyAlertTypeAbuseReportAlert PolicyAlertType = "abuse_report_alert"` - `const PolicyAlertTypeAccessCustomCertificateExpirationType PolicyAlertType = "access_custom_certificate_expiration_type"` - `const PolicyAlertTypeAdvancedDDoSAttackL4Alert PolicyAlertType = "advanced_ddos_attack_l4_alert"` - `const PolicyAlertTypeAdvancedDDoSAttackL7Alert PolicyAlertType = "advanced_ddos_attack_l7_alert"` - `const PolicyAlertTypeAdvancedHTTPAlertError PolicyAlertType = "advanced_http_alert_error"` - `const PolicyAlertTypeBGPHijackNotification PolicyAlertType = "bgp_hijack_notification"` - `const PolicyAlertTypeBillingUsageAlert PolicyAlertType = "billing_usage_alert"` - `const PolicyAlertTypeBlockNotificationBlockRemoved PolicyAlertType = "block_notification_block_removed"` - `const PolicyAlertTypeBlockNotificationNewBlock PolicyAlertType = "block_notification_new_block"` - `const PolicyAlertTypeBlockNotificationReviewRejected PolicyAlertType = "block_notification_review_rejected"` - `const PolicyAlertTypeBotTrafficBasicAlert PolicyAlertType = "bot_traffic_basic_alert"` - `const PolicyAlertTypeBrandProtectionAlert PolicyAlertType = "brand_protection_alert"` - `const PolicyAlertTypeBrandProtectionDigest PolicyAlertType = "brand_protection_digest"` - `const PolicyAlertTypeClickhouseAlertFwAnomaly PolicyAlertType = "clickhouse_alert_fw_anomaly"` - `const PolicyAlertTypeClickhouseAlertFwEntAnomaly PolicyAlertType = "clickhouse_alert_fw_ent_anomaly"` - `const PolicyAlertTypeCloudforceOneRequestNotification PolicyAlertType = "cloudforce_one_request_notification"` - `const PolicyAlertTypeCNIMaintenanceNotification PolicyAlertType = "cni_maintenance_notification"` - `const PolicyAlertTypeCustomAnalytics PolicyAlertType = "custom_analytics"` - `const PolicyAlertTypeCustomBotDetectionAlert PolicyAlertType = "custom_bot_detection_alert"` - `const PolicyAlertTypeCustomSSLCertificateEventType PolicyAlertType = "custom_ssl_certificate_event_type"` - `const PolicyAlertTypeDedicatedSSLCertificateEventType PolicyAlertType = "dedicated_ssl_certificate_event_type"` - `const PolicyAlertTypeDeviceConnectivityAnomalyAlert PolicyAlertType = "device_connectivity_anomaly_alert"` - `const PolicyAlertTypeDosAttackL4 PolicyAlertType = "dos_attack_l4"` - `const PolicyAlertTypeDosAttackL7 PolicyAlertType = "dos_attack_l7"` - `const PolicyAlertTypeExpiringServiceTokenAlert PolicyAlertType = "expiring_service_token_alert"` - `const PolicyAlertTypeFailingLogpushJobDisabledAlert PolicyAlertType = "failing_logpush_job_disabled_alert"` - `const PolicyAlertTypeFbmAutoAdvertisement PolicyAlertType = "fbm_auto_advertisement"` - `const PolicyAlertTypeFbmDosdAttack PolicyAlertType = "fbm_dosd_attack"` - `const PolicyAlertTypeFbmVolumetricAttack PolicyAlertType = "fbm_volumetric_attack"` - `const PolicyAlertTypeHealthCheckStatusNotification PolicyAlertType = "health_check_status_notification"` - `const PolicyAlertTypeHostnameAopCustomCertificateExpirationType PolicyAlertType = "hostname_aop_custom_certificate_expiration_type"` - `const PolicyAlertTypeHTTPAlertEdgeError PolicyAlertType = "http_alert_edge_error"` - `const PolicyAlertTypeHTTPAlertOriginError PolicyAlertType = "http_alert_origin_error"` - `const PolicyAlertTypeImageNotification PolicyAlertType = "image_notification"` - `const PolicyAlertTypeImageResizingNotification PolicyAlertType = "image_resizing_notification"` - `const PolicyAlertTypeIncidentAlert PolicyAlertType = "incident_alert"` - `const PolicyAlertTypeLoadBalancingHealthAlert PolicyAlertType = "load_balancing_health_alert"` - `const PolicyAlertTypeLoadBalancingPoolEnablementAlert PolicyAlertType = "load_balancing_pool_enablement_alert"` - `const PolicyAlertTypeLogoMatchAlert PolicyAlertType = "logo_match_alert"` - `const PolicyAlertTypeMagicTunnelHealthCheckEvent PolicyAlertType = "magic_tunnel_health_check_event"` - `const PolicyAlertTypeMagicWANTunnelHealth PolicyAlertType = "magic_wan_tunnel_health"` - `const PolicyAlertTypeMaintenanceEventNotification PolicyAlertType = "maintenance_event_notification"` - `const PolicyAlertTypeMTLSCertificateStoreCertificateExpirationType PolicyAlertType = "mtls_certificate_store_certificate_expiration_type"` - `const PolicyAlertTypePagesEventAlert PolicyAlertType = "pages_event_alert"` - `const PolicyAlertTypeRadarNotification PolicyAlertType = "radar_notification"` - `const PolicyAlertTypeRealOriginMonitoring PolicyAlertType = "real_origin_monitoring"` - `const PolicyAlertTypeScriptmonitorAlertNewCodeChangeDetections PolicyAlertType = "scriptmonitor_alert_new_code_change_detections"` - `const PolicyAlertTypeScriptmonitorAlertNewHosts PolicyAlertType = "scriptmonitor_alert_new_hosts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousHosts PolicyAlertType = "scriptmonitor_alert_new_malicious_hosts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousScripts PolicyAlertType = "scriptmonitor_alert_new_malicious_scripts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousURL PolicyAlertType = "scriptmonitor_alert_new_malicious_url"` - `const PolicyAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PolicyAlertType = "scriptmonitor_alert_new_max_length_resource_url"` - `const PolicyAlertTypeScriptmonitorAlertNewResources PolicyAlertType = "scriptmonitor_alert_new_resources"` - `const PolicyAlertTypeSecondaryDNSAllPrimariesFailing PolicyAlertType = "secondary_dns_all_primaries_failing"` - `const PolicyAlertTypeSecondaryDNSPrimariesFailing PolicyAlertType = "secondary_dns_primaries_failing"` - `const PolicyAlertTypeSecondaryDNSWarning PolicyAlertType = "secondary_dns_warning"` - `const PolicyAlertTypeSecondaryDNSZoneSuccessfullyUpdated PolicyAlertType = "secondary_dns_zone_successfully_updated"` - `const PolicyAlertTypeSecondaryDNSZoneValidationWarning PolicyAlertType = "secondary_dns_zone_validation_warning"` - `const PolicyAlertTypeSecurityInsightsAlert PolicyAlertType = "security_insights_alert"` - `const PolicyAlertTypeSentinelAlert PolicyAlertType = "sentinel_alert"` - `const PolicyAlertTypeStreamLiveNotifications PolicyAlertType = "stream_live_notifications"` - `const PolicyAlertTypeSyntheticTestLatencyAlert PolicyAlertType = "synthetic_test_latency_alert"` - `const PolicyAlertTypeSyntheticTestLowAvailabilityAlert PolicyAlertType = "synthetic_test_low_availability_alert"` - `const PolicyAlertTypeTrafficAnomaliesAlert PolicyAlertType = "traffic_anomalies_alert"` - `const PolicyAlertTypeTunnelHealthEvent PolicyAlertType = "tunnel_health_event"` - `const PolicyAlertTypeTunnelUpdateEvent PolicyAlertType = "tunnel_update_event"` - `const PolicyAlertTypeUniversalSSLEventType PolicyAlertType = "universal_ssl_event_type"` - `const PolicyAlertTypeWebAnalyticsMetricsUpdate PolicyAlertType = "web_analytics_metrics_update"` - `const PolicyAlertTypeZoneAopCustomCertificateExpirationType PolicyAlertType = "zone_aop_custom_certificate_expiration_type"` - `Created Time` - `Description string` Optional description for the Notification policy. - `Enabled bool` Whether or not the Notification policy is enabled. - `Filters PolicyFilter` 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. - `Actions []string` Usage depends on specific alert type - `AffectedASNs []string` Used for configuring radar_notification - `AffectedComponents []string` Used for configuring incident_alert - `AffectedLocations []string` Used for configuring radar_notification - `AirportCode []string` Used for configuring maintenance_event_notification - `AlertTriggerPreferences []string` Usage depends on specific alert type - `AlertTriggerPreferencesValue []string` Usage depends on specific alert type - `Enabled []string` Used for configuring load_balancing_pool_enablement_alert - `Environment []string` Used for configuring pages_event_alert - `Event []string` Used for configuring pages_event_alert - `EventSource []string` Used for configuring load_balancing_health_alert - `EventType []string` Usage depends on specific alert type - `GroupBy []string` Usage depends on specific alert type - `HealthCheckID []string` Used for configuring health_check_status_notification - `IncidentImpact []PolicyFilterIncidentImpact` Used for configuring incident_alert - `const PolicyFilterIncidentImpactIncidentImpactNone PolicyFilterIncidentImpact = "INCIDENT_IMPACT_NONE"` - `const PolicyFilterIncidentImpactIncidentImpactMinor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MINOR"` - `const PolicyFilterIncidentImpactIncidentImpactMajor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MAJOR"` - `const PolicyFilterIncidentImpactIncidentImpactCritical PolicyFilterIncidentImpact = "INCIDENT_IMPACT_CRITICAL"` - `InputID []string` Used for configuring stream_live_notifications - `InsightClass []string` Used for configuring security_insights_alert - `Limit []string` Used for configuring billing_usage_alert - `LogoTag []string` Used for configuring logo_match_alert - `MegabitsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `NewHealth []string` Used for configuring load_balancing_health_alert - `NewStatus []string` Used for configuring tunnel_health_event - `PacketsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `PoolID []string` Usage depends on specific alert type - `POPNames []string` Usage depends on specific alert type - `Product []string` Used for configuring billing_usage_alert - `ProjectID []string` Used for configuring pages_event_alert - `Protocol []string` Used for configuring advanced_ddos_attack_l4_alert - `QueryTag []string` Usage depends on specific alert type - `RequestsPerSecond []string` Used for configuring advanced_ddos_attack_l7_alert - `Selectors []string` Usage depends on specific alert type - `Services []string` Used for configuring clickhouse_alert_fw_ent_anomaly - `Slo []string` Usage depends on specific alert type - `Status []string` Used for configuring health_check_status_notification - `TargetHostname []string` Used for configuring advanced_ddos_attack_l7_alert - `TargetIP []string` Used for configuring advanced_ddos_attack_l4_alert - `TargetZoneName []string` Used for configuring advanced_ddos_attack_l7_alert - `TrafficExclusions []PolicyFilterTrafficExclusion` Used for configuring traffic_anomalies_alert - `const PolicyFilterTrafficExclusionSecurityEvents PolicyFilterTrafficExclusion = "security_events"` - `TunnelID []string` Used for configuring tunnel_health_event - `TunnelName []string` Usage depends on specific alert type - `Type []string` Usage depends on specific alert type - `Where []string` Usage depends on specific alert type - `Zones []string` Usage depends on specific alert type - `Mechanisms Mechanism` List of IDs that will be used when dispatching a notification. IDs for email type will be the email address. - `Email []MechanismEmail` - `ID string` The email address - `Pagerduty []MechanismPagerduty` - `ID string` UUID - `Webhooks []MechanismWebhook` - `ID string` UUID - `Modified Time` - `Name string` Name of the policy. ### 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"), ) page, err := client.Alerting.Policies.List(context.TODO(), alerting.PolicyListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "0da2b59ef118439d8097bdfb215203c9", "alert_interval": "30m", "alert_type": "universal_ssl_event_type", "created": "2014-01-01T05:20:00.12345Z", "description": "Something describing the policy.", "enabled": true, "filters": { "actions": [ "string" ], "affected_asns": [ "string" ], "affected_components": [ "string" ], "affected_locations": [ "string" ], "airport_code": [ "string" ], "alert_trigger_preferences": [ "string" ], "alert_trigger_preferences_value": [ "string" ], "enabled": [ "string" ], "environment": [ "string" ], "event": [ "string" ], "event_source": [ "string" ], "event_type": [ "string" ], "group_by": [ "string" ], "health_check_id": [ "string" ], "incident_impact": [ "INCIDENT_IMPACT_NONE" ], "input_id": [ "string" ], "insight_class": [ "string" ], "limit": [ "string" ], "logo_tag": [ "string" ], "megabits_per_second": [ "string" ], "new_health": [ "string" ], "new_status": [ "string" ], "packets_per_second": [ "string" ], "pool_id": [ "string" ], "pop_names": [ "string" ], "product": [ "string" ], "project_id": [ "string" ], "protocol": [ "string" ], "query_tag": [ "string" ], "requests_per_second": [ "string" ], "selectors": [ "string" ], "services": [ "string" ], "slo": [ "99.9" ], "status": [ "string" ], "target_hostname": [ "string" ], "target_ip": [ "string" ], "target_zone_name": [ "string" ], "traffic_exclusions": [ "security_events" ], "tunnel_id": [ "string" ], "tunnel_name": [ "string" ], "type": [ "string" ], "where": [ "string" ], "zones": [ "string" ] }, "mechanisms": { "email": [ { "id": "id" } ], "pagerduty": [ { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } ], "webhooks": [ { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } ] }, "modified": "2014-01-01T05:20:00.12345Z", "name": "SSL Notification Event Policy" } ] } ``` ## Get a Notification policy `client.Alerting.Policies.Get(ctx, policyID, query) (*Policy, error)` **get** `/accounts/{account_id}/alerting/v3/policies/{policy_id}` Get details for a single policy. ### Parameters - `policyID string` The unique identifier of a notification policy - `query PolicyGetParams` - `AccountID param.Field[string]` The account id ### Returns - `type Policy struct{…}` - `ID string` The unique identifier of a notification policy - `AlertInterval string` Optional specification of how often to re-alert from the same incident, not support on all alert types. - `AlertType PolicyAlertType` 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 PolicyAlertTypeAbuseReportAlert PolicyAlertType = "abuse_report_alert"` - `const PolicyAlertTypeAccessCustomCertificateExpirationType PolicyAlertType = "access_custom_certificate_expiration_type"` - `const PolicyAlertTypeAdvancedDDoSAttackL4Alert PolicyAlertType = "advanced_ddos_attack_l4_alert"` - `const PolicyAlertTypeAdvancedDDoSAttackL7Alert PolicyAlertType = "advanced_ddos_attack_l7_alert"` - `const PolicyAlertTypeAdvancedHTTPAlertError PolicyAlertType = "advanced_http_alert_error"` - `const PolicyAlertTypeBGPHijackNotification PolicyAlertType = "bgp_hijack_notification"` - `const PolicyAlertTypeBillingUsageAlert PolicyAlertType = "billing_usage_alert"` - `const PolicyAlertTypeBlockNotificationBlockRemoved PolicyAlertType = "block_notification_block_removed"` - `const PolicyAlertTypeBlockNotificationNewBlock PolicyAlertType = "block_notification_new_block"` - `const PolicyAlertTypeBlockNotificationReviewRejected PolicyAlertType = "block_notification_review_rejected"` - `const PolicyAlertTypeBotTrafficBasicAlert PolicyAlertType = "bot_traffic_basic_alert"` - `const PolicyAlertTypeBrandProtectionAlert PolicyAlertType = "brand_protection_alert"` - `const PolicyAlertTypeBrandProtectionDigest PolicyAlertType = "brand_protection_digest"` - `const PolicyAlertTypeClickhouseAlertFwAnomaly PolicyAlertType = "clickhouse_alert_fw_anomaly"` - `const PolicyAlertTypeClickhouseAlertFwEntAnomaly PolicyAlertType = "clickhouse_alert_fw_ent_anomaly"` - `const PolicyAlertTypeCloudforceOneRequestNotification PolicyAlertType = "cloudforce_one_request_notification"` - `const PolicyAlertTypeCNIMaintenanceNotification PolicyAlertType = "cni_maintenance_notification"` - `const PolicyAlertTypeCustomAnalytics PolicyAlertType = "custom_analytics"` - `const PolicyAlertTypeCustomBotDetectionAlert PolicyAlertType = "custom_bot_detection_alert"` - `const PolicyAlertTypeCustomSSLCertificateEventType PolicyAlertType = "custom_ssl_certificate_event_type"` - `const PolicyAlertTypeDedicatedSSLCertificateEventType PolicyAlertType = "dedicated_ssl_certificate_event_type"` - `const PolicyAlertTypeDeviceConnectivityAnomalyAlert PolicyAlertType = "device_connectivity_anomaly_alert"` - `const PolicyAlertTypeDosAttackL4 PolicyAlertType = "dos_attack_l4"` - `const PolicyAlertTypeDosAttackL7 PolicyAlertType = "dos_attack_l7"` - `const PolicyAlertTypeExpiringServiceTokenAlert PolicyAlertType = "expiring_service_token_alert"` - `const PolicyAlertTypeFailingLogpushJobDisabledAlert PolicyAlertType = "failing_logpush_job_disabled_alert"` - `const PolicyAlertTypeFbmAutoAdvertisement PolicyAlertType = "fbm_auto_advertisement"` - `const PolicyAlertTypeFbmDosdAttack PolicyAlertType = "fbm_dosd_attack"` - `const PolicyAlertTypeFbmVolumetricAttack PolicyAlertType = "fbm_volumetric_attack"` - `const PolicyAlertTypeHealthCheckStatusNotification PolicyAlertType = "health_check_status_notification"` - `const PolicyAlertTypeHostnameAopCustomCertificateExpirationType PolicyAlertType = "hostname_aop_custom_certificate_expiration_type"` - `const PolicyAlertTypeHTTPAlertEdgeError PolicyAlertType = "http_alert_edge_error"` - `const PolicyAlertTypeHTTPAlertOriginError PolicyAlertType = "http_alert_origin_error"` - `const PolicyAlertTypeImageNotification PolicyAlertType = "image_notification"` - `const PolicyAlertTypeImageResizingNotification PolicyAlertType = "image_resizing_notification"` - `const PolicyAlertTypeIncidentAlert PolicyAlertType = "incident_alert"` - `const PolicyAlertTypeLoadBalancingHealthAlert PolicyAlertType = "load_balancing_health_alert"` - `const PolicyAlertTypeLoadBalancingPoolEnablementAlert PolicyAlertType = "load_balancing_pool_enablement_alert"` - `const PolicyAlertTypeLogoMatchAlert PolicyAlertType = "logo_match_alert"` - `const PolicyAlertTypeMagicTunnelHealthCheckEvent PolicyAlertType = "magic_tunnel_health_check_event"` - `const PolicyAlertTypeMagicWANTunnelHealth PolicyAlertType = "magic_wan_tunnel_health"` - `const PolicyAlertTypeMaintenanceEventNotification PolicyAlertType = "maintenance_event_notification"` - `const PolicyAlertTypeMTLSCertificateStoreCertificateExpirationType PolicyAlertType = "mtls_certificate_store_certificate_expiration_type"` - `const PolicyAlertTypePagesEventAlert PolicyAlertType = "pages_event_alert"` - `const PolicyAlertTypeRadarNotification PolicyAlertType = "radar_notification"` - `const PolicyAlertTypeRealOriginMonitoring PolicyAlertType = "real_origin_monitoring"` - `const PolicyAlertTypeScriptmonitorAlertNewCodeChangeDetections PolicyAlertType = "scriptmonitor_alert_new_code_change_detections"` - `const PolicyAlertTypeScriptmonitorAlertNewHosts PolicyAlertType = "scriptmonitor_alert_new_hosts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousHosts PolicyAlertType = "scriptmonitor_alert_new_malicious_hosts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousScripts PolicyAlertType = "scriptmonitor_alert_new_malicious_scripts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousURL PolicyAlertType = "scriptmonitor_alert_new_malicious_url"` - `const PolicyAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PolicyAlertType = "scriptmonitor_alert_new_max_length_resource_url"` - `const PolicyAlertTypeScriptmonitorAlertNewResources PolicyAlertType = "scriptmonitor_alert_new_resources"` - `const PolicyAlertTypeSecondaryDNSAllPrimariesFailing PolicyAlertType = "secondary_dns_all_primaries_failing"` - `const PolicyAlertTypeSecondaryDNSPrimariesFailing PolicyAlertType = "secondary_dns_primaries_failing"` - `const PolicyAlertTypeSecondaryDNSWarning PolicyAlertType = "secondary_dns_warning"` - `const PolicyAlertTypeSecondaryDNSZoneSuccessfullyUpdated PolicyAlertType = "secondary_dns_zone_successfully_updated"` - `const PolicyAlertTypeSecondaryDNSZoneValidationWarning PolicyAlertType = "secondary_dns_zone_validation_warning"` - `const PolicyAlertTypeSecurityInsightsAlert PolicyAlertType = "security_insights_alert"` - `const PolicyAlertTypeSentinelAlert PolicyAlertType = "sentinel_alert"` - `const PolicyAlertTypeStreamLiveNotifications PolicyAlertType = "stream_live_notifications"` - `const PolicyAlertTypeSyntheticTestLatencyAlert PolicyAlertType = "synthetic_test_latency_alert"` - `const PolicyAlertTypeSyntheticTestLowAvailabilityAlert PolicyAlertType = "synthetic_test_low_availability_alert"` - `const PolicyAlertTypeTrafficAnomaliesAlert PolicyAlertType = "traffic_anomalies_alert"` - `const PolicyAlertTypeTunnelHealthEvent PolicyAlertType = "tunnel_health_event"` - `const PolicyAlertTypeTunnelUpdateEvent PolicyAlertType = "tunnel_update_event"` - `const PolicyAlertTypeUniversalSSLEventType PolicyAlertType = "universal_ssl_event_type"` - `const PolicyAlertTypeWebAnalyticsMetricsUpdate PolicyAlertType = "web_analytics_metrics_update"` - `const PolicyAlertTypeZoneAopCustomCertificateExpirationType PolicyAlertType = "zone_aop_custom_certificate_expiration_type"` - `Created Time` - `Description string` Optional description for the Notification policy. - `Enabled bool` Whether or not the Notification policy is enabled. - `Filters PolicyFilter` 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. - `Actions []string` Usage depends on specific alert type - `AffectedASNs []string` Used for configuring radar_notification - `AffectedComponents []string` Used for configuring incident_alert - `AffectedLocations []string` Used for configuring radar_notification - `AirportCode []string` Used for configuring maintenance_event_notification - `AlertTriggerPreferences []string` Usage depends on specific alert type - `AlertTriggerPreferencesValue []string` Usage depends on specific alert type - `Enabled []string` Used for configuring load_balancing_pool_enablement_alert - `Environment []string` Used for configuring pages_event_alert - `Event []string` Used for configuring pages_event_alert - `EventSource []string` Used for configuring load_balancing_health_alert - `EventType []string` Usage depends on specific alert type - `GroupBy []string` Usage depends on specific alert type - `HealthCheckID []string` Used for configuring health_check_status_notification - `IncidentImpact []PolicyFilterIncidentImpact` Used for configuring incident_alert - `const PolicyFilterIncidentImpactIncidentImpactNone PolicyFilterIncidentImpact = "INCIDENT_IMPACT_NONE"` - `const PolicyFilterIncidentImpactIncidentImpactMinor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MINOR"` - `const PolicyFilterIncidentImpactIncidentImpactMajor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MAJOR"` - `const PolicyFilterIncidentImpactIncidentImpactCritical PolicyFilterIncidentImpact = "INCIDENT_IMPACT_CRITICAL"` - `InputID []string` Used for configuring stream_live_notifications - `InsightClass []string` Used for configuring security_insights_alert - `Limit []string` Used for configuring billing_usage_alert - `LogoTag []string` Used for configuring logo_match_alert - `MegabitsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `NewHealth []string` Used for configuring load_balancing_health_alert - `NewStatus []string` Used for configuring tunnel_health_event - `PacketsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `PoolID []string` Usage depends on specific alert type - `POPNames []string` Usage depends on specific alert type - `Product []string` Used for configuring billing_usage_alert - `ProjectID []string` Used for configuring pages_event_alert - `Protocol []string` Used for configuring advanced_ddos_attack_l4_alert - `QueryTag []string` Usage depends on specific alert type - `RequestsPerSecond []string` Used for configuring advanced_ddos_attack_l7_alert - `Selectors []string` Usage depends on specific alert type - `Services []string` Used for configuring clickhouse_alert_fw_ent_anomaly - `Slo []string` Usage depends on specific alert type - `Status []string` Used for configuring health_check_status_notification - `TargetHostname []string` Used for configuring advanced_ddos_attack_l7_alert - `TargetIP []string` Used for configuring advanced_ddos_attack_l4_alert - `TargetZoneName []string` Used for configuring advanced_ddos_attack_l7_alert - `TrafficExclusions []PolicyFilterTrafficExclusion` Used for configuring traffic_anomalies_alert - `const PolicyFilterTrafficExclusionSecurityEvents PolicyFilterTrafficExclusion = "security_events"` - `TunnelID []string` Used for configuring tunnel_health_event - `TunnelName []string` Usage depends on specific alert type - `Type []string` Usage depends on specific alert type - `Where []string` Usage depends on specific alert type - `Zones []string` Usage depends on specific alert type - `Mechanisms Mechanism` List of IDs that will be used when dispatching a notification. IDs for email type will be the email address. - `Email []MechanismEmail` - `ID string` The email address - `Pagerduty []MechanismPagerduty` - `ID string` UUID - `Webhooks []MechanismWebhook` - `ID string` UUID - `Modified Time` - `Name string` Name of the policy. ### 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.Get( context.TODO(), "0da2b59ef118439d8097bdfb215203c9", alerting.PolicyGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) 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": "0da2b59ef118439d8097bdfb215203c9", "alert_interval": "30m", "alert_type": "universal_ssl_event_type", "created": "2014-01-01T05:20:00.12345Z", "description": "Something describing the policy.", "enabled": true, "filters": { "actions": [ "string" ], "affected_asns": [ "string" ], "affected_components": [ "string" ], "affected_locations": [ "string" ], "airport_code": [ "string" ], "alert_trigger_preferences": [ "string" ], "alert_trigger_preferences_value": [ "string" ], "enabled": [ "string" ], "environment": [ "string" ], "event": [ "string" ], "event_source": [ "string" ], "event_type": [ "string" ], "group_by": [ "string" ], "health_check_id": [ "string" ], "incident_impact": [ "INCIDENT_IMPACT_NONE" ], "input_id": [ "string" ], "insight_class": [ "string" ], "limit": [ "string" ], "logo_tag": [ "string" ], "megabits_per_second": [ "string" ], "new_health": [ "string" ], "new_status": [ "string" ], "packets_per_second": [ "string" ], "pool_id": [ "string" ], "pop_names": [ "string" ], "product": [ "string" ], "project_id": [ "string" ], "protocol": [ "string" ], "query_tag": [ "string" ], "requests_per_second": [ "string" ], "selectors": [ "string" ], "services": [ "string" ], "slo": [ "99.9" ], "status": [ "string" ], "target_hostname": [ "string" ], "target_ip": [ "string" ], "target_zone_name": [ "string" ], "traffic_exclusions": [ "security_events" ], "tunnel_id": [ "string" ], "tunnel_name": [ "string" ], "type": [ "string" ], "where": [ "string" ], "zones": [ "string" ] }, "mechanisms": { "email": [ { "id": "id" } ], "pagerduty": [ { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } ], "webhooks": [ { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } ] }, "modified": "2014-01-01T05:20:00.12345Z", "name": "SSL Notification Event Policy" } } ``` ## 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" } } ``` ## Update a Notification policy `client.Alerting.Policies.Update(ctx, policyID, params) (*PolicyUpdateResponse, error)` **put** `/accounts/{account_id}/alerting/v3/policies/{policy_id}` Update a Notification policy. ### Parameters - `policyID string` The unique identifier of a notification policy - `params PolicyUpdateParams` - `AccountID param.Field[string]` Path param: The account id - `AlertInterval param.Field[string]` Body param: Optional specification of how often to re-alert from the same incident, not support on all alert types. - `AlertType param.Field[PolicyUpdateParamsAlertType]` 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 PolicyUpdateParamsAlertTypeAbuseReportAlert PolicyUpdateParamsAlertType = "abuse_report_alert"` - `const PolicyUpdateParamsAlertTypeAccessCustomCertificateExpirationType PolicyUpdateParamsAlertType = "access_custom_certificate_expiration_type"` - `const PolicyUpdateParamsAlertTypeAdvancedDDoSAttackL4Alert PolicyUpdateParamsAlertType = "advanced_ddos_attack_l4_alert"` - `const PolicyUpdateParamsAlertTypeAdvancedDDoSAttackL7Alert PolicyUpdateParamsAlertType = "advanced_ddos_attack_l7_alert"` - `const PolicyUpdateParamsAlertTypeAdvancedHTTPAlertError PolicyUpdateParamsAlertType = "advanced_http_alert_error"` - `const PolicyUpdateParamsAlertTypeBGPHijackNotification PolicyUpdateParamsAlertType = "bgp_hijack_notification"` - `const PolicyUpdateParamsAlertTypeBillingUsageAlert PolicyUpdateParamsAlertType = "billing_usage_alert"` - `const PolicyUpdateParamsAlertTypeBlockNotificationBlockRemoved PolicyUpdateParamsAlertType = "block_notification_block_removed"` - `const PolicyUpdateParamsAlertTypeBlockNotificationNewBlock PolicyUpdateParamsAlertType = "block_notification_new_block"` - `const PolicyUpdateParamsAlertTypeBlockNotificationReviewRejected PolicyUpdateParamsAlertType = "block_notification_review_rejected"` - `const PolicyUpdateParamsAlertTypeBotTrafficBasicAlert PolicyUpdateParamsAlertType = "bot_traffic_basic_alert"` - `const PolicyUpdateParamsAlertTypeBrandProtectionAlert PolicyUpdateParamsAlertType = "brand_protection_alert"` - `const PolicyUpdateParamsAlertTypeBrandProtectionDigest PolicyUpdateParamsAlertType = "brand_protection_digest"` - `const PolicyUpdateParamsAlertTypeClickhouseAlertFwAnomaly PolicyUpdateParamsAlertType = "clickhouse_alert_fw_anomaly"` - `const PolicyUpdateParamsAlertTypeClickhouseAlertFwEntAnomaly PolicyUpdateParamsAlertType = "clickhouse_alert_fw_ent_anomaly"` - `const PolicyUpdateParamsAlertTypeCloudforceOneRequestNotification PolicyUpdateParamsAlertType = "cloudforce_one_request_notification"` - `const PolicyUpdateParamsAlertTypeCNIMaintenanceNotification PolicyUpdateParamsAlertType = "cni_maintenance_notification"` - `const PolicyUpdateParamsAlertTypeCustomAnalytics PolicyUpdateParamsAlertType = "custom_analytics"` - `const PolicyUpdateParamsAlertTypeCustomBotDetectionAlert PolicyUpdateParamsAlertType = "custom_bot_detection_alert"` - `const PolicyUpdateParamsAlertTypeCustomSSLCertificateEventType PolicyUpdateParamsAlertType = "custom_ssl_certificate_event_type"` - `const PolicyUpdateParamsAlertTypeDedicatedSSLCertificateEventType PolicyUpdateParamsAlertType = "dedicated_ssl_certificate_event_type"` - `const PolicyUpdateParamsAlertTypeDeviceConnectivityAnomalyAlert PolicyUpdateParamsAlertType = "device_connectivity_anomaly_alert"` - `const PolicyUpdateParamsAlertTypeDosAttackL4 PolicyUpdateParamsAlertType = "dos_attack_l4"` - `const PolicyUpdateParamsAlertTypeDosAttackL7 PolicyUpdateParamsAlertType = "dos_attack_l7"` - `const PolicyUpdateParamsAlertTypeExpiringServiceTokenAlert PolicyUpdateParamsAlertType = "expiring_service_token_alert"` - `const PolicyUpdateParamsAlertTypeFailingLogpushJobDisabledAlert PolicyUpdateParamsAlertType = "failing_logpush_job_disabled_alert"` - `const PolicyUpdateParamsAlertTypeFbmAutoAdvertisement PolicyUpdateParamsAlertType = "fbm_auto_advertisement"` - `const PolicyUpdateParamsAlertTypeFbmDosdAttack PolicyUpdateParamsAlertType = "fbm_dosd_attack"` - `const PolicyUpdateParamsAlertTypeFbmVolumetricAttack PolicyUpdateParamsAlertType = "fbm_volumetric_attack"` - `const PolicyUpdateParamsAlertTypeHealthCheckStatusNotification PolicyUpdateParamsAlertType = "health_check_status_notification"` - `const PolicyUpdateParamsAlertTypeHostnameAopCustomCertificateExpirationType PolicyUpdateParamsAlertType = "hostname_aop_custom_certificate_expiration_type"` - `const PolicyUpdateParamsAlertTypeHTTPAlertEdgeError PolicyUpdateParamsAlertType = "http_alert_edge_error"` - `const PolicyUpdateParamsAlertTypeHTTPAlertOriginError PolicyUpdateParamsAlertType = "http_alert_origin_error"` - `const PolicyUpdateParamsAlertTypeImageNotification PolicyUpdateParamsAlertType = "image_notification"` - `const PolicyUpdateParamsAlertTypeImageResizingNotification PolicyUpdateParamsAlertType = "image_resizing_notification"` - `const PolicyUpdateParamsAlertTypeIncidentAlert PolicyUpdateParamsAlertType = "incident_alert"` - `const PolicyUpdateParamsAlertTypeLoadBalancingHealthAlert PolicyUpdateParamsAlertType = "load_balancing_health_alert"` - `const PolicyUpdateParamsAlertTypeLoadBalancingPoolEnablementAlert PolicyUpdateParamsAlertType = "load_balancing_pool_enablement_alert"` - `const PolicyUpdateParamsAlertTypeLogoMatchAlert PolicyUpdateParamsAlertType = "logo_match_alert"` - `const PolicyUpdateParamsAlertTypeMagicTunnelHealthCheckEvent PolicyUpdateParamsAlertType = "magic_tunnel_health_check_event"` - `const PolicyUpdateParamsAlertTypeMagicWANTunnelHealth PolicyUpdateParamsAlertType = "magic_wan_tunnel_health"` - `const PolicyUpdateParamsAlertTypeMaintenanceEventNotification PolicyUpdateParamsAlertType = "maintenance_event_notification"` - `const PolicyUpdateParamsAlertTypeMTLSCertificateStoreCertificateExpirationType PolicyUpdateParamsAlertType = "mtls_certificate_store_certificate_expiration_type"` - `const PolicyUpdateParamsAlertTypePagesEventAlert PolicyUpdateParamsAlertType = "pages_event_alert"` - `const PolicyUpdateParamsAlertTypeRadarNotification PolicyUpdateParamsAlertType = "radar_notification"` - `const PolicyUpdateParamsAlertTypeRealOriginMonitoring PolicyUpdateParamsAlertType = "real_origin_monitoring"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewCodeChangeDetections PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_code_change_detections"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewHosts PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_hosts"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousHosts PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_hosts"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousScripts PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_scripts"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousURL PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_url"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_max_length_resource_url"` - `const PolicyUpdateParamsAlertTypeScriptmonitorAlertNewResources PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_resources"` - `const PolicyUpdateParamsAlertTypeSecondaryDNSAllPrimariesFailing PolicyUpdateParamsAlertType = "secondary_dns_all_primaries_failing"` - `const PolicyUpdateParamsAlertTypeSecondaryDNSPrimariesFailing PolicyUpdateParamsAlertType = "secondary_dns_primaries_failing"` - `const PolicyUpdateParamsAlertTypeSecondaryDNSWarning PolicyUpdateParamsAlertType = "secondary_dns_warning"` - `const PolicyUpdateParamsAlertTypeSecondaryDNSZoneSuccessfullyUpdated PolicyUpdateParamsAlertType = "secondary_dns_zone_successfully_updated"` - `const PolicyUpdateParamsAlertTypeSecondaryDNSZoneValidationWarning PolicyUpdateParamsAlertType = "secondary_dns_zone_validation_warning"` - `const PolicyUpdateParamsAlertTypeSecurityInsightsAlert PolicyUpdateParamsAlertType = "security_insights_alert"` - `const PolicyUpdateParamsAlertTypeSentinelAlert PolicyUpdateParamsAlertType = "sentinel_alert"` - `const PolicyUpdateParamsAlertTypeStreamLiveNotifications PolicyUpdateParamsAlertType = "stream_live_notifications"` - `const PolicyUpdateParamsAlertTypeSyntheticTestLatencyAlert PolicyUpdateParamsAlertType = "synthetic_test_latency_alert"` - `const PolicyUpdateParamsAlertTypeSyntheticTestLowAvailabilityAlert PolicyUpdateParamsAlertType = "synthetic_test_low_availability_alert"` - `const PolicyUpdateParamsAlertTypeTrafficAnomaliesAlert PolicyUpdateParamsAlertType = "traffic_anomalies_alert"` - `const PolicyUpdateParamsAlertTypeTunnelHealthEvent PolicyUpdateParamsAlertType = "tunnel_health_event"` - `const PolicyUpdateParamsAlertTypeTunnelUpdateEvent PolicyUpdateParamsAlertType = "tunnel_update_event"` - `const PolicyUpdateParamsAlertTypeUniversalSSLEventType PolicyUpdateParamsAlertType = "universal_ssl_event_type"` - `const PolicyUpdateParamsAlertTypeWebAnalyticsMetricsUpdate PolicyUpdateParamsAlertType = "web_analytics_metrics_update"` - `const PolicyUpdateParamsAlertTypeZoneAopCustomCertificateExpirationType PolicyUpdateParamsAlertType = "zone_aop_custom_certificate_expiration_type"` - `Description param.Field[string]` Body param: Optional description for the Notification policy. - `Enabled param.Field[bool]` Body param: Whether or not the Notification policy is enabled. - `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. - `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. ### Returns - `type PolicyUpdateResponse 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.Update( context.TODO(), "0da2b59ef118439d8097bdfb215203c9", alerting.PolicyUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) 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" } } ``` ## Delete a Notification policy `client.Alerting.Policies.Delete(ctx, policyID, body) (*PolicyDeleteResponse, error)` **delete** `/accounts/{account_id}/alerting/v3/policies/{policy_id}` Delete a Notification policy. ### Parameters - `policyID string` The unique identifier of a notification policy - `body PolicyDeleteParams` - `AccountID param.Field[string]` The account id ### Returns - `type PolicyDeleteResponse struct{…}` - `Errors []PolicyDeleteResponseError` - `Message string` - `Code int64` - `Messages []PolicyDeleteResponseMessage` - `Message string` - `Code int64` - `Success PolicyDeleteResponseSuccess` Whether the API call was successful - `const PolicyDeleteResponseSuccessTrue PolicyDeleteResponseSuccess = true` - `ResultInfo PolicyDeleteResponseResultInfo` - `Count float64` Total number of results for the requested service - `Page float64` Current page within paginated list of results - `PerPage float64` Number of results per page of results - `TotalCount float64` Total results available without any search parameters ### 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.Delete( context.TODO(), "0da2b59ef118439d8097bdfb215203c9", alerting.PolicyDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", policy.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### Mechanism - `type Mechanism struct{…}` List of IDs that will be used when dispatching a notification. IDs for email type will be the email address. - `Email []MechanismEmail` - `ID string` The email address - `Pagerduty []MechanismPagerduty` - `ID string` UUID - `Webhooks []MechanismWebhook` - `ID string` UUID ### Policy - `type Policy struct{…}` - `ID string` The unique identifier of a notification policy - `AlertInterval string` Optional specification of how often to re-alert from the same incident, not support on all alert types. - `AlertType PolicyAlertType` 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 PolicyAlertTypeAbuseReportAlert PolicyAlertType = "abuse_report_alert"` - `const PolicyAlertTypeAccessCustomCertificateExpirationType PolicyAlertType = "access_custom_certificate_expiration_type"` - `const PolicyAlertTypeAdvancedDDoSAttackL4Alert PolicyAlertType = "advanced_ddos_attack_l4_alert"` - `const PolicyAlertTypeAdvancedDDoSAttackL7Alert PolicyAlertType = "advanced_ddos_attack_l7_alert"` - `const PolicyAlertTypeAdvancedHTTPAlertError PolicyAlertType = "advanced_http_alert_error"` - `const PolicyAlertTypeBGPHijackNotification PolicyAlertType = "bgp_hijack_notification"` - `const PolicyAlertTypeBillingUsageAlert PolicyAlertType = "billing_usage_alert"` - `const PolicyAlertTypeBlockNotificationBlockRemoved PolicyAlertType = "block_notification_block_removed"` - `const PolicyAlertTypeBlockNotificationNewBlock PolicyAlertType = "block_notification_new_block"` - `const PolicyAlertTypeBlockNotificationReviewRejected PolicyAlertType = "block_notification_review_rejected"` - `const PolicyAlertTypeBotTrafficBasicAlert PolicyAlertType = "bot_traffic_basic_alert"` - `const PolicyAlertTypeBrandProtectionAlert PolicyAlertType = "brand_protection_alert"` - `const PolicyAlertTypeBrandProtectionDigest PolicyAlertType = "brand_protection_digest"` - `const PolicyAlertTypeClickhouseAlertFwAnomaly PolicyAlertType = "clickhouse_alert_fw_anomaly"` - `const PolicyAlertTypeClickhouseAlertFwEntAnomaly PolicyAlertType = "clickhouse_alert_fw_ent_anomaly"` - `const PolicyAlertTypeCloudforceOneRequestNotification PolicyAlertType = "cloudforce_one_request_notification"` - `const PolicyAlertTypeCNIMaintenanceNotification PolicyAlertType = "cni_maintenance_notification"` - `const PolicyAlertTypeCustomAnalytics PolicyAlertType = "custom_analytics"` - `const PolicyAlertTypeCustomBotDetectionAlert PolicyAlertType = "custom_bot_detection_alert"` - `const PolicyAlertTypeCustomSSLCertificateEventType PolicyAlertType = "custom_ssl_certificate_event_type"` - `const PolicyAlertTypeDedicatedSSLCertificateEventType PolicyAlertType = "dedicated_ssl_certificate_event_type"` - `const PolicyAlertTypeDeviceConnectivityAnomalyAlert PolicyAlertType = "device_connectivity_anomaly_alert"` - `const PolicyAlertTypeDosAttackL4 PolicyAlertType = "dos_attack_l4"` - `const PolicyAlertTypeDosAttackL7 PolicyAlertType = "dos_attack_l7"` - `const PolicyAlertTypeExpiringServiceTokenAlert PolicyAlertType = "expiring_service_token_alert"` - `const PolicyAlertTypeFailingLogpushJobDisabledAlert PolicyAlertType = "failing_logpush_job_disabled_alert"` - `const PolicyAlertTypeFbmAutoAdvertisement PolicyAlertType = "fbm_auto_advertisement"` - `const PolicyAlertTypeFbmDosdAttack PolicyAlertType = "fbm_dosd_attack"` - `const PolicyAlertTypeFbmVolumetricAttack PolicyAlertType = "fbm_volumetric_attack"` - `const PolicyAlertTypeHealthCheckStatusNotification PolicyAlertType = "health_check_status_notification"` - `const PolicyAlertTypeHostnameAopCustomCertificateExpirationType PolicyAlertType = "hostname_aop_custom_certificate_expiration_type"` - `const PolicyAlertTypeHTTPAlertEdgeError PolicyAlertType = "http_alert_edge_error"` - `const PolicyAlertTypeHTTPAlertOriginError PolicyAlertType = "http_alert_origin_error"` - `const PolicyAlertTypeImageNotification PolicyAlertType = "image_notification"` - `const PolicyAlertTypeImageResizingNotification PolicyAlertType = "image_resizing_notification"` - `const PolicyAlertTypeIncidentAlert PolicyAlertType = "incident_alert"` - `const PolicyAlertTypeLoadBalancingHealthAlert PolicyAlertType = "load_balancing_health_alert"` - `const PolicyAlertTypeLoadBalancingPoolEnablementAlert PolicyAlertType = "load_balancing_pool_enablement_alert"` - `const PolicyAlertTypeLogoMatchAlert PolicyAlertType = "logo_match_alert"` - `const PolicyAlertTypeMagicTunnelHealthCheckEvent PolicyAlertType = "magic_tunnel_health_check_event"` - `const PolicyAlertTypeMagicWANTunnelHealth PolicyAlertType = "magic_wan_tunnel_health"` - `const PolicyAlertTypeMaintenanceEventNotification PolicyAlertType = "maintenance_event_notification"` - `const PolicyAlertTypeMTLSCertificateStoreCertificateExpirationType PolicyAlertType = "mtls_certificate_store_certificate_expiration_type"` - `const PolicyAlertTypePagesEventAlert PolicyAlertType = "pages_event_alert"` - `const PolicyAlertTypeRadarNotification PolicyAlertType = "radar_notification"` - `const PolicyAlertTypeRealOriginMonitoring PolicyAlertType = "real_origin_monitoring"` - `const PolicyAlertTypeScriptmonitorAlertNewCodeChangeDetections PolicyAlertType = "scriptmonitor_alert_new_code_change_detections"` - `const PolicyAlertTypeScriptmonitorAlertNewHosts PolicyAlertType = "scriptmonitor_alert_new_hosts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousHosts PolicyAlertType = "scriptmonitor_alert_new_malicious_hosts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousScripts PolicyAlertType = "scriptmonitor_alert_new_malicious_scripts"` - `const PolicyAlertTypeScriptmonitorAlertNewMaliciousURL PolicyAlertType = "scriptmonitor_alert_new_malicious_url"` - `const PolicyAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PolicyAlertType = "scriptmonitor_alert_new_max_length_resource_url"` - `const PolicyAlertTypeScriptmonitorAlertNewResources PolicyAlertType = "scriptmonitor_alert_new_resources"` - `const PolicyAlertTypeSecondaryDNSAllPrimariesFailing PolicyAlertType = "secondary_dns_all_primaries_failing"` - `const PolicyAlertTypeSecondaryDNSPrimariesFailing PolicyAlertType = "secondary_dns_primaries_failing"` - `const PolicyAlertTypeSecondaryDNSWarning PolicyAlertType = "secondary_dns_warning"` - `const PolicyAlertTypeSecondaryDNSZoneSuccessfullyUpdated PolicyAlertType = "secondary_dns_zone_successfully_updated"` - `const PolicyAlertTypeSecondaryDNSZoneValidationWarning PolicyAlertType = "secondary_dns_zone_validation_warning"` - `const PolicyAlertTypeSecurityInsightsAlert PolicyAlertType = "security_insights_alert"` - `const PolicyAlertTypeSentinelAlert PolicyAlertType = "sentinel_alert"` - `const PolicyAlertTypeStreamLiveNotifications PolicyAlertType = "stream_live_notifications"` - `const PolicyAlertTypeSyntheticTestLatencyAlert PolicyAlertType = "synthetic_test_latency_alert"` - `const PolicyAlertTypeSyntheticTestLowAvailabilityAlert PolicyAlertType = "synthetic_test_low_availability_alert"` - `const PolicyAlertTypeTrafficAnomaliesAlert PolicyAlertType = "traffic_anomalies_alert"` - `const PolicyAlertTypeTunnelHealthEvent PolicyAlertType = "tunnel_health_event"` - `const PolicyAlertTypeTunnelUpdateEvent PolicyAlertType = "tunnel_update_event"` - `const PolicyAlertTypeUniversalSSLEventType PolicyAlertType = "universal_ssl_event_type"` - `const PolicyAlertTypeWebAnalyticsMetricsUpdate PolicyAlertType = "web_analytics_metrics_update"` - `const PolicyAlertTypeZoneAopCustomCertificateExpirationType PolicyAlertType = "zone_aop_custom_certificate_expiration_type"` - `Created Time` - `Description string` Optional description for the Notification policy. - `Enabled bool` Whether or not the Notification policy is enabled. - `Filters PolicyFilter` 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. - `Actions []string` Usage depends on specific alert type - `AffectedASNs []string` Used for configuring radar_notification - `AffectedComponents []string` Used for configuring incident_alert - `AffectedLocations []string` Used for configuring radar_notification - `AirportCode []string` Used for configuring maintenance_event_notification - `AlertTriggerPreferences []string` Usage depends on specific alert type - `AlertTriggerPreferencesValue []string` Usage depends on specific alert type - `Enabled []string` Used for configuring load_balancing_pool_enablement_alert - `Environment []string` Used for configuring pages_event_alert - `Event []string` Used for configuring pages_event_alert - `EventSource []string` Used for configuring load_balancing_health_alert - `EventType []string` Usage depends on specific alert type - `GroupBy []string` Usage depends on specific alert type - `HealthCheckID []string` Used for configuring health_check_status_notification - `IncidentImpact []PolicyFilterIncidentImpact` Used for configuring incident_alert - `const PolicyFilterIncidentImpactIncidentImpactNone PolicyFilterIncidentImpact = "INCIDENT_IMPACT_NONE"` - `const PolicyFilterIncidentImpactIncidentImpactMinor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MINOR"` - `const PolicyFilterIncidentImpactIncidentImpactMajor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MAJOR"` - `const PolicyFilterIncidentImpactIncidentImpactCritical PolicyFilterIncidentImpact = "INCIDENT_IMPACT_CRITICAL"` - `InputID []string` Used for configuring stream_live_notifications - `InsightClass []string` Used for configuring security_insights_alert - `Limit []string` Used for configuring billing_usage_alert - `LogoTag []string` Used for configuring logo_match_alert - `MegabitsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `NewHealth []string` Used for configuring load_balancing_health_alert - `NewStatus []string` Used for configuring tunnel_health_event - `PacketsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `PoolID []string` Usage depends on specific alert type - `POPNames []string` Usage depends on specific alert type - `Product []string` Used for configuring billing_usage_alert - `ProjectID []string` Used for configuring pages_event_alert - `Protocol []string` Used for configuring advanced_ddos_attack_l4_alert - `QueryTag []string` Usage depends on specific alert type - `RequestsPerSecond []string` Used for configuring advanced_ddos_attack_l7_alert - `Selectors []string` Usage depends on specific alert type - `Services []string` Used for configuring clickhouse_alert_fw_ent_anomaly - `Slo []string` Usage depends on specific alert type - `Status []string` Used for configuring health_check_status_notification - `TargetHostname []string` Used for configuring advanced_ddos_attack_l7_alert - `TargetIP []string` Used for configuring advanced_ddos_attack_l4_alert - `TargetZoneName []string` Used for configuring advanced_ddos_attack_l7_alert - `TrafficExclusions []PolicyFilterTrafficExclusion` Used for configuring traffic_anomalies_alert - `const PolicyFilterTrafficExclusionSecurityEvents PolicyFilterTrafficExclusion = "security_events"` - `TunnelID []string` Used for configuring tunnel_health_event - `TunnelName []string` Usage depends on specific alert type - `Type []string` Usage depends on specific alert type - `Where []string` Usage depends on specific alert type - `Zones []string` Usage depends on specific alert type - `Mechanisms Mechanism` List of IDs that will be used when dispatching a notification. IDs for email type will be the email address. - `Email []MechanismEmail` - `ID string` The email address - `Pagerduty []MechanismPagerduty` - `ID string` UUID - `Webhooks []MechanismWebhook` - `ID string` UUID - `Modified Time` - `Name string` Name of the policy. ### Policy Filter - `type PolicyFilter struct{…}` 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. - `Actions []string` Usage depends on specific alert type - `AffectedASNs []string` Used for configuring radar_notification - `AffectedComponents []string` Used for configuring incident_alert - `AffectedLocations []string` Used for configuring radar_notification - `AirportCode []string` Used for configuring maintenance_event_notification - `AlertTriggerPreferences []string` Usage depends on specific alert type - `AlertTriggerPreferencesValue []string` Usage depends on specific alert type - `Enabled []string` Used for configuring load_balancing_pool_enablement_alert - `Environment []string` Used for configuring pages_event_alert - `Event []string` Used for configuring pages_event_alert - `EventSource []string` Used for configuring load_balancing_health_alert - `EventType []string` Usage depends on specific alert type - `GroupBy []string` Usage depends on specific alert type - `HealthCheckID []string` Used for configuring health_check_status_notification - `IncidentImpact []PolicyFilterIncidentImpact` Used for configuring incident_alert - `const PolicyFilterIncidentImpactIncidentImpactNone PolicyFilterIncidentImpact = "INCIDENT_IMPACT_NONE"` - `const PolicyFilterIncidentImpactIncidentImpactMinor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MINOR"` - `const PolicyFilterIncidentImpactIncidentImpactMajor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MAJOR"` - `const PolicyFilterIncidentImpactIncidentImpactCritical PolicyFilterIncidentImpact = "INCIDENT_IMPACT_CRITICAL"` - `InputID []string` Used for configuring stream_live_notifications - `InsightClass []string` Used for configuring security_insights_alert - `Limit []string` Used for configuring billing_usage_alert - `LogoTag []string` Used for configuring logo_match_alert - `MegabitsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `NewHealth []string` Used for configuring load_balancing_health_alert - `NewStatus []string` Used for configuring tunnel_health_event - `PacketsPerSecond []string` Used for configuring advanced_ddos_attack_l4_alert - `PoolID []string` Usage depends on specific alert type - `POPNames []string` Usage depends on specific alert type - `Product []string` Used for configuring billing_usage_alert - `ProjectID []string` Used for configuring pages_event_alert - `Protocol []string` Used for configuring advanced_ddos_attack_l4_alert - `QueryTag []string` Usage depends on specific alert type - `RequestsPerSecond []string` Used for configuring advanced_ddos_attack_l7_alert - `Selectors []string` Usage depends on specific alert type - `Services []string` Used for configuring clickhouse_alert_fw_ent_anomaly - `Slo []string` Usage depends on specific alert type - `Status []string` Used for configuring health_check_status_notification - `TargetHostname []string` Used for configuring advanced_ddos_attack_l7_alert - `TargetIP []string` Used for configuring advanced_ddos_attack_l4_alert - `TargetZoneName []string` Used for configuring advanced_ddos_attack_l7_alert - `TrafficExclusions []PolicyFilterTrafficExclusion` Used for configuring traffic_anomalies_alert - `const PolicyFilterTrafficExclusionSecurityEvents PolicyFilterTrafficExclusion = "security_events"` - `TunnelID []string` Used for configuring tunnel_health_event - `TunnelName []string` Usage depends on specific alert type - `Type []string` Usage depends on specific alert type - `Where []string` Usage depends on specific alert type - `Zones []string` Usage depends on specific alert type # Silences ## List Silences `client.Alerting.Silences.List(ctx, query) (*SinglePage[SilenceListResponse], error)` **get** `/accounts/{account_id}/alerting/v3/silences` Gets a list of silences for an account. ### Parameters - `query SilenceListParams` - `AccountID param.Field[string]` The account id ### Returns - `type SilenceListResponse struct{…}` - `ID string` Silence ID - `CreatedAt string` When the silence was created. - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. - `UpdatedAt string` When the silence was modified. ### 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"), ) page, err := client.Alerting.Silences.List(context.TODO(), alerting.SilenceListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "f878e90c23f44126ae3cfc399f646977", "created_at": "2022-01-01T00:00:00Z", "end_time": "2022-01-01T00:00:00Z", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "start_time": "2022-01-01T00:00:00Z", "updated_at": "2022-01-01T00:00:00Z" } ] } ``` ## Get Silence `client.Alerting.Silences.Get(ctx, silenceID, query) (*SilenceGetResponse, error)` **get** `/accounts/{account_id}/alerting/v3/silences/{silence_id}` Gets a specific silence for an account. ### Parameters - `silenceID string` Silence ID - `query SilenceGetParams` - `AccountID param.Field[string]` The account id ### Returns - `type SilenceGetResponse struct{…}` - `ID string` Silence ID - `CreatedAt string` When the silence was created. - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. - `UpdatedAt string` When the silence was modified. ### 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"), ) silence, err := client.Alerting.Silences.Get( context.TODO(), "f878e90c23f44126ae3cfc399f646977", alerting.SilenceGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", silence.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f878e90c23f44126ae3cfc399f646977", "created_at": "2022-01-01T00:00:00Z", "end_time": "2022-01-01T00:00:00Z", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "start_time": "2022-01-01T00:00:00Z", "updated_at": "2022-01-01T00:00:00Z" } } ``` ## Create Silences `client.Alerting.Silences.New(ctx, params) (*SilenceNewResponse, error)` **post** `/accounts/{account_id}/alerting/v3/silences` Creates a new silence for an account. ### Parameters - `params SilenceNewParams` - `AccountID param.Field[string]` Path param: The account id - `Body param.Field[[]SilenceNewParamsBody]` Body param - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. ### Returns - `type SilenceNewResponse struct{…}` - `Errors []SilenceNewResponseError` - `Message string` - `Code int64` - `Messages []SilenceNewResponseMessage` - `Message string` - `Code int64` - `Success SilenceNewResponseSuccess` Whether the API call was successful - `const SilenceNewResponseSuccessTrue SilenceNewResponseSuccess = true` ### 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"), ) silence, err := client.Alerting.Silences.New(context.TODO(), alerting.SilenceNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: []alerting.SilenceNewParamsBody{alerting.SilenceNewParamsBody{ }}, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", silence.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Update Silences `client.Alerting.Silences.Update(ctx, params) (*SinglePage[SilenceUpdateResponse], error)` **put** `/accounts/{account_id}/alerting/v3/silences` Updates existing silences for an account. ### Parameters - `params SilenceUpdateParams` - `AccountID param.Field[string]` Path param: The account id - `Body param.Field[[]SilenceUpdateParamsBody]` Body param - `ID string` Silence ID - `EndTime string` When the silence ends. - `StartTime string` When the silence starts. ### Returns - `type SilenceUpdateResponse struct{…}` - `ID string` Silence ID - `CreatedAt string` When the silence was created. - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. - `UpdatedAt string` When the silence was modified. ### 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"), ) page, err := client.Alerting.Silences.Update(context.TODO(), alerting.SilenceUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: []alerting.SilenceUpdateParamsBody{alerting.SilenceUpdateParamsBody{ }}, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "f878e90c23f44126ae3cfc399f646977", "created_at": "2022-01-01T00:00:00Z", "end_time": "2022-01-01T00:00:00Z", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "start_time": "2022-01-01T00:00:00Z", "updated_at": "2022-01-01T00:00:00Z" } ] } ``` ## Delete Silence `client.Alerting.Silences.Delete(ctx, silenceID, body) (*SilenceDeleteResponse, error)` **delete** `/accounts/{account_id}/alerting/v3/silences/{silence_id}` Deletes an existing silence for an account. ### Parameters - `silenceID string` Silence ID - `body SilenceDeleteParams` - `AccountID param.Field[string]` The account id ### Returns - `type SilenceDeleteResponse struct{…}` - `Errors []SilenceDeleteResponseError` - `Message string` - `Code int64` - `Messages []SilenceDeleteResponseMessage` - `Message string` - `Code int64` - `Success SilenceDeleteResponseSuccess` Whether the API call was successful - `const SilenceDeleteResponseSuccessTrue SilenceDeleteResponseSuccess = true` ### 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"), ) silence, err := client.Alerting.Silences.Delete( context.TODO(), "f878e90c23f44126ae3cfc399f646977", alerting.SilenceDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", silence.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ```