webhooks
Creates, updates, deletes, gets or lists a webhooks resource.
Overview
| Name | webhooks |
| Type | Resource |
| Id | cloudflare.alerting.webhooks |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get a webhook response
| Name | Datatype | Description |
|---|---|---|
id | string | The unique identifier of a webhook (example: b115d5ec15c641ee8b7692c449b5227b) |
name | string | The name of the webhook destination. This will be included in the request body when you receive a webhook notification. (example: Slack Webhook) |
created_at | string (date-time) | Timestamp of when the webhook destination was created. (example: 2020-10-26T18:25:04.532316Z) |
last_failure | string (date-time) | Timestamp of the last time an attempt to dispatch a notification to this webhook failed. (example: 2020-10-26T18:25:04.532316Z) |
last_success | string (date-time) | Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. (example: 2020-10-26T18:25:04.532316Z) |
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 | string | Type of webhook endpoint. (datadog, discord, feishu, gchat, generic, opsgenie, slack, splunk) (example: slack) |
url | string | The POST endpoint to call when dispatching a notification. (example: https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd) |
List webhooks response
| Name | Datatype | Description |
|---|---|---|
id | string | The unique identifier of a webhook (example: b115d5ec15c641ee8b7692c449b5227b) |
name | string | The name of the webhook destination. This will be included in the request body when you receive a webhook notification. (example: Slack Webhook) |
created_at | string (date-time) | Timestamp of when the webhook destination was created. (example: 2020-10-26T18:25:04.532316Z) |
last_failure | string (date-time) | Timestamp of the last time an attempt to dispatch a notification to this webhook failed. (example: 2020-10-26T18:25:04.532316Z) |
last_success | string (date-time) | Timestamp of the last time Cloudflare was able to successfully dispatch a notification using this webhook. (example: 2020-10-26T18:25:04.532316Z) |
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 | string | Type of webhook endpoint. (datadog, discord, feishu, gchat, generic, opsgenie, slack, splunk) (example: slack) |
url | string | The POST endpoint to call when dispatching a notification. (example: https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | account_id, webhook_id | Get details for a single webhooks destination. | |
list | select | account_id | Gets a list of all configured webhook destinations. | |
create | insert | account_id, name, url | Creates a new webhook destination. | |
update | replace | webhook_id, account_id, name, url | Update a webhook destination. | |
delete | delete | webhook_id, account_id | Delete a configured webhook destination. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
webhook_id | string |
SELECT examples
- get
- list
Get details for a single webhooks destination.
SELECT
id,
name,
created_at,
last_failure,
last_success,
secret,
type,
url
FROM cloudflare.alerting.webhooks
WHERE account_id = '{{ account_id }}' -- required
AND webhook_id = '{{ webhook_id }}' -- required
;
Gets a list of all configured webhook destinations.
SELECT
id,
name,
created_at,
last_failure,
last_success,
secret,
type,
url
FROM cloudflare.alerting.webhooks
WHERE account_id = '{{ account_id }}' -- required
;
INSERT examples
- create
- Manifest
Creates a new webhook destination.
INSERT INTO cloudflare.alerting.webhooks (
name,
secret,
url,
account_id
)
SELECT
'{{ name }}' /* required */,
'{{ secret }}',
'{{ url }}' /* required */,
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;
# Description fields are for documentation purposes
- name: webhooks
props:
- name: account_id
value: "{{ account_id }}"
description: Required parameter for the webhooks resource.
- name: name
value: "{{ name }}"
description: |
The name of the webhook destination. This will be included in the request body when you receive a webhook notification.
- name: secret
value: "{{ secret }}"
description: |
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.
- name: url
value: "{{ url }}"
description: |
The POST endpoint to call when dispatching a notification.
REPLACE examples
- update
Update a webhook destination.
REPLACE cloudflare.alerting.webhooks
SET
name = '{{ name }}',
secret = '{{ secret }}',
url = '{{ url }}'
WHERE
webhook_id = '{{ webhook_id }}' --required
AND account_id = '{{ account_id }}' --required
AND name = '{{ name }}' --required
AND url = '{{ url }}' --required
RETURNING
errors,
messages,
result,
success;
DELETE examples
- delete
Delete a configured webhook destination.
DELETE FROM cloudflare.alerting.webhooks
WHERE webhook_id = '{{ webhook_id }}' --required
AND account_id = '{{ account_id }}' --required
;