# Webhook (https://raaqeb.dev/en/docs/notifications/webhook)

> The JSON a webhook channel posts, how Raaqeb signs it with Standard Webhooks, and how to verify the signature on your receiver.

A webhook channel posts each notification as JSON to a URL you choose, signed with the [Standard Webhooks](https://www.standardwebhooks.com/) scheme. Use it to feed your own service, an automation tool or anything that takes an HTTP POST. The body is machine values only and is never translated, so the channel has no channel language.

## What you need first

An `http` or `https` URL that accepts a POST and answers `2xx`. It can be on the public internet or on your own network. Raaqeb generates the signing secret when you save the channel; copy it from the channel's page to your receiver.

## Fields

| Field | Meaning | Required | Default |
| --- | --- | --- | --- |
| **Name** | What the admin area calls the channel, at most 80 characters. | Yes | None |
| **Apply to new monitors by default** | Every new monitor starts with this channel selected. | No | On |
| **URL** | Where Raaqeb posts. `http` or `https`, at most 2048 characters. A secret: stored encrypted and never shown after saving, since a URL often carries a token. | Yes | None |
| **Signing secret** | Generated by Raaqeb, `whsec_` followed by the base64 of 32 random bytes. Shown on the channel's page once saved. | Generated | None |
| **A new signing secret on save** | Replaces the signing secret when you save. After saving, the receiver stops verifying with the old secret. | No | Off |

## The request

Each attempt is one POST:

```http
POST /hooks/raaqeb HTTP/1.1
content-type: application/json
user-agent: Raaqeb
webhook-id: 0199a3c4-1b2e-7f40-8a6d-3c5e9b2d7a11
webhook-timestamp: 1790362142
webhook-signature: v1,ZQq6cK+z7eUi6D9zZWTUyqr1MZ/7a41TG2GEWUF7CAs=

{"data":{"incidentUrl":"https://status.example.com/admin/incidents/new?monitor=0199a3c2-5f1e-7c3a-9b1d-2f6e8a4c1b7d","monitor":{"adminUrl":"https://status.example.com/admin/monitors/0199a3c2-5f1e-7c3a-9b1d-2f6e8a4c1b7d","checkType":"http","id":"0199a3c2-5f1e-7c3a-9b1d-2f6e8a4c1b7d","name":"Main website","target":"https://example.com"},"reason":"timeout"},"timestamp":"2026-09-25T18:49:00.000Z","type":"monitor.down"}
```

| Header | Value |
| --- | --- |
| `webhook-id` | The notification's id, a UUID. The same on every retry of one notification, so a receiver can drop a duplicate. |
| `webhook-timestamp` | When this attempt was made, in Unix seconds. Each retry has its own. |
| `webhook-signature` | `v1,` then the base64 HMAC-SHA256 signature. |

Any `2xx` answer is a success, and Raaqeb does not read its body. Redirects are not followed: a `3xx` answer is a failed attempt, so a signed body never lands at another address.

## The payload

The body follows the Standard Webhooks envelope: `type`, `timestamp` (when the event happened, ISO 8601 in UTC) and `data`. Every monitor event's `data` has a `monitor` object:

| Field | Meaning |
| --- | --- |
| `id` | The monitor's id. |
| `name` | The monitor's name. |
| `checkType` | `http`, `tcp`, `dns`, `postgres`, `mysql`, `redis`, `docker` or `heartbeat`. |
| `target` | The URL, `host:port` or name the check reaches; `null` for a heartbeat monitor. |
| `adminUrl` | The monitor's page in the admin area. Absent when the install stores no public address. |

The types and what they add to `data`:

| `type` | Added to `data` |
| --- | --- |
| `monitor.down` | `reason`; `incidentUrl`, the admin page that opens an incident for this monitor, absent without a public address. |
| `monitor.reminder` | `reason`, the one the outage opened with; `downForMs`, how long the monitor has been down. |
| `monitor.recovered` | `downtimeMs`, how long the outage lasted. |
| `monitor.degraded_started` | `reason`. |
| `monitor.degraded_ended` | Nothing. |
| `monitor.certificate_expiring` | `certificate`: `daysLeft`, whole days left rounded down, and `notAfter`, the expiry instant. |
| `channel.test` | `channel`: the channel's `id` and `name`. No `monitor`. |

`reason` is a reason code such as `timeout`, `dns_failed`, `connection_refused`, `unexpected_status`, `assertion_failed`, `slow` or `heartbeat_late`. A recovered notification:

```json
{
  "data": {
    "downtimeMs": 754000,
    "monitor": {
      "adminUrl": "https://status.example.com/admin/monitors/0199a3c2-5f1e-7c3a-9b1d-2f6e8a4c1b7d",
      "checkType": "http",
      "id": "0199a3c2-5f1e-7c3a-9b1d-2f6e8a4c1b7d",
      "name": "Main website",
      "target": "https://example.com"
    }
  },
  "timestamp": "2026-09-25T19:01:34.000Z",
  "type": "monitor.recovered"
}
```

The payload is a public contract: types and fields are added, never changed. The full schema, with every reason code, is in the [API reference](https://raaqeb.dev/en/docs/api).

## The signature

Raaqeb signs each attempt as Standard Webhooks describes:

1. Take the signing secret, drop the `whsec_` prefix, and base64-decode the rest. Those 32 bytes are the HMAC key.
2. Build the signed content: the `webhook-id`, a full stop, the `webhook-timestamp`, a full stop, then the body exactly as received: `id.timestamp.body`.
3. Compute HMAC-SHA256 of the signed content with the key, and base64-encode it.
4. Send it as `webhook-signature: v1,<signature>`.

To verify, compute the same signature from the raw body bytes, before any JSON parsing, and compare it in constant time. Reject a request whose `webhook-timestamp` is too far from your clock; Standard Webhooks suggests five minutes. A Standard Webhooks library takes the secret as Raaqeb shows it, `whsec_` prefix included. Without one:

```ts title="verify.ts"
const toBytes = (base64: string) =>
  Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));

/** Whether a request carries a valid Raaqeb signature. `body` is the raw request body. */
export async function verify(
  secret: string,
  headers: Headers,
  body: string,
  toleranceSeconds = 300
): Promise<boolean> {
  const id = headers.get("webhook-id");
  const timestamp = headers.get("webhook-timestamp");
  const signatures = headers.get("webhook-signature");
  if (!(id && timestamp && signatures)) {
    return false;
  }
  if (!(Math.abs(Date.now() / 1000 - Number(timestamp)) <= toleranceSeconds)) {
    return false;
  }
  const key = await crypto.subtle.importKey(
    "raw",
    toBytes(secret.slice("whsec_".length)),
    { hash: "SHA-256", name: "HMAC" },
    false,
    ["verify"]
  );
  const signed = new TextEncoder().encode(`${id}.${timestamp}.${body}`);
  // The header may list several signatures separated by spaces; Raaqeb sends one.
  for (const entry of signatures.split(" ")) {
    const [version, signature] = entry.split(",");
    if (
      version === "v1" &&
      signature &&
      (await crypto.subtle.verify("HMAC", key, toBytes(signature), signed))
    ) {
      return true;
    }
  }
  return false;
}
```

It runs on Bun, Deno, Node.js 20 and later, and Cloudflare Workers. `crypto.subtle.verify` compares in constant time. To test your receiver, the request at the top of this page is signed with the secret `whsec_AQgPFh0kKzI5QEdOVVxjanF4f4aNlJuiqbC3vsXM09o=`; it verifies once you set aside the timestamp check.

To rotate the secret, turn on **A new signing secret on save**, save, and give the new secret to your receiver. The old secret stops working at once, so update the receiver straight after saving.

<Callout>Subscriber webhooks, the ones visitors register on a status page, are a different thing: they carry `webhook-id` and `webhook-timestamp` but no signature, and use Statuspage's body. See [Subscriptions](https://raaqeb.dev/en/docs/status-pages/subscriptions).</Callout>

## Failures and limits

One attempt gives up after 10 seconds. A failed attempt is retried 30 seconds, 2 minutes and 10 minutes later, with the same `webhook-id`. See [the queue and retries](https://raaqeb.dev/en/docs/notifications#the-queue-and-retries).

| Reason code | Text | Typical cause |
| --- | --- | --- |
| `unexpected_status` | Unexpected status code | The receiver answered outside `2xx`, or redirected. **Observed** shows the status, **Error text** the start of the answer's body. |
| `timeout` | Timed out | No answer within 10 seconds. |
| `dns_failed` | DNS lookup failed | The URL's host does not resolve. |
| `connection_refused` | Connection refused | Nothing listens at the URL's host and port. |
| `connection_failed` | Connection failed | The connection was reset or the host was unreachable. |
| `certificate_expired` | Certificate expired | The receiver's certificate has expired. |
| `certificate_invalid` | Certificate invalid | The certificate is self-signed, for another name, or cannot be verified. |
| `unknown` | Unknown error | Anything else. **Error text** says what happened. |

The URL is removed from every recorded error text. There are no custom request headers; the signature is how a receiver knows a POST came from your install.
