Skip to main content

webhooks

Creates, updates, deletes, gets or lists a webhooks resource.

Overview

Namewebhooks
TypeResource
Idcloudflare.alerting.webhooks

Fields

The following fields are returned by SELECT queries:

Get a webhook response

NameDatatypeDescription
idstringThe unique identifier of a webhook (example: b115d5ec15c641ee8b7692c449b5227b)
namestringThe name of the webhook destination. This will be included in the request body when you receive a webhook notification. (example: Slack Webhook)
created_atstring (date-time)Timestamp of when the webhook destination was created. (example: 2020-10-26T18:25:04.532316Z)
last_failurestring (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_successstring (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)
secretstringOptional 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.
typestringType of webhook endpoint. (datadog, discord, feishu, gchat, generic, opsgenie, slack, splunk) (example: slack)
urlstringThe 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:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, webhook_idGet details for a single webhooks destination.
listselectaccount_idGets a list of all configured webhook destinations.
createinsertaccount_id, name, urlCreates a new webhook destination.
updatereplacewebhook_id, account_id, name, urlUpdate a webhook destination.
deletedeletewebhook_id, account_idDelete 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.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
webhook_idstring

SELECT examples

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
;

INSERT examples

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
;

REPLACE examples

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 a configured webhook destination.

DELETE FROM cloudflare.alerting.webhooks
WHERE webhook_id = '{{ webhook_id }}' --required
AND account_id = '{{ account_id }}' --required
;