Webhooks
Endpoints, events, payloads, signatures and retries.
Webhooks tell your server when something happens: a payment settles, a refund completes. Each event is written in the same database transaction as the change it describes, so an event is never lost and never sent for a change that didn't happen.
Endpoints
An endpoint belongs to one project and one environment: test events go only to endpoints made with a test key.
POST /v1/webhook-endpoints (scope write)
| Field | Rules |
|---|---|
url | https (test mode also takes http), no credentials, at most 2048 characters. Every address the host resolves to must be public |
description | At most 255 characters |
enabled_events | 1 to 20 event types from the list below, or ["*"] for all (default) |
The answer is 201 with the endpoint and its signing secret, whsec_…. The secret is
shown once, here; it never appears again.
{
"id": "whe_0D4r…",
"object": "webhook_endpoint",
"environment": "test",
"url": "https://shop.example/duevance",
"description": null,
"enabled_events": ["*"],
"status": "active",
"previous_secret_expires_at": null,
"created_at": "2026-12-03T10:00:00Z",
"secret": "whsec_7Hk2…"
}
| Request | Does |
|---|---|
GET /v1/webhook-endpoints | Lists the endpoints (scope read) |
GET /v1/webhook-endpoints/{id} | One endpoint, without its secret (scope read) |
PATCH /v1/webhook-endpoints/{id} | Changes url, description, enabled_events or status (active, disabled) |
DELETE /v1/webhook-endpoints/{id} | Deletes it and its pending deliveries |
POST /v1/webhook-endpoints/{id}/roll-secret | A new secret, shown once in the answer. The old one keeps signing next to it for 24 hours |
Events
| Event | When |
|---|---|
payment.authorized | The card was approved and the amount is held, waiting for a capture. |
payment.succeeded | The payment was captured: money moved. |
payment.declined | The acquirer, or a routing rule, declined the payment. |
payment.failed | The payment provably never reached an acquirer. Nothing was charged. |
payment.expired | The payment was abandoned before any acquirer answer, or a hold lapsed. |
payment.canceled | An authorization was voided. |
refund.succeeded | A refund was confirmed by the acquirer. |
refund.failed | A refund was declined or could not be sent; its amount is refundable again. |
checkout_session.completed | A checkout session was paid. |
checkout_session.expired | A checkout session expired unpaid. |
processing sends nothing: an unknown outcome always resolves into one of these.
Test events
The dashboard's Send test event button delivers one webhook_endpoint.test event to that
endpoint only, whatever its enabled_events, signed like every other delivery. Its
data.object is { "id": "whe_…", "object": "webhook_endpoint", "url": "…", "test": true }.
Nobody subscribes to it; answer it with a 2xx like any event, or ignore unknown types.
Payload
Each delivery is a POST of the event, with Content-Type: application/json:
{
"id": "evt_0D4s…",
"object": "event",
"type": "payment.succeeded",
"environment": "test",
"created_at": "2026-12-03T10:00:00.130Z",
"data": {
"object": {
"id": "pay_0D4m…",
"object": "payment",
"status": "succeeded",
"amount": 1999,
"currency": "EUR",
"captured_amount": 1999,
"refunded_amount": 0,
"reference": "order-1001",
"decline_code": null,
"metadata": {},
"created_at": "2026-12-03T10:00:00.004Z"
}
}
}
data.object is a snapshot taken when the event happened: the payment fields above; for
refund.* a refund with id, object, payment, amount, currency, status,
decline_code and created_at; for checkout_session.* a session with id, object,
status, mode, amount, currency, reference, payment (the paying payment's id, or
null), metadata, expires_at, completed_at and created_at. Fetch the object for its
current state.
checkout_session.completed is sent in the same transaction as the payment.succeeded (or
payment.authorized) of the payment that paid it; checkout_session.expired when an unpaid
session runs out. A session whose charge is still being confirmed when it runs out waits up to
an hour more before it expires, so a slow approval can still complete it.
GET /v1/events/{id} (scope read) returns an event exactly as it was sent, for events of your
project and environment.
Verifying the signature
Every delivery carries:
| Header | Value |
|---|---|
Duevance-Event | The event type |
Duevance-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")> |
During the 24 hours after a secret roll, the header carries two v1 values, one per secret.
Accept the delivery when any v1 matches. To verify:
- Split the header on
,; readtand everyv1. - Compute
HMAC-SHA256(secret, t + "." + raw body)over the raw bytes received, before any JSON parsing. - Compare in constant time with each
v1. - Refuse a
tmore than 5 minutes old, to stop replays.
import crypto from "node:crypto";
function verify(rawBody, header, secret) {
const parts = header.split(",").map((part) => part.split("="));
const t = parts.find(([name]) => name === "t")?.[1];
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
return fresh && parts
.filter(([name]) => name === "v1")
.some(([, value]) => {
const given = Buffer.from(value, "hex");
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}
Delivery and retries
Answer with any 2xx within 10 seconds to acknowledge. Anything else, a timeout or a
connection error, is retried on this schedule (11 attempts over about three days):
| Attempt | Delay after the previous one | Since the event |
|---|---|---|
| 2 | 30 s | 30 s |
| 3 | 2 min | 2 min |
| 4 | 10 min | 12 min |
| 5 | 30 min | 42 min |
| 6 | 1 h | 1 h |
| 7 | 3 h | 4 h |
| 8 | 6 h | 10 h |
| 9 | 12 h | 22 h |
| 10 | 1 days | 1.9 days |
| 11 | 1 days | 2.9 days |
After the last attempt the delivery is marked failed. A URL that resolves to a private address,
or a live endpoint without https, fails at once; a DNS failure is retried. Redirects are never
followed.
A failed or delivered event can be sent again from the dashboard's webhooks page: the same event, with a fresh timestamp and signature.
Events can arrive more than once and out of order. Use the event id to ignore duplicates,
and the payment's own status as the truth.