# Get notified about events with webhooks

A webhook sends a signed JSON event to your HTTPS endpoint whenever a resource it covers is created, changed or removed. Use it to drive automations without polling.

## Create a webhook

1. Go to **Integrations** → **Webhooks** → [Create webhook](https://cloud.betterstack.com/team/t0/integrations/webhooks/new ";_blank")
2. Enter a **Name**.
3. Enter the **URL** of your HTTPS endpoint.
4. Under **Resource types**, check the resources the webhook covers, for example **Servers**.
5. Click **Create webhook**.

The webhook's page then shows its **Signing secret**. Copy it to [verify each delivery](#verify-the-signature).

![Create webhook form](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/cf12f99b-3af7-4552-c7c4-868bb563e700/md2x =2100x2120)

To check your endpoint, click **⋯** next to the webhook and then **Send test event**. You get one test event for each resource type, with `event` set to `test` and `data` set to `null`.

## What you receive

Each delivery is a `POST` request with a JSON body that describes one event on one resource:

```json
[label Example delivery, shortened]
{
  "object": "server",
  "event": "created",
  "occurred_at": "2026-05-27T10:00:21Z",
  "data": {
    "id": "8f14e45f-ceea-467a-9275-7c4f3d9b1a2e",
    "name": "web-01",
    "status": "starting"
  }
}
```

| Field | What it holds |
| --- | --- |
| `object` | The resource type, from the table below. |
| `event` | What happened: `created`, `updated`, `destroyed`, or one of the events below. |
| `occurred_at` | When the event happened, as an ISO 8601 timestamp in UTC. |
| `data` | The full resource at the moment of the event. |

Every resource type sends `created`, `updated` and `destroyed`:

| Resource type | `object` |
| --- | --- |
| Servers | `server` |
| Snapshots | `snapshot` |
| Scheduled snapshots | `scheduled_snapshot` |
| Placement groups | `placement_group` |
| Volumes | `volume` |
| Volume snapshots | `volume_snapshot` |
| Scheduled volume snapshots | `scheduled_volume_snapshot` |
| Object caches | `object_proxy` |
| Networks | `network` |
| Reserved IPs | `reserved_ip` |
| Firewalls | `firewall` |
| PostgreSQL | `postgres` |
| MySQL | `mysql` |
| Valkey | `valkey` |
| ClickHouse | `clickhouse` |
| Kafka | `kafka` |
| Load balancers | `load_balancer` |
| Certificates | `certificate` |
| SSH keys | `ssh_key` |

Some resource types send more events:

| Event | Resource types | When |
| --- | --- | --- |
| `spot_server_termination` | Servers | A spot server was picked for termination. It's removed two minutes later. |
| `failed_over` | PostgreSQL, MySQL, Valkey | A replica was promoted to primary. |
| `upgraded` | PostgreSQL, MySQL, Valkey, ClickHouse, Kafka | An engine upgrade finished or was stopped. |
| `restored` | PostgreSQL, MySQL, Valkey, ClickHouse | A restore finished. |
| `rescaled` | PostgreSQL, MySQL, Valkey, ClickHouse, Kafka, Object caches | A plan change finished. |
| `disk_usage_high` | PostgreSQL, MySQL, ClickHouse, Kafka | Data on disk crossed a warning threshold of the plan's storage. |
| `disk_read_only_enabled`, `disk_read_only_cleared` | PostgreSQL | The database switched to read-only because its disk is 95% full, or switched back. |
| `disk_guard_changed` | MySQL | The database switched to read-only because its disk is 97% full, or switched back. |
| `version_eol_approaching` | ClickHouse | The ClickHouse version is close to the end of its support. |
| `broker_down`, `broker_recovered` | Kafka | A broker became unreachable, or came back. |
| `broker_rebuilt` | Kafka | An unreachable broker was replaced and is copying data from the other brokers. |
| `broker_unrepairable` | Kafka | The broker of a single-broker cluster couldn't be restarted. Contact us. |

## Verify the signature

Every delivery carries an `X-Signature` header with `sha256=` followed by the HMAC-SHA256 of the raw request body, keyed on the webhook's signing secret. Compute it on the raw body before you parse it, use the secret as it's shown, and compare in constant time:

[code-tabs]
```js
[label Node.js]
import crypto from "node:crypto";

export function isValidSignature(rawBody, signatureHeader, secret) {
  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(signatureHeader || "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}
```
```python
[label Python]
import hashlib
import hmac

def is_valid_signature(raw_body: bytes, signature_header: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature_header or "")
```
```ruby
[label Ruby]
require "openssl"

def valid_signature?(raw_body, signature_header, secret)
  expected = "sha256=" + OpenSSL::HMAC.hexdigest("SHA256", secret, raw_body)
  OpenSSL.secure_compare(expected, signature_header.to_s)
end
```
[/code-tabs]

To rotate the secret, remove the webhook and create a new one.

## Delivery and retries

- **Respond with a 2xx status within 10 seconds.** Do slow work after you respond.
- **Failed deliveries are retried** up to 10 attempts in total, spread across about a day.
- **Deduplicate on the `X-Delivery` header.** It stays the same for every retry of an event.
- **Order events by `occurred_at`.** A retried event can arrive after newer ones.

When an event fails all 10 attempts, the webhook is paused. The **Failed** column shows the consecutive failed attempts. Fix your endpoint, then click **⋯** next to the webhook and **Resume**. Events that happen while a webhook is paused aren't sent later.

## Need help?

Please let us know at hello@betterstack.com.  
We're happy to help! 🙏
