Skip to content

Verify webhook deliveries

Every webhook delivery is signed with the channel secret. Verify the signature and timestamp before you act on the payload.

The signing secret needs at least 32 characters, for example a random hex string from openssl rand -hex 32. A channel saved earlier with a shorter secret keeps working until you enter a new secret.

Header Value Signed
X-Heptapod-Timestamp Unix seconds in decimal, new for each delivery attempt Yes
Signature Lowercase hexadecimal HMAC-SHA256 of timestamp + "." + raw JSON body, with the channel secret —
X-Heptapod-Delivery, Idempotency-Key Delivery hints. Do not use them to deduplicate. No
  1. Read the raw request bytes before any JSON parsing.
  2. Reject malformed headers with 401.
  3. Reject a timestamp more than 300 seconds away from your clock, in either direction. Keep both clocks synchronized.
  4. Compute the HMAC of timestamp + "." + raw body and compare it with Signature in constant time. Reject a mismatch with 401.
  5. Parse the signed body.
  6. Record (event_id, destination_id) atomically before any side effect. Skip the event if it is already recorded.
  7. Return 2xx for a processed event, also when it was processed before.
  • Keep the deduplication keys for the full retry period. Retries get a fresh timestamp but the same signed IDs.
  • The timestamp window alone does not stop a replay inside the window.
  • A test delivery has is_test: true and event_id: 0. Use it to verify your receiver, without side effects.
  • Signatures over the body alone are not accepted.

Webhook channels require HTTPS. Set allow_insecure_http to true only for a trusted HTTP receiver, such as a local test fixture. It is false by default. Over HTTP the payload and signature are visible on the network; the signature does not encrypt anything.

Field Content
headline The delivered event, not the check’s state at delivery time. It names the check when the headline does not. If run evidence has expired, it uses the event’s retained summary.
title, summary Title and summary of the alert.
changes Localized change descriptions, apart from the headline of a Warning or Failed result. Empty when there are none.
details Localized secondary facts, such as links that could not be verified. Empty when there are none.
Field Content
severity Urgency, not cause: down, recovered, warning, error or info. Both an uptime outage and a non-uptime failure can be down, and both bypass quiet hours.
downtime_seconds For uptime, the downtime. For other checks, how long the failure lasted, not proof that the site was down.
also_affected, rechecking Check keys grouped under an uptime outage, or waiting for a re-check after it. [] when empty.
site_id, link Set for every site alert: an alert whose site was deleted before it went out is not sent.
repositories The site’s repository links, [{"url": …, "label": …}], for team and personal channels. Always [] for a client’s channel.
  • Read the event type, check type and result to tell a Down site from a Failed check. Never label every down severity as an outage.
  • Dates use ISO 8601, also inside summary.
  • summary labels durations as “Total downtime” for every check type.
  • If a Down alert has not been attempted before recovery is confirmed, the webhook receives one combined delivery with severity: "recovered", since, downtime_seconds and a “was down …, up again” title. Once a Down attempt starts, retries keep its original format so deduplicating receivers still receive Recovered.

A webhook channel receives System alerts when System is on for it in the team notification settings. They report a problem with the Heptapod instance, such as a failed backup, a stopped scheduler or failing email, and its recovery. The payload has the same keys as other alerts:

Field Value
site_id, site_label, site_url, check_type null
title Starts with [System], or [System recovered] for a recovery
headline The recommended action, or what changed for a recovery
summary Localized facts, one per line
severity down or warning for a problem, recovered for a recovery
cause null
repositories []
link System health

Each problem and recovery is sent once per channel with its own event_id.

Server monitoring is experimental. A webhook channel receives server alerts when Servers is on for it in the team notification settings and the channel is not limited to one client. They report a problem on a monitored server, such as a full disk, and its recovery. The payload has the alert keys plus a server object:

Field Value
server {"id": 3, "name": "web-1", "url": "https://heptapod.example.com/servers/3"}
server.url The server page; null once the server is removed
site_id, site_label, site_url, check_type null
title Starts with [Server], or [Server recovered] for a recovery
headline The measurement and its threshold, or what changed for a recovery
summary Localized facts, one per line
severity warning for a problem, recovered for a recovery
link The server page; null once the server is removed

Other alerts have no server key.

Returns 401 when verification fails. $secret comes from your receiver configuration.

$raw = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_HEPTAPOD_TIMESTAMP'] ?? '';
$signature = $_SERVER['HTTP_SIGNATURE'] ?? '';
if (!preg_match('/^[1-9][0-9]{0,9}$/D', $timestamp)
|| !preg_match('/^[a-f0-9]{64}$/D', $signature)
|| abs(time() - (int) $timestamp) > 300
|| !hash_equals(hash_hmac('sha256', $timestamp.'.'.$raw, $secret), $signature)) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true, flags: JSON_THROW_ON_ERROR);
// Atomically record [$event['event_id'], $event['destination_id']] before side effects.

Call it before any JSON or body middleware. rawBody is the original Buffer.

import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyWebhook(
rawBody,
headers,
secret,
now = Math.floor(Date.now() / 1000),
) {
const timestamp = headers['x-heptapod-timestamp'];
const signature = headers.signature;
if (
typeof timestamp !== 'string' ||
!/^[1-9][0-9]{0,9}$/.test(timestamp) ||
typeof signature !== 'string' ||
!/^[a-f0-9]{64}$/.test(signature) ||
Math.abs(now - Number(timestamp)) > 300
) {
return false;
}
const expected = createHmac('sha256', secret)
.update(timestamp + '.')
.update(rawBody)
.digest();
return timingSafeEqual(expected, Buffer.from(signature, 'hex'));
}
// Reject with 401 when false. Parse JSON and atomically deduplicate signed IDs when true.