Webhook recipes: subscribe, verify and handle deliveries
developers-webhook-recipesOn this page
Copy-paste webhook code in curl, JavaScript and PHP: subscribe to an event, check the signature, ignore repeats, answer in time and stop deliveries.
Five things you'll do with webhooks, ready to copy, each in three tabs: curl, JavaScript and PHP. $SKEDULER_API is your Skeduler API address and $ACCESS_TOKEN an access token (see API recipes). SKEDULER_SIGNING_SECRET is the signing secret you got when you subscribed. In the JavaScript and PHP tabs, the same names in capitals are variables you set. Nothing here is a real key or secret.
1. Subscribe to an event
Scope: none beyond the event's own read scope (for example read:jobs for job.created). Keep the signing_secret from the answer: it's shown only once.
curl
curl -s -X POST "$SKEDULER_API/api/v1/webhooks/subscriptions" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"event":"job.created","target_url":"https://example.com/skeduler/webhook"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/webhooks/subscriptions`, {
method: "POST",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
body: JSON.stringify({ event: "job.created", target_url: "https://example.com/skeduler/webhook" }),
});
const { data } = await res.json();
// Store data.signing_secret somewhere safe now: it isn't shown again.
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/webhooks/subscriptions", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['event' => 'job.created', 'target_url' => 'https://example.com/skeduler/webhook'],
]);
$data = json_decode((string) $res->getBody(), true)['data'];
// Store $data['signing_secret'] somewhere safe now: it isn't shown again.
See Subscribe to webhook events and Webhook events and payloads.
2. List your subscriptions
Check what's subscribed, and whether a subscription has been switched off (status is disabled).
curl
curl -s "$SKEDULER_API/api/v1/webhooks/subscriptions" \
-H "Authorization: Bearer $ACCESS_TOKEN"
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/webhooks/subscriptions`, {
headers: { Authorization: `Bearer ${ACCESS_TOKEN}` },
});
const { data } = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', "$SKEDULER_API/api/v1/webhooks/subscriptions", [
'headers' => ['Authorization' => "Bearer $ACCESS_TOKEN"],
]);
$data = json_decode((string) $res->getBody(), true)['data'];
3. Receive a delivery and check its signature
Check the X-Skeduler-Signature-V2 header (t=<unix seconds>,v1=<hex>) on every delivery: v1 must equal HMAC-SHA256(secret, "<t>.<raw body>"), and t must be within 5 minutes of your clock. Use the raw body, exactly as received. The curl tab sends your own endpoint a signed test delivery, so you can try your code before Skeduler sends a real one.
curl
# Send yourself a signed test delivery. YOUR_WEBHOOK_URL is your own endpoint.
BODY='{"event":"job.created","occurred_at":"2026-11-03T01:00:00+00:00","delivery_id":"TEST_DELIVERY_ID","data":{"id":"JOB_ID","title":"Hot water system repair"}}'
T=$(date +%s)
SIG=$(printf '%s' "$T.$BODY" | openssl dgst -sha256 -hmac "$SKEDULER_SIGNING_SECRET" -hex | sed 's/^.* //')
curl -s -X POST "$YOUR_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-H "X-Skeduler-Signature-V2: t=$T,v1=$SIG" \
-d "$BODY"
JavaScript (fetch)
// Node with Express. express.raw keeps the exact bytes; don't use express.json() here.
import crypto from "node:crypto";
import express from "express";
const app = express();
app.post("/skeduler/webhook", express.raw({ type: "application/json" }), (req, res) => {
const parts = Object.fromEntries((req.get("X-Skeduler-Signature-V2") ?? "").split(",").map((p) => p.split("=", 2)));
const t = Number(parts.t);
if (!parts.v1 || !Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > 300) return res.sendStatus(400);
const expected = Buffer.from(crypto.createHmac("sha256", SKEDULER_SIGNING_SECRET).update(`${t}.`).update(req.body).digest("hex"), "hex");
const given = Buffer.from(parts.v1, "hex");
if (given.length !== expected.length || !crypto.timingSafeEqual(given, expected)) return res.sendStatus(400);
const delivery = JSON.parse(req.body.toString("utf8"));
res.sendStatus(200); // answer first; do the work afterwards (recipe 5)
handle(delivery);
});
PHP (Guzzle)
<?php
$raw = file_get_contents('php://input'); // the exact bytes
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_SKEDULER_SIGNATURE_V2'] ?? ''), $parts);
$t = $parts['t'] ?? '';
$given = $parts['v1'] ?? '';
if (! ctype_digit((string) $t) || $given === '' || abs(time() - (int) $t) > 300) {
http_response_code(400);
exit;
}
if (! hash_equals(hash_hmac('sha256', $t.'.'.$raw, $SKEDULER_SIGNING_SECRET), $given)) {
http_response_code(400);
exit;
}
$delivery = json_decode($raw, true);
http_response_code(200);
If the signature never matches, see My webhook signature doesn't match.
4. Ignore a repeat
The same event can arrive more than once, for example after a retry. Its delivery_id stays the same, so keep the ids you've handled and skip one you've seen. If one endpoint takes deliveries for more than one subscription, key on the subscription as well as delivery_id: the same event has the same delivery_id in each. The curl tab sends the same test delivery twice: your endpoint should answer 2xx both times, and handle it once.
curl
# Run the recipe 3 commands, then send the same body again with a fresh signature.
T=$(date +%s)
SIG=$(printf '%s' "$T.$BODY" | openssl dgst -sha256 -hmac "$SKEDULER_SIGNING_SECRET" -hex | sed 's/^.* //')
curl -s -X POST "$YOUR_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-H "X-Skeduler-Signature-V2: t=$T,v1=$SIG" \
-d "$BODY"
JavaScript (fetch)
// In memory, for a single process. With more than one, use your database (a unique key on delivery_id).
const seen = new Map(); // delivery_id -> when it was handled
function firstTime(deliveryId) {
const now = Date.now();
for (const [id, at] of seen) if (now - at > 10 * 60 * 1000) seen.delete(id); // keep 10 minutes
if (seen.has(deliveryId)) return false;
seen.set(deliveryId, now);
return true;
}
// In the handler, after the signature check:
// if (!firstTime(delivery.delivery_id)) return res.sendStatus(200);
PHP (Guzzle)
// With PDO: a table with delivery_id as its primary key. A repeat fails the insert, so it's skipped.
$pdo->exec('CREATE TABLE IF NOT EXISTS webhook_deliveries (delivery_id TEXT PRIMARY KEY, received_at TEXT)');
$insert = $pdo->prepare('INSERT INTO webhook_deliveries (delivery_id, received_at) VALUES (?, ?)');
try {
$insert->execute([$delivery['delivery_id'], gmdate('c')]);
} catch (\PDOException $e) {
http_response_code(200); // already handled: answer 2xx, do nothing
exit;
}
5. Answer in time, or stop deliveries
Answer 2xx within 10 seconds, and do slow work afterwards. A 4xx or 5xx answer, or a timeout, is retried up to 4 times (after 10 seconds, 30 seconds, 1 minute and 2 minutes). To stop a subscription for good, answer 410 Gone to a delivery, or unsubscribe:
curl
curl -s -X DELETE "$SKEDULER_API/api/v1/webhooks/subscriptions/SUBSCRIPTION_ID" \
-H "Authorization: Bearer $ACCESS_TOKEN"
JavaScript (fetch)
await fetch(`${SKEDULER_API}/api/v1/webhooks/subscriptions/SUBSCRIPTION_ID`, {
method: "DELETE",
headers: { Authorization: `Bearer ${ACCESS_TOKEN}` },
});
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$client->request('DELETE', "$SKEDULER_API/api/v1/webhooks/subscriptions/SUBSCRIPTION_ID", [
'headers' => ['Authorization' => "Bearer $ACCESS_TOKEN"],
]);
In this section
- How webhooks work: subscriptions, events and deliveries
- Subscribe to webhook events
- Verify a webhook signature
- Webhook events and their payloads
- Webhook retries, duplicates and switch-off
- I'm not receiving webhook deliveries
- My webhook signature doesn't match
- My webhook subscription was disabled
- Does an integration get webhooks for its own API writes?