CentralCSP
APIAlerts

Create an alert channel

Adds a destination for this website's alerts. Chat and webhook channels need an https URL on a public host, and a chat channel's URL must belong to that service. URLs that point to private or internal addresses are rejected. Each webhook request carries an x-centralcsp-timestamp header and an x-centralcsp-signature header of the form sha256=<hex>: the HMAC-SHA256 of <timestamp>.<raw body>, keyed with your secret. The body is an AlertWebhookPayload, described in this endpoint's alertNotification callback. A Telegram channel takes a bot token and a chat id. An email channel takes the membership ids of workspace members who have access to this website. Counts against the plan's channel limit.

Requires the manager role on the website and the alerting plan feature.

POST
/v1/workspaces/{workspaceId}/websites/{websiteId}/alerts/channels

Authorization

headerAuthorizationBearer <JWT>

An OpenID Connect access token from signing in to CentralCSP, acting as the signed-in user.

Path Parameters

workspaceId*string

The workspace's id.

websiteId*string

The website's id.

Request Body

application/json
  1. body

The fields depend on type. Chat channels take an incoming-webhook url and the URL must belong to the chosen service, a webhook channel also takes a signing secret, a telegram channel takes botToken and chatId, and an email channel takes memberIds instead of a URL. Microsoft Teams expects a Power Automate workflow URL.

name*string

Display name for the channel.

Length1 <= length <= 255
type*string

A chat service, notified through an incoming webhook.

Value in"slack""google-chat""teams"
url*string

An https URL on a public host. Never returned.

Length1 <= length <= 2048
enabled?boolean

Defaults to true.

Response Body

A destination for alerts.

application/json
  1. response
id*string

The channel's id.

workspaceId*string

The workspace's id.

websiteId*string

The website's id.

name*string

Display name.

type*string

The channel type: slack, google-chat, teams, telegram, webhook or email.

configPreview*string

A masked view of the destination: the URL's origin and last few characters, the Telegram chat id, or the recipients' addresses. Full URLs and secrets are never returned.

hasSecret*boolean

Whether a secret is set: a signing secret for a webhook, a bot token for Telegram.

emailRecipients*array<>|

The members an email channel notifies. null for other types.

enabled*boolean

A disabled channel receives nothing.

disabledReason*|

Why the channel was switched off. delivery_failures means it was switched off automatically after repeated failures.

consecutiveFailures*|

Failed deliveries in a row. The channel is switched off at five, and the count resets on a success or when you enable it again.

createdAt*string

When the channel was created.

Formatdate-time
updatedAt*string

When the channel was last changed.

Formatdate-time

Callbacks

Example Request
curl -X POST 'https://api.centralcsp.com/v1/workspaces/01936b7a-6f2e-7c31-9a4d-2f8e1c5b7d90/websites/01936b7a-6f2e-7c31-9a4d-2f8e1c5b7d90/alerts/channels' \  -H 'Content-Type: application/json' \  -d '{  "name": "Security channel",  "type": "slack",  "url": "https://hooks.slack.com/services/T000/B000/XXXX"}'
Example Response
{  "id": "string",  "workspaceId": "string",  "websiteId": "string",  "name": "Security channel",  "type": "slack",  "configPreview": "https://hooks.slack.com/…AbCd",  "hasSecret": true,  "emailRecipients": [    {      "memberId": "string",      "userId": "string",      "hasAccess": true,      "email": "string",      "firstName": "string",      "lastName": "string",      "picture": "string"    }  ],  "enabled": true,  "disabledReason": "delivery_failures",  "consecutiveFailures": 0,  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}