# Destinations # Eligible ## Get delivery mechanism eligibility `alerting.destinations.eligible.get(EligibleGetParams**kwargs) -> EligibleGetResponse` **get** `/accounts/{account_id}/alerting/v3/destinations/eligible` Get a list of all delivery mechanism types for which an account is eligible. ### Parameters - `account_id: str` The account id ### Returns - `Dict[str, List[EligibleGetResponseItem]]` - `eligible: Optional[bool]` Determines whether or not the account is eligible for the delivery mechanism. - `ready: Optional[bool]` Beta flag. Users can create a policy with a mechanism that is not ready, but we cannot guarantee successful delivery of notifications. - `type: Optional[Literal["email", "pagerduty", "webhook"]]` Determines type of delivery mechanism. - `"email"` - `"pagerduty"` - `"webhook"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) eligible = client.alerting.destinations.eligible.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(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 - `Dict[str, List[EligibleGetResponseItem]]` - `eligible: Optional[bool]` Determines whether or not the account is eligible for the delivery mechanism. - `ready: Optional[bool]` Beta flag. Users can create a policy with a mechanism that is not ready, but we cannot guarantee successful delivery of notifications. - `type: Optional[Literal["email", "pagerduty", "webhook"]]` Determines type of delivery mechanism. - `"email"` - `"pagerduty"` - `"webhook"` # Pagerduty ## List PagerDuty services `alerting.destinations.pagerduty.get(PagerdutyGetParams**kwargs) -> SyncSinglePage[Pagerduty]` **get** `/accounts/{account_id}/alerting/v3/destinations/pagerduty` Get a list of all configured PagerDuty services. ### Parameters - `account_id: str` The account id ### Returns - `class Pagerduty: …` - `id: Optional[str]` UUID - `name: Optional[str]` The name of the pagerduty service. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.alerting.destinations.pagerduty.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.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 `alerting.destinations.pagerduty.create(PagerdutyCreateParams**kwargs) -> PagerdutyCreateResponse` **post** `/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect` Creates a new token for integrating with PagerDuty. ### Parameters - `account_id: str` The account id ### Returns - `class PagerdutyCreateResponse: …` - `id: Optional[str]` token in form of UUID ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) pagerduty = client.alerting.destinations.pagerduty.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(pagerduty.id) ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "a313ba7d3e464c0ea40808fafbc3816a" } } ``` ## Delete PagerDuty Services `alerting.destinations.pagerduty.delete(PagerdutyDeleteParams**kwargs) -> PagerdutyDeleteResponse` **delete** `/accounts/{account_id}/alerting/v3/destinations/pagerduty` Deletes all the PagerDuty Services connected to the account. ### Parameters - `account_id: str` The account id ### Returns - `class PagerdutyDeleteResponse: …` - `errors: List[Error]` - `message: str` - `code: Optional[int]` - `messages: List[Message]` - `message: str` - `code: Optional[int]` - `success: Literal[true]` Whether the API call was successful - `true` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) pagerduty = client.alerting.destinations.pagerduty.delete( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(pagerduty.errors) ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Connect PagerDuty `alerting.destinations.pagerduty.link(strtoken_id, PagerdutyLinkParams**kwargs) -> PagerdutyLinkResponse` **get** `/accounts/{account_id}/alerting/v3/destinations/pagerduty/connect/{token_id}` Links PagerDuty with the account using the integration token. ### Parameters - `account_id: str` The account id - `token_id: str` The token integration key ### Returns - `class PagerdutyLinkResponse: …` - `id: Optional[str]` UUID ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.alerting.destinations.pagerduty.link( token_id="8c71e667571b4f61b94d9e4b12158038", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(response.id) ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Domain Types ### Pagerduty - `class Pagerduty: …` - `id: Optional[str]` UUID - `name: Optional[str]` The name of the pagerduty service. ### Pagerduty Create Response - `class PagerdutyCreateResponse: …` - `id: Optional[str]` token in form of UUID ### Pagerduty Delete Response - `class PagerdutyDeleteResponse: …` - `errors: List[Error]` - `message: str` - `code: Optional[int]` - `messages: List[Message]` - `message: str` - `code: Optional[int]` - `success: Literal[true]` Whether the API call was successful - `true` ### Pagerduty Link Response - `class PagerdutyLinkResponse: …` - `id: Optional[str]` UUID # Webhooks ## List webhooks `alerting.destinations.webhooks.list(WebhookListParams**kwargs) -> SyncSinglePage[Webhooks]` **get** `/accounts/{account_id}/alerting/v3/destinations/webhooks` Gets a list of all configured webhook destinations. ### Parameters - `account_id: str` The account id ### Returns - `class Webhooks: …` - `id: Optional[str]` The unique identifier of a webhook - `created_at: Optional[datetime]` Timestamp of when the webhook destination was created. - `last_failure: Optional[datetime]` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `last_success: Optional[datetime]` Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. - `name: Optional[str]` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `secret: Optional[str]` 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: Optional[Literal["datadog", "discord", "feishu", 5 more]]` Type of webhook endpoint. - `"datadog"` - `"discord"` - `"feishu"` - `"gchat"` - `"generic"` - `"opsgenie"` - `"slack"` - `"splunk"` - `url: Optional[str]` The POST endpoint to call when dispatching a notification. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.alerting.destinations.webhooks.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.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 `alerting.destinations.webhooks.get(strwebhook_id, WebhookGetParams**kwargs) -> Webhooks` **get** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Get details for a single webhooks destination. ### Parameters - `account_id: str` The account id - `webhook_id: str` The unique identifier of a webhook ### Returns - `class Webhooks: …` - `id: Optional[str]` The unique identifier of a webhook - `created_at: Optional[datetime]` Timestamp of when the webhook destination was created. - `last_failure: Optional[datetime]` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `last_success: Optional[datetime]` Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. - `name: Optional[str]` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `secret: Optional[str]` 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: Optional[Literal["datadog", "discord", "feishu", 5 more]]` Type of webhook endpoint. - `"datadog"` - `"discord"` - `"feishu"` - `"gchat"` - `"generic"` - `"opsgenie"` - `"slack"` - `"splunk"` - `url: Optional[str]` The POST endpoint to call when dispatching a notification. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhooks = client.alerting.destinations.webhooks.get( webhook_id="b115d5ec15c641ee8b7692c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(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 `alerting.destinations.webhooks.create(WebhookCreateParams**kwargs) -> WebhookCreateResponse` **post** `/accounts/{account_id}/alerting/v3/destinations/webhooks` Creates a new webhook destination. ### Parameters - `account_id: str` The account id - `name: str` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `url: str` The POST endpoint to call when dispatching a notification. - `secret: Optional[str]` 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 - `class WebhookCreateResponse: …` - `id: Optional[str]` UUID ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhook = client.alerting.destinations.webhooks.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", name="Slack Webhook", url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) print(webhook.id) ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Update a webhook `alerting.destinations.webhooks.update(strwebhook_id, WebhookUpdateParams**kwargs) -> WebhookUpdateResponse` **put** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Update a webhook destination. ### Parameters - `account_id: str` The account id - `webhook_id: str` The unique identifier of a webhook - `name: str` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `url: str` The POST endpoint to call when dispatching a notification. - `secret: Optional[str]` 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 - `class WebhookUpdateResponse: …` - `id: Optional[str]` UUID ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhook = client.alerting.destinations.webhooks.update( webhook_id="b115d5ec15c641ee8b7692c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", name="Slack Webhook", url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) print(webhook.id) ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f174e90afafe4643bbbc4a0ed4fc8415" } } ``` ## Delete a webhook `alerting.destinations.webhooks.delete(strwebhook_id, WebhookDeleteParams**kwargs) -> WebhookDeleteResponse` **delete** `/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}` Delete a configured webhook destination. ### Parameters - `account_id: str` The account id - `webhook_id: str` The unique identifier of a webhook ### Returns - `class WebhookDeleteResponse: …` - `errors: List[Error]` - `message: str` - `code: Optional[int]` - `messages: List[Message]` - `message: str` - `code: Optional[int]` - `success: Literal[true]` Whether the API call was successful - `true` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhook = client.alerting.destinations.webhooks.delete( webhook_id="b115d5ec15c641ee8b7692c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(webhook.errors) ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Domain Types ### Webhooks - `class Webhooks: …` - `id: Optional[str]` The unique identifier of a webhook - `created_at: Optional[datetime]` Timestamp of when the webhook destination was created. - `last_failure: Optional[datetime]` Timestamp of the last time an attempt to dispatch a notification to this webhook failed. - `last_success: Optional[datetime]` Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. - `name: Optional[str]` The name of the webhook destination. This will be included in the request body when you receive a webhook notification. - `secret: Optional[str]` 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: Optional[Literal["datadog", "discord", "feishu", 5 more]]` Type of webhook endpoint. - `"datadog"` - `"discord"` - `"feishu"` - `"gchat"` - `"generic"` - `"opsgenie"` - `"slack"` - `"splunk"` - `url: Optional[str]` The POST endpoint to call when dispatching a notification. ### Webhook Create Response - `class WebhookCreateResponse: …` - `id: Optional[str]` UUID ### Webhook Update Response - `class WebhookUpdateResponse: …` - `id: Optional[str]` UUID ### Webhook Delete Response - `class WebhookDeleteResponse: …` - `errors: List[Error]` - `message: str` - `code: Optional[int]` - `messages: List[Message]` - `message: str` - `code: Optional[int]` - `success: Literal[true]` Whether the API call was successful - `true`