# 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.