Skip to main content
Plans: Core and Plus, and the free trial, to add destinations. Listing and removing keep working after a move to Starter. Adding and removing are refused with 402 while the workspace is read-only. Who: anyone with a workspace token; owners and admins create workspace tokens.
These endpoints manage the same Slack, Microsoft Teams and webhook destinations as the Slack, Teams and webhooks card under Settings → Notifications, so you can set up alerting from Terraform, a script or an internal tool. A destination added through the API shows in Settings, and the list returns destinations added in Settings too.
The API lists, adds and removes destinations. Changing a destination’s name or events, turning it off, sending a test and making a new signing secret are under Settings → Notifications. See notifications.

Authentication

Every request needs a workspace token in the Authorization header:
Create one under Settings → API tokens with Create token, and under Access choose Manage Slack, Teams and webhook destinations. A CI upload token for a product family gets 401 here. See create a token.

Example: add a Slack channel

1

Get an incoming webhook URL in Slack

In Slack, set up an incoming webhook for the channel (a Slack app with Incoming Webhooks turned on) and copy its URL. It starts with https://hooks.slack.com/.
2

Add the destination

Pharus answers 201 Created with the new destination:
3

Test it

Adding a destination through the API doesn’t send anything. To check it, go to Settings → Notifications and select Send a test on the destination. A message “Test alert from Pharus” should appear in the channel.
To post to two channels, add two destinations. Keep the id if your tool will remove the destination later.

List destinations

200 OK

Every destination in the workspace, oldest first, however it was added.

Add a destination

Send a JSON object with Content-Type: application/json: The body may be at most 16 384 characters.

URL rules

Every URL starts with https://, has a full host name and has no user name or password in it. On top of that:

201 Created

The destination, in the same shape as in the list, turned on. For a webhook, the response also has secret:
secret is the webhook’s signing secret, starting with whsec_. Pharus signs every request to the endpoint with it; see verify the signature for how to check it, and outgoing webhooks for the request and body Pharus sends.
This response is the only time Pharus returns the signing secret. Store it with your endpoint straight away. If it is lost, select New signing secret on the destination under Settings → Notifications; the old secret stops working at once.
POST isn’t idempotent: sending the same body twice adds two destinations, and each gets every alert. If your tool retries, list the destinations first, or remove the extra one.

Remove a destination

Pharus answers 204 No Content and stops posting to the destination. Its failed deliveries stay listed under Delivery problems. Removing works after a move to Starter too, so a workspace can wind its destinations down. When the workspace has no destination with that id, Pharus answers 404 with not_found.

Audit trail

Destinations added and removed through the API are recorded in the audit trail, with the token’s name as the actor. Listing isn’t recorded.

Errors

Errors return { "error", "message" }. A 400 with invalid_request adds fields, with one English message for each field that is missing or invalid:
Pharus checks in this order: the token, the rate limit, whether the workspace is read-only, then for POST the plan, whether Pharus can store destination URLs, and the body.

API introduction

Outgoing webhooks

Notifications

Audit trail