# Webhook signatures and delivery

> The request WP Waterfall sends, how to check its signature, and how retries and redelivery work.

Source: https://docs.wpwaterfall.com/developers/webhooks

WP Waterfall sends a signed HTTP request to your endpoint when something happens: a job finishes, a deploy ends, a backup completes. [Webhooks](https://docs.wpwaterfall.com/webhooks) explains how to set up an endpoint in the dashboard. This page covers the request, how to check its signature, and how retries and redelivery work.

This page describes the `json` format. An endpoint with `format` set to `slack`, `discord`, or `teams` gets a message written for that chat tool instead, with the same event headers, retries, and delivery log, and no signature.

## How do I create an endpoint?

Create an endpoint with `POST /v1/webhooks`. Give it a public https URL and the event types it should receive. Use `["*"]` for every event. The response includes the signing secret once. Store it. WP Waterfall keeps only an encrypted copy and cannot show it again.

To send a test event to one endpoint, call `POST /v1/webhooks/{id}/test`. A test event reaches that endpoint only, whatever its event filter says. Its deliveries are marked as tests.

A disabled endpoint receives nothing. Events that happen while it is disabled are not queued for later delivery.

## What does a delivery look like?

Each delivery is an HTTP `POST` with a JSON body:

```json
{
  "id": "evt_01...",
  "type": "job.succeeded",
  "version": 1,
  "created_at": "2026-10-05T12:00:00.000Z",
  "company_id": "co_01...",
  "data": {}
}
```

`id` is the event id. It stays the same on every retry and every redelivery, so use it to ignore duplicates. The body never includes secrets. A `job.*` event carries the result of the job, with one exception: when the result holds what is on a site (the rows of a SQL statement, the output of a WP-CLI command, a database import, a search and replace, a new WordPress user), `result` is `null`. Read that result from `GET /v1/jobs/{id}` with a key or a role that may see it.

Headers:

| Header | Meaning |
|---|---|
| `wpwaterfall-signature` | The signature. See below. |
| `wpwaterfall-event-id` | The event id. Same as `id` in the body. |
| `wpwaterfall-event-type` | The event type, such as `job.succeeded`. |
| `wpwaterfall-delivery-id` | The delivery id. Different for each endpoint. |
| `wpwaterfall-timestamp` | Unix seconds when the signature was made. |
| `User-Agent` | `WP Waterfall-Webhooks/1.0`. |

Respond with any 2xx status within 5 seconds. WP Waterfall does not follow redirects, so a 3xx counts as a failure.

## How do I verify the signature?

The header has this form:

```
wpwaterfall-signature: t=<unix seconds>,v1=<hex hmac>
```

During a secret rotation the header carries two `v1` values, one per secret. Either one verifies.

The signed text is the timestamp, a period, and the exact bytes of the request body:

```
signed_content = "<t>." + body
```

The signature is the lowercase hex HMAC-SHA256 of `signed_content`, keyed with the endpoint secret as UTF-8. The secret starts with `whsec_`.

To verify a delivery:

1. Read the raw body as bytes or text, before any JSON parsing.
2. Parse `t` and every `v1` value from `wpwaterfall-signature`.
3. Refuse the request if `t` is more than 300 seconds (5 minutes) away from your clock. This stops a captured delivery from being replayed later.
4. Compute the HMAC for each secret you hold. Compare it with each `v1` value using a constant-time comparison.
5. Accept only if one matches.

Node.js example:

```js
import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyWpWaterfallSignature(rawBody, header, secret, toleranceSeconds = 300) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const timestamp = Number(parts.t);
  const given = header.split(",").filter((p) => p.startsWith("v1=")).map((p) => p.slice(3));
  if (!Number.isInteger(timestamp) || given.length === 0) return false;
  if (Math.abs(Math.floor(Date.now() / 1000) - timestamp) > toleranceSeconds) return false;
  const expected = createHmac("sha256", secret).update(`${timestamp}.${rawBody}`, "utf8").digest();
  return given.some((hex) => {
    const candidate = Buffer.from(hex, "hex");
    return candidate.length === expected.length && timingSafeEqual(candidate, expected);
  });
}
```

Verify with the raw body. A parsed and re-serialized body will not match.

## How do retries work?

A try fails when the endpoint answers with a non-2xx status, does not answer within 5 seconds, refuses the connection, or answers with a redirect.

After a failed try, WP Waterfall waits and tries again, up to 5 retries (6 tries in all). The waits are:

| Retry | Wait after the failed try |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 12 hours |

If the last retry fails, the delivery is dead. WP Waterfall stops trying it. After five dead deliveries in a row on one endpoint, WP Waterfall turns that endpoint off and records the reason. Turning the endpoint back on clears the count.

## How do I redeliver an event?

`POST /v1/webhook-deliveries/{id}/redeliver` queues a new attempt of the same event to the same endpoint. The event id does not change. The new attempt is logged as manual.

## Where is the delivery log?

`GET /v1/webhooks/{id}/deliveries` lists deliveries, newest first. Filter by `status` or `event_type`. Each delivery has one row per try in `GET /v1/webhook-deliveries/{id}`, with the request headers (the signature value is masked), the status code, the first 4 KiB of the response body, the duration, and any error sentence. The `url` of a try is the host the request went to, such as `hooks.slack.com`, and never the rest of the address. The log is kept for 30 days.

## How do I rotate the secret?

`POST /v1/webhooks/{id}/rotate-secret` returns a new secret once. The old secret keeps signing for 24 hours, so you can deploy the new one without downtime. Check either signature during that window.

## Which URLs can I use?

WP Waterfall delivers only to public hosts:

- The URL must use `https`. Plain `http` is refused unless your company has the private target allowlist.
- The URL must not carry a username or password.
- WP Waterfall resolves the hostname before each delivery. Every address must be public. Loopback, link-local (including the cloud metadata address), RFC 1918 private ranges, carrier NAT, unique local IPv6, and multicast addresses are refused.
- A refused URL answers `422` with a sentence that says why.

## Which events are sent?

`GET /v1/webhooks/events` lists every event type with its group and a one-line description. [Webhooks](https://docs.wpwaterfall.com/webhooks#which-events-are-sent) lists them by category and explains the less obvious ones. Each event type has a sample payload in the event catalog, and you can send any of them to an endpoint with `POST /v1/webhooks/{id}/test` and `{"event_type": "site.created"}`.

## When is an event sent?

Most events follow a job: when the job finishes, WP Waterfall sends its `job.*` event and then the event for what the job did. A few follow a change that is not a job: `site.updated`, `domain.added`, the DNS zone and record events, `security.two_factor_changed`, the plan and invoice events, `usage.threshold`, `ssl.expiring`, `migration.status_changed`, and `site.down` and `site.up`. An automatic updates run (including Safe Updates) and an integrity check are jobs, so their events follow the job.
