# Destinations # Eligible ## Get delivery mechanism eligibility `client.alerting.destinations.eligible.get(EligibleGetParamsparams, RequestOptionsoptions?): EligibleGetResponse` **get** `/accounts/{account_id}/alerting/v3/destinations/eligible` Get a list of all delivery mechanism types for which an account is eligible. ### Parameters - `params: EligibleGetParams` - `account_id: string` The account id ### Returns - `EligibleGetResponse = Record>` - `eligible?: boolean` Determines whether or not the account is eligible for the delivery mechanism. - `ready?: boolean` Beta flag. Users can create a policy with a mechanism that is not ready, but we cannot guarantee successful delivery of notifications. - `type?: "email" | "pagerduty" | "webhook"` Determines type of delivery mechanism. - `"email"` - `"pagerduty"` - `"webhook"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const eligible = await client.alerting.destinations.eligible.get({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(eligible); ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "foo": [ { "eligible": true, "ready": true, "type": "email" } ] } } ``` ## Domain Types ### Eligible Get Response - `EligibleGetResponse = Record>` - `eligible?: boolean` Determines whether or not the account is eligible for the delivery mechanism. - `ready?: boolean` Beta flag. Users can create a policy with a mechanism that is not ready, but we cannot guarantee successful delivery of notifications. - `type?: "email" | "pagerduty" | "webhook"` Determines type of delivery mechanism. - `"email"` - `"pagerduty"` - `"webhook"` # Pagerduty ## List PagerDuty services `client.alerting.destinations.pagerduty.get(PagerdutyGetParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/alerting/v3/destinations/pagerduty` Get a list of all configured PagerDuty services. ### Parameters - `params: PagerdutyGetParams` - `account_id: string` The account id ### Returns - `Pagerduty` - `id?: string` UUID - `name?: string` The name of the pagerduty service. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const pagerduty of client.alerting.destinations.pagerduty.get({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(pagerduty.id); } ``` #### 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.create(PagerdutyCreateParamsparams, RequestOptionsoptions?): PagerdutyCreateResponse` **post** `/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect` Creates a new token for integrating with PagerDuty. ### Parameters - `params: PagerdutyCreateParams` - `account_id: string` The account id ### Returns - `PagerdutyCreateResponse` - `id?: string` token in form of UUID ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const pagerduty = await client.alerting.destinations.pagerduty.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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(PagerdutyDeleteParamsparams, RequestOptionsoptions?): PagerdutyDeleteResponse` **delete** `/accounts/{account_id}/alerting/v3/destinations/pagerduty` Deletes all the PagerDuty Services connected to the account. ### Parameters - `params: PagerdutyDeleteParams` - `account_id: string` The account id ### Returns - `PagerdutyDeleteResponse` - `errors: Array` - `message: string` - `code?: number` - `messages: Array` - `message: string` - `code?: number` - `success: true` Whether the API call was successful - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const pagerduty = await client.alerting.destinations.pagerduty.delete({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(pagerduty.errors); ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Connect PagerDuty `client.alerting.destinations.pagerduty.link(stringtokenId, PagerdutyLinkParamsparams, RequestOptionsoptions?): PagerdutyLinkResponse` **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 - `params: PagerdutyLinkParams` - `account_id: string` The account id ### Returns - `PagerdutyLinkResponse` - `id?: string` UUID ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.alerting.destinations.pagerduty.link( '8c71e667571b4f61b94d9e4b12158038', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(response.id); ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Domain Types ### Pagerduty - `Pagerduty` - `id?: string` UUID - `name?: string` The name of the pagerduty service. ### Pagerduty Create Response - `PagerdutyCreateResponse` - `id?: string` token in form of UUID ### Pagerduty Delete Response - `PagerdutyDeleteResponse` - `errors: Array` - `message: string` - `code?: number` - `messages: Array` - `message: string` - `code?: number` - `success: true` Whether the API call was successful - `true` ### Pagerduty Link Response - `PagerdutyLinkResponse` - `id?: string` UUID # Webhooks ## List webhooks `client.alerting.destinations.webhooks.list(WebhookListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/alerting/v3/destinations/webhooks` Gets a list of all configured webhook destinations. ### Parameters - `params: WebhookListParams` - `account_id: string` The account id ### Returns - `Webhooks` - `id?: string` The unique identifier of a webhook - `created_at?: string` Timestamp of when the webhook destination was created. - `last_failure?: string` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `last_success?: string` 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?: "datadog" | "discord" | "feishu" | 5 more` Type of webhook endpoint. - `"datadog"` - `"discord"` - `"feishu"` - `"gchat"` - `"generic"` - `"opsgenie"` - `"slack"` - `"splunk"` - `url?: string` The POST endpoint to call when dispatching a notification. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const webhooks of client.alerting.destinations.webhooks.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(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" } ] } ``` ## Get a webhook `client.alerting.destinations.webhooks.get(stringwebhookId, WebhookGetParamsparams, RequestOptionsoptions?): Webhooks` **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 - `params: WebhookGetParams` - `account_id: string` The account id ### Returns - `Webhooks` - `id?: string` The unique identifier of a webhook - `created_at?: string` Timestamp of when the webhook destination was created. - `last_failure?: string` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `last_success?: string` 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?: "datadog" | "discord" | "feishu" | 5 more` Type of webhook endpoint. - `"datadog"` - `"discord"` - `"feishu"` - `"gchat"` - `"generic"` - `"opsgenie"` - `"slack"` - `"splunk"` - `url?: string` The POST endpoint to call when dispatching a notification. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const webhooks = await client.alerting.destinations.webhooks.get( 'b115d5ec15c641ee8b7692c449b5227b', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(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.create(WebhookCreateParamsparams, RequestOptionsoptions?): WebhookCreateResponse` **post** `/accounts/{account_id}/alerting/v3/destinations/webhooks` Creates a new webhook destination. ### Parameters - `params: WebhookCreateParams` - `account_id: string` Path param: The account id - `name: string` Body param: The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `url: string` Body param: The POST endpoint to call when dispatching a notification. - `secret?: 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 - `WebhookCreateResponse` - `id?: string` UUID ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const webhook = await client.alerting.destinations.webhooks.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'Slack Webhook', url: 'https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd', }); console.log(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(stringwebhookId, WebhookUpdateParamsparams, RequestOptionsoptions?): WebhookUpdateResponse` **put** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Update a webhook destination. ### Parameters - `webhookId: string` The unique identifier of a webhook - `params: WebhookUpdateParams` - `account_id: string` Path param: The account id - `name: string` Body param: The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `url: string` Body param: The POST endpoint to call when dispatching a notification. - `secret?: 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 - `WebhookUpdateResponse` - `id?: string` UUID ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const webhook = await client.alerting.destinations.webhooks.update( 'b115d5ec15c641ee8b7692c449b5227b', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'Slack Webhook', url: 'https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd', }, ); console.log(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(stringwebhookId, WebhookDeleteParamsparams, RequestOptionsoptions?): WebhookDeleteResponse` **delete** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Delete a configured webhook destination. ### Parameters - `webhookId: string` The unique identifier of a webhook - `params: WebhookDeleteParams` - `account_id: string` The account id ### Returns - `WebhookDeleteResponse` - `errors: Array` - `message: string` - `code?: number` - `messages: Array` - `message: string` - `code?: number` - `success: true` Whether the API call was successful - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const webhook = await client.alerting.destinations.webhooks.delete( 'b115d5ec15c641ee8b7692c449b5227b', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(webhook.errors); ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Domain Types ### Webhooks - `Webhooks` - `id?: string` The unique identifier of a webhook - `created_at?: string` Timestamp of when the webhook destination was created. - `last_failure?: string` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `last_success?: string` 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?: "datadog" | "discord" | "feishu" | 5 more` Type of webhook endpoint. - `"datadog"` - `"discord"` - `"feishu"` - `"gchat"` - `"generic"` - `"opsgenie"` - `"slack"` - `"splunk"` - `url?: string` The POST endpoint to call when dispatching a notification. ### Webhook Create Response - `WebhookCreateResponse` - `id?: string` UUID ### Webhook Update Response - `WebhookUpdateResponse` - `id?: string` UUID ### Webhook Delete Response - `WebhookDeleteResponse` - `errors: Array` - `message: string` - `code?: number` - `messages: Array` - `message: string` - `code?: number` - `success: true` Whether the API call was successful - `true`