> For the complete documentation index, see [llms.txt](https://docs.controltheory.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/incidents/alerts-and-notifications/webhooks.md). Agents can also search and read this documentation through its [MCP server](https://docs.controltheory.com/~gitbook/mcp).

# Webhooks

A webhook channel sends each alert event to a URL you choose, as a signed JSON `POST`. Use it to start something in your own environment when an incident is created, changes or resolves: a triage agent, a script, another alerting tool.

Each request carries the same envelope:

* the event,
* the alert rule and detection behind it,
* the incident as it is when the request is sent,
* links back to Dstl8.

A failed request is retried with the same delivery id, so your endpoint can drop a repeat.

### Set up a webhook

You need the **Admin** org role. To set one up from a script or an agent instead, see [Set up a webhook with the API](#set-up-a-webhook-with-the-api).

#### 1. Add the channel

1. In a workspace, go to **Channels** and click **Add Channel**. Channels belong to the organization, so every workspace lists the same ones.
2. Give the channel a **Name**, choose **Webhook** under **Channel Type**, and fill in:

| Field              | Notes                                                                                                                                                                                                                                                                                |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **URL**            | Where each event is `POST`ed. It must use `https` and resolve to a public address. See [URL requirements](#url-requirements).                                                                                                                                                        |
| **Signing secret** | Optional. Each request is signed with it, so your endpoint can check that the request came from Dstl8. See [Verify the signature](#verify-the-signature). Generate a long random value and keep a copy: it's never shown again.                                                      |
| **Headers**        | Optional. Click **Add header** for each header to send with every request, for example `Authorization`. You can add up to 10. Their values are stored as secrets and never shown again. A header Dstl8 sets itself, such as `Content-Type` or any `X-Dstl8-` header, can't be added. |
| **Event types**    | Leave it empty to receive every event type, including types added later, or choose the events to receive. See [Event types](#event-types).                                                                                                                                           |

3. Click **Create Channel**. The channel shows in the list, with its URL under **To**.

The dialog's **Payload & signature** section shows the headers and the body your endpoint receives.

#### 2. Send a test message

In the channel's actions menu, on the **Channels** list or on the channel's page, click **Send test message**. Dstl8 sends an envelope whose `event` is `test`, whatever **Event types** says.

Dstl8 then shows whether your endpoint accepted it, and the HTTP status it answered with, for example `200`. If your endpoint didn't accept it, you see the status and the start of its answer, or why Dstl8 couldn't reach it.

You can test the same URL once every 30 seconds. Test messages aren't listed in the [delivery history](#delivery-history).

#### 3. Add it to an alert rule

In **Alerting** → **Rules**, edit a rule and add the channel under **Channels**. From then on, every notification the rule sends also goes to the webhook. See [Alerts and Notifications](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/incidents/alerts-and-notifications.md).

#### Edit the channel

In the channel's actions menu, on the **Channels** list or on the channel's page, click **Edit**:

* **Name**, **URL** and **Event types** show what's saved.
* **Signing secret** is never shown. Leave it blank to keep it, or enter a new one to rotate it; when you rotate it, [accept both secrets for a few minutes](#verify-the-signature). **Remove signing secret** stops signing.
* **Headers** shows each header's name, not its value. Leave a value blank to keep it, type a new value to replace it, or remove the header to stop sending it. To rename a header, remove it and add it again under the new name.

Click **Save Changes**. A channel's **Channel Type** can't be changed.

### Set up a webhook with the API

You need an API token with the **Admin** role (**Org Settings → API Tokens**). Requests go to your organization's API at `https://<org_id>.app.dstl8.ai`, where `<org_id>` is the name at the start of your Dstl8 address (`acme` in `https://acme.app.dstl8.ai`). It isn't the envelope's `org_id` field, which starts with `org-`.

#### 1. Create the channel

```bash
curl -X POST "https://<org_id>.app.dstl8.ai/api/channels" \
  -H "Authorization: Bearer $DSTL8_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "triage-bot",
    "kind": "webhook",
    "config": {
      "url": "https://hooks.example.com/dstl8",
      "event_types": ["incident.created", "incident.resolved"]
    },
    "secret": {
      "signing_secret": "a-long-random-string",
      "header:Authorization": "Bearer your-endpoint-token"
    }
  }'
```

Everything under `secret` is optional:

* `signing_secret` signs each request. Generate a long random value and keep a copy: your endpoint needs it to check signatures, and Dstl8 never shows it again.
* `header:<Name>` adds a header to every request, for example `header:Authorization` or `header:X-Api-Key`. You can set up to 10. Header values are stored as secrets and never returned.

`config.event_types` limits which events are sent. Leave it out, or send `[]`, to receive every event type, including types added later.

The response shows the channel's id, its `config` (with `header_names`, the names of your headers) and `has_secret`, which is `true` when a signing secret is set.

#### 2. Send a test

```bash
curl -X POST "https://<org_id>.app.dstl8.ai/api/channels/<channel_id>/test" \
  -H "Authorization: Bearer $DSTL8_API_TOKEN"
```

Dstl8 sends an envelope whose `event` is `test`. The response shows whether your endpoint accepted it, and the HTTP status it answered with:

```json
{ "success": true, "error": "", "status_code": 200 }
```

You can test the same URL once every 30 seconds.

#### 3. Attach it to an alert rule

In **Alerting** → **Rules**, edit a rule and add the channel under **Channels**. From then on, every notification the rule sends also goes to the webhook. See [Alerts and Notifications](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/incidents/alerts-and-notifications.md).

#### Change the channel later

Send `PATCH /api/channels/<channel_id>` with `name` and `kind` (both are required), plus what you're changing:

* **`config`:** replaces the channel's settings, so send `url` and `event_types` together. A `config` without `event_types` is refused, so that changing the URL can't clear your filter by accident. For example, `{"config": {"url": "https://hooks.example.com/dstl8", "event_types": []}}` turns the filter off.
* **`secret`:** merges by key:

  * a key with a value sets it (this is how you rotate the signing secret);
  * a key with `""` removes it (`"header:X-Env": ""` stops sending that header);
  * keys you don't send are kept.

  Leave `secret` out to keep all of it.

### What your endpoint receives

```http
POST /dstl8 HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
User-Agent: Dstl8-Webhooks/1.0
X-Dstl8-Event: incident.status_changed
X-Dstl8-Delivery-Id: dl-01JZTESTDELIVERY
X-Dstl8-Signature: t=1752300000,v1=ed813be57a3fe1f13394b99da24d5deacd49517d68f529fcbc56ff42718fa737
Authorization: Bearer your-endpoint-token
```

| Header                | What it carries                                                                                                                                                                                                                                                                                                                                                                                                         |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `X-Dstl8-Event`       | The event, the same as the envelope's `event`.                                                                                                                                                                                                                                                                                                                                                                          |
| `X-Dstl8-Delivery-Id` | The delivery's id, the same as the envelope's `id`. It stays the same on every retry.                                                                                                                                                                                                                                                                                                                                   |
| `X-Dstl8-Signature`   | The signature, when the channel has a signing secret. See [Verify the signature](#verify-the-signature).                                                                                                                                                                                                                                                                                                                |
| Your headers          | Each `header:<Name>` from the channel's secret. A header can't be one Dstl8 sets or one that controls how the request is sent: any `X-Dstl8-` header, `Content-Type`, `User-Agent`, `Host`, `Content-Length`, `Content-Encoding`, `Transfer-Encoding`, `Connection`, `Keep-Alive`, `TE`, `Trailer`, `Upgrade`, `Expect`, or a `Proxy-` header. Saving a channel with one is refused with a `400` that names the header. |

The body is the envelope. All times are epoch milliseconds.

```json
{
  "version": "2026-09-01",
  "id": "dl-01JZTESTDELIVERY",
  "event": "incident.status_changed",
  "timestamp_ms": 1752300000000,
  "org_id": "org-01JZTESTORG",
  "rule": {
    "id": "rl-01JZTESTRULE",
    "name": "Checkout errors",
    "kind": "incident"
  },
  "detection": {
    "id": "dt-01JZTESTDETECTION",
    "timestamp_ms": 1752299990000,
    "results": {
      "incident_id": "in-01JZTESTINCIDENT",
      "trigger_on": "status_change"
    }
  },
  "incident": {
    "id": "in-01JZTESTINCIDENT",
    "title": "Checkout API 5xx above 2% for 10 minutes",
    "status": "Active",
    "impact": "major",
    "predictive": false,
    "environment": "production",
    "workspace_id": "ws-01JZTESTWS",
    "summary": "Errors from payments-svc since the 14:00 deploy; p99 latency doubled.",
    "start_time_ms": 1752296400000,
    "end_time_ms": 0,
    "updated_at_ms": 1752299995000
  },
  "watch": null,
  "links": {
    "incident": "https://acme.app.dstl8.ai/workspaces/ws-01JZTESTWS/incidents/in-01JZTESTINCIDENT",
    "detections": "https://acme.app.dstl8.ai/workspaces/ws-01JZTESTWS/alerting/detections"
  }
}
```

| Field                 | Notes                                                                                                                                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `version`             | The envelope's format. A change that could break a receiver gets a new version.                                                                                                                              |
| `id`                  | The delivery's id, the same on every retry. Use it to drop a request you've already handled.                                                                                                                 |
| `timestamp_ms`        | When this attempt was made.                                                                                                                                                                                  |
| `org_id`              | Your organization's id (it starts with `org-`). It tells you which organization sent a request when one endpoint receives from several. It isn't the name in your Dstl8 address.                             |
| `rule`, `detection`   | The alert rule that fired and the detection it made. `null` for `incident.resolved`, `incident.reopened`, `watch.fired` and `test`.                                                                          |
| `detection.results`   | What the rule matched, as recorded on the detection. `null` when it's larger than 16 KB.                                                                                                                     |
| `incident`            | The incident as it is when the request is sent, not when the rule fired: a retry carries the latest status. `null` for spike rules, `watch.fired` and `test`. `end_time_ms` is 0 while the incident is open. |
| `incident.predictive` | `true` for a forecast, an incident opened before the failure it predicts. See [Forecasts](#forecasts).                                                                                                       |
| `links`               | Pages in Dstl8 about the event. A link that doesn't apply is left out.                                                                                                                                       |
| `truncated`           | Present, and `true`, when a field was cut to fit: `title` past 1 KB, `summary` past 4 KB, `results` past 16 KB, or a body past 64 KB. A cut text ends with `…`.                                              |

### Event types

| Event                     | When it's sent                                                                                                                                                        |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `incident.created`        | A rule whose trigger mode is **Creation** matched a new incident.                                                                                                     |
| `incident.status_changed` | A rule whose trigger mode is **Status Change** matched an incident that changed.                                                                                      |
| `incident.updated`        | A rule whose trigger mode is **Any** matched an incident that was created or changed. Such a rule sends a new incident as `incident.updated`, not `incident.created`. |
| `incident.resolved`       | An incident this webhook was sent was resolved or closed.                                                                                                             |
| `incident.reopened`       | An incident this webhook was sent `incident.resolved` for was opened again.                                                                                           |
| `spike.detected`          | A spike rule fired. `incident` is `null`.                                                                                                                             |
| `watch.fired`             | Not sent yet. When metric watches start sending notifications: a watch's condition held. See below.                                                                   |
| `test`                    | You tested the channel. It's always sent, whatever `event_types` says.                                                                                                |

`incident.resolved` and `incident.reopened` don't depend on a rule's filters or trigger mode. Once a rule has sent your webhook an incident, you hear when that incident resolves, and when it reopens after that. If your `event_types` filters out the rule's own event but lists `incident.resolved`, you still get `incident.resolved` for the incidents that rule matched.

#### Watch events

{% hint style="warning" %}
**Not sent yet.** Metric watches don't send notifications yet, so no webhook receives `watch.fired` today. This section describes the event so you can prepare for it.
{% endhint %}

When metric watches start sending notifications, every webhook whose `event_types` doesn't leave `watch.fired` out receives it, including webhooks that receive every event type. To receive only incidents, list the incident events in `event_types` now.

In a `watch.fired` envelope:

* `rule`, `detection` and `incident` are `null`.
* `watch` describes the watch and why it fired.
* `links` points at the workspace's metrics and events pages.

```json
"watch": {
  "id": "mw-01JZTESTWATCH",
  "name": "checkout p99 over 800ms",
  "workspace_id": "ws-01JZTESTWS",
  "condition": { "kind": "threshold", "field": "p99", "op": ">", "value": 800, "episode_kind": "" },
  "event_id": "ev-01JZTESTEVENT",
  "window_end_ms": 1752299940000,
  "matches": [
    { "group_key": "g1", "headline": "p99 912ms", "metric_name": "http.server.duration",
      "canonical_name": "http_server_duration", "value": 912, "episode_id": "", "episode_kind": "",
      "dims": { "service": "checkout" }, "stream_name": "prod-otel" }
  ]
},
"links": {
  "watch": "https://acme.app.dstl8.ai/workspaces/ws-01JZTESTWS/explore/metrics",
  "events": "https://acme.app.dstl8.ai/workspaces/ws-01JZTESTWS/events"
}
```

`matches` holds the strongest 20 matches at most.

#### Forecasts

A forecast is sent with `"predictive": true`. When the predicted failure starts, the incident becomes Active and `predictive` turns `false`. That change only reaches webhooks on a rule whose trigger mode fires on changes (**Status Change** or **Any**). A webhook on a **Creation**-only rule never learns that the forecast came true.

### Verify the signature

With a signing secret set, each request has an `X-Dstl8-Signature` header:

```
X-Dstl8-Signature: t=1752300000,v1=ed813be57a3fe1f13394b99da24d5deacd49517d68f529fcbc56ff42718fa737
```

* `t` is when the request was signed, in Unix seconds.
* `v1` is the hex HMAC-SHA256 of `<t>.<body>`, keyed with your signing secret, where `<body>` is the raw request body, byte for byte.

To check a request:

1. Read the raw body before parsing it. Re-encoding the JSON changes the bytes, and the signature no longer matches.
2. Split the header on `,` and take `t` and each `v1`.
3. Refuse the request if `t` is more than 5 minutes from your clock. This stops someone replaying an old request.
4. Compute the HMAC-SHA256 of `t`, a `.`, then the raw body, keyed with your signing secret, and hex-encode it.
5. Accept the request if it equals one of the `v1` values. Compare in constant time.

**Go**

```go
package webhook

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"errors"
	"strconv"
	"strings"
	"time"
)

const tolerance = 5 * time.Minute

// Verify checks an X-Dstl8-Signature header against the raw request body.
func Verify(secret, header string, body []byte, now time.Time) error {
	var ts string
	var sigs []string
	for _, part := range strings.Split(header, ",") {
		key, value, _ := strings.Cut(strings.TrimSpace(part), "=")
		switch key {
		case "t":
			ts = value
		case "v1":
			sigs = append(sigs, value)
		}
	}
	sec, err := strconv.ParseInt(ts, 10, 64)
	if err != nil || len(sigs) == 0 {
		return errors.New("malformed signature header")
	}
	if d := now.Sub(time.Unix(sec, 0)); d > tolerance || d < -tolerance {
		return errors.New("signature is too old or too new")
	}
	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write([]byte(ts + "."))
	mac.Write(body)
	want := hex.EncodeToString(mac.Sum(nil))
	for _, sig := range sigs {
		if hmac.Equal([]byte(sig), []byte(want)) {
			return nil
		}
	}
	return errors.New("signature does not match")
}
```

**Python**

```python
import hashlib
import hmac
import re
import time

TOLERANCE_SECONDS = 300


def verify(secret, header, body, now=None):
    """Check an X-Dstl8-Signature header (str) against the raw request body (bytes)."""
    timestamp, signatures = None, []
    for part in header.split(","):
        key, _, value = part.strip().partition("=")
        if key == "t":
            timestamp = value
        elif key == "v1":
            signatures.append(value)
    if not timestamp or not re.fullmatch(r"[0-9]+", timestamp) or not signatures:
        return False
    if abs((time.time() if now is None else now) - int(timestamp)) > TOLERANCE_SECONDS:
        return False
    expected = hmac.new(secret.encode(), timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(expected.encode(), sig.encode()) for sig in signatures)
```

**Node.js**

```javascript
const crypto = require("node:crypto");

const TOLERANCE_SECONDS = 300;

// Check an X-Dstl8-Signature header against the raw request body (a Buffer).
function verify(secret, header, rawBody, nowSeconds = Date.now() / 1000) {
  let timestamp;
  const signatures = [];
  for (const part of header.split(",")) {
    const [key, value] = part.trim().split("=");
    if (key === "t") timestamp = value;
    else if (key === "v1") signatures.push(value);
  }
  if (!timestamp || !/^\d+$/.test(timestamp) || signatures.length === 0) return false;
  if (Math.abs(nowSeconds - Number(timestamp)) > TOLERANCE_SECONDS) return false;
  const expected = crypto
    .createHmac("sha256", secret)
    .update(`${timestamp}.`)
    .update(rawBody)
    .digest("hex");
  const want = Buffer.from(expected);
  return signatures.some((sig) => {
    const got = Buffer.from(sig);
    return got.length === want.length && crypto.timingSafeEqual(got, want);
  });
}

module.exports = { verify };
```

Every attempt is signed with the channel's current signing secret, including retries of requests made before a rotation. When you rotate it, accept both the old and the new secret for a few minutes.

### Responses and retries

Answer with a `2xx` within 10 seconds. If the work takes longer, accept the request first and do the work after.

| Your endpoint's answer                                  | What Dstl8 does                                                                                  |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `2xx`                                                   | Delivered.                                                                                       |
| `408`, `429`, any `5xx`, or no answer within 10 seconds | Retries later.                                                                                   |
| A redirect (`3xx`)                                      | Retries later. Redirects are never followed: point the channel's URL at where the redirect goes. |
| Can't connect (DNS, TLS, connection refused)            | Retries later.                                                                                   |
| Any other `4xx`                                         | Stops: the delivery is not retried.                                                              |

A delivery gets 8 attempts. The waits between them are about 1, 2, 4, 8, 16, 32 and 60 minutes, each varied by up to 20% either way. The last attempt comes between about 1 hour 40 minutes and 2 hours 30 minutes after the first. If that one fails too, the delivery stops.

Each delivery's status, attempts and last error are in the [delivery history](#delivery-history). The last error is your endpoint's status and the first 1 KB of what it answered. In case your endpoint answers with the request it got, Dstl8 takes your header values and signing secret out of that text, and leaves out the answer altogether when a value is too short to take out.

Things to plan for:

* **Duplicates.** Delivery is at least once. A request can arrive twice, for example when your endpoint answers after the 10-second limit. Drop one whose `X-Dstl8-Delivery-Id` you've already handled.
* **Order.** Notifications about one incident reach your webhook in the order they were made. While one is being retried, later ones about the same incident wait behind it. Notifications about different incidents aren't ordered.
* **Current state.** The envelope carries the incident as it is when sent. After retries, a request for `incident.created` can show an incident that has since resolved. The `incident.resolved` request follows.

### Delivery history

Each event sent to a channel is a delivery. The channel's page lists them under **Deliveries**, newest first, with the rule that sent each one, how many attempts it took and the last error. An alert rule's page lists its latest 10 under **Recent Deliveries**, and an incident's page lists the ones about that incident under **Notifications**. See [Delivery history](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/incidents/alerts-and-notifications.md#delivery-history) for what each status means.

For a webhook:

* **Skipped** is an event the channel's **Event types** leave out. Nothing was sent.
* Events that don't come from an alert rule show no rule: `incident.resolved` and `incident.reopened`, for example, follow the incident.
* The error of a failed delivery has your header values and signing secret taken out, as described in [Responses and retries](#responses-and-retries).
* Test messages aren't listed.

The same list is at `GET /api/deliveries?channel_id=<channel_id>`. Its `status` names some states differently from the portal; note that `failed` is **Retrying**, not **Failed**:

| `status` in the API                        | In the portal                         |
| ------------------------------------------ | ------------------------------------- |
| `pending`                                  | **Pending**                           |
| `inflight`                                 | **Sending**                           |
| `sent`                                     | **Sent**                              |
| `sent`, with `"skipped": "event_filtered"` | **Skipped**                           |
| `failed`                                   | **Retrying**: it's tried again later. |
| `dead`                                     | **Failed**: it won't be tried again.  |

### URL requirements

* The URL must use `https`.
* It must resolve to public addresses. Private, loopback and link-local addresses are refused (for example `10.0.0.0/8`, `192.168.0.0/16`, `127.0.0.1`, `169.254.169.254`), both when you save the channel and on every request.
* It can't hold a username or password. Send credentials as a header instead, for example `header:Authorization`.
* Redirects are not followed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.controltheory.com/controltheory-documentation/dstl8-docs/incidents/alerts-and-notifications/webhooks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
