CentralCSP
APIAlerts

Create an alert rule

Starts notifying on an event type through the channels you list, which must belong to this website. Detection runs about once a minute and only looks forward, so a new rule never replays history. Counts against the plan's rule limit.

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

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

Authorization

AuthorizationBearer <token>

An OpenID Connect access token issued by Keycloak, acting as the signed-in user.

In: header

Path Parameters

workspaceId*string
websiteId*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

name*string

Display name for the rule.

Length1 <= length <= 255
eventType*|||||||||||||

What to notify about. new-* types fire the first time something appears in a website's reports: a CSP directive and blocked origin pair, a script origin, a failing network origin, a COOP or COEP violation type, a Permissions Policy violation, a deprecated API, a browser intervention, or a blocked connection origin. compliance:unjustified-script fires when a payment-page script needs review. *:spike types fire when an hour's report volume reaches at least 50 reports and three times the trailing 24-hour average, both adjustable per rule with config.

cooldownSeconds?|

How long to collect findings before sending, up to 24 hours. Everything found in that time arrives as one notification. Defaults to 900 seconds.

Range0 <= value <= 86400
config?

Thresholds for a *:spike rule. Only spike rules accept it; fields left out keep the defaults.

channelIds*array<string>

Channels to notify. They must belong to this website. An empty list means the rule detects but notifies nobody.

Itemsitems <= 20
enabled?boolean

Defaults to true.

Response Body

application/json

curl -X POST "https://api-next.centralcsp.com/v1/workspaces/string/websites/string/alerts/rules" \  -H "Content-Type: application/json" \  -d '{    "name": "New third-party script",    "eventType": "csp-violation:new-type",    "channelIds": [      "string"    ]  }'
{  "id": "string",  "workspaceId": "string",  "websiteId": "string",  "name": "New third-party script",  "eventType": "csp-violation:new-type",  "cooldownSeconds": 0,  "config": {    "multiplier": 3,    "floor": 50  },  "enabled": true,  "channelIds": [    "string"  ],  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}