Guides
Webhooks: register, verify, retry
Register an HTTPS endpoint (an empty filter means payment events only; billing events are opt-in), verify the ZeroPoint-Signature header in ten lines, handle retries and out-of-order events, catch up from the event list, and rotate secrets without downtime.
1. Register
This call requires an Idempotency-Key header, like every POST that creates something. Register each URL once per environment: GET /v1/webhooks (the list_webhooks tool) lists what exists, and every event is delivered once per active endpoint, so a URL registered twice receives everything twice. The register_webhook tool answers with a warning and existing_endpoint_ids when an active endpoint already posts to that URL. Response 201 includes secret (starts with whsec_), shown exactly once. The URL must be https on a public host; localhost, private addresses, multicast addresses, translation addresses that wrap a private one (NAT64, IPv4-mapped, 6to4, Teredo) and any IPv6 address outside global unicast space (2000::/3) are rejected with webhook_url_invalid. So is a host name that does not resolve within 3 seconds (did not resolve in time); if the message says the name could not be looked up right now, the resolver was busy and the same request will work in a few seconds. We look your host name up at most about once a minute, so allow a minute for a DNS change to take effect. While you have no receiver yet, POST /sandbox/webhook-sink on the hosted service accepts anything and answers 200.
What event_types subscribes to:
event_types | Receives |
|---|---|
| empty or left out | Every payment event (the list at the end of this guide). No billing event, now or later. |
["*"] | Every event type, payment and billing, including types added later. "*" must be the only entry. |
| a list of names | Exactly those types. Up to 50 names. |
Billing events (checkout, invoice, subscription, customer and payment method events) are opt-in: they go only to endpoints that list them or use ["*"]. An endpoint registered with no types gets no billing event and no error, so a Stripe-style integration that registers an endpoint with no types and waits for invoice.paid waits forever. Name the types, or use ["*"]. billing-webhooks lists them and what each carries.
Use a separate endpoint for billing events. Pauses are per endpoint (section 5), so a bug in a billing handler that makes it answer non-2xx would also delay the payment events sharing that endpoint.
2. What arrives
data.object is the full object as it looked when the event fired. A payment object always has a partial_approval field: null unless the processor approved the sale for less than was asked, then processor_transaction_id, approved_amount_cents, requested_amount_cents, reversed and reversed_at (see the payment states guide). Answer any 2xx within 10 seconds; do slow work after responding. The 10 seconds is one deadline for the whole exchange (looking up your host name, connecting, TLS, sending the event, and receiving your status line and headers), not a pause allowed between bytes: a receiver that has not finished its response headers by then is recorded as timed out after 10s, however much it had sent. Only the status code is used; the response body is never read. Aim for well under 5 seconds: a 2xx that takes 5 seconds or longer is delivered, but counts against the endpoint exactly like a failure when it comes to pausing it (section 5).
3. Verify the signature
The signed payload is "{t}.{raw_body}", the digest is HMAC-SHA256 hex with your secret, and t must be within 5 minutes of now.
Python:
import hmac, hashlib, time
def verify(header: str, body: bytes, secret: str) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
ts = int(parts["t"])
if abs(time.time() - ts) > 300:
return False
expected = hmac.new(secret.encode(), f"{ts}.".encode() + body, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(expected, v) for k, v in
(p.split("=", 1) for p in header.split(",")) if k == "v1")Node:
const crypto = require("crypto");
function verify(header, rawBody, secret) {
const parts = header.split(",").map(p => p.split("="));
const t = parts.find(([k]) => k === "t")[1];
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(`${t}.`).update(rawBody).digest("hex");
return parts.filter(([k]) => k === "v1").some(([, v]) =>
v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
}Use the raw request body bytes, not a re-serialized JSON object.
4. Prove it works
Delivers one webhook.test event right now, waits up to 5 seconds for your answer (/test and /verify use a shorter deadline than the 10 seconds a normal delivery gets), and returns the delivery with status: delivered or failed plus response_status and last_error. A delivered signed event is what integration_checklist counts as the legacy webhook_verified milestone, recorded on the endpoint so it outlives the 30-day delivery history. That name is retained for compatibility: it proves delivery only. The step's evidence reports signed_test_delivered, receiver_signature_validation: not_recorded and business_effect_deduplication: not_observed. Neither this milestone nor a successful /test call proves that your receiver rejects bad signatures.
Sample billing events, test mode only. Send /test a body with event_type and merchant_id to get one sample of a billing type instead of webhook.test (the send_sample_event tool is the same call):
The sample is the documented payload of that type, with "sample": true beside data.object, your test merchant as merchant_id, and ids that exist nowhere (a prefix and 26 zeros, so a GET answers 404). It goes to this endpoint only, and only if the endpoint subscribes to the type; otherwise the answer is 400 parameter_invalid and nothing is sent. A live key gets 403 live_mode_unavailable. Samples share the budget below and count toward the sandbox's daily event ceiling. A sample also appears in GET /v1/events, so a handler that acts on events should skip any event whose data.sample is true. A sample proves your parsing, never your business effects: for those, drive the real flow in the sandbox.
Runs the scorecard (the verify_webhook tool is the same call) and returns a webhook_scorecard with passed and four checks:
| check | Your receiver must |
|---|---|
signed_event_delivered | Answer 2xx to a correctly signed webhook.test event |
responds_fast | Answer within 5 seconds (do slow work after responding) |
replay_accepted | Answer 2xx again when the same ZeroPoint-Event-Id arrives a second time, and ignore the repeat |
bad_signature_rejected | Answer a non-2xx (401 is conventional) to a delivery whose signature does not verify |
The scorecard names both deliveries: delivery_id is the signed send and replay_delivery_id is the repeat of the same event id (null when the first delivery failed or was not fast). When the first send fails or takes 5 seconds or longer the run stops there: replay_accepted and bad_signature_rejected come back passed: false with a detail saying they were not run, so fix that first and run verify again. Both appear in GET /v1/webhooks/{webhook_id}/deliveries, so two webhook.test rows with one event id are one scorecard run, not a bug; the bad-signature probe does not appear, because it is not an event. The hosted /sandbox/webhook-sink passes the first three checks only: it answers 200 to everything, including the bad signature. Neither /test nor /verify takes an Idempotency-Key, and neither does /redeliver below: each is a deliberate fresh attempt, not a request you would ever want replayed from a cache.
/test and /verify wait for your receiver, so they are limited. One run at a time per account, and only a few across the whole service at once (some of those are kept for live-mode keys). In any 10 minutes: at most 10 runs per endpoint and 30 per account, test and verify together, one verify being one run; and at most 30 seconds, per account, of runs waiting on your receiver, so a receiver that answers in 100 ms never notices this and one that takes 5 seconds uses it up in six sends. Past any of these the answer is 429 rate_limited with a Retry-After header and nothing was sent: wait that many seconds and call again. The verify_webhook tool has the same limits; its error message carries the seconds to wait.
Developing locally
ZeroPoint never delivers to localhost, a private address or plain http: that refusal protects the service and stays on. Three ways to run your receiver on your own machine, test mode only:
- The listen helper in the
zeropoint.node.subscriptionssnippet (listen.mjs,get_snippet). Register an endpoint at a public URL you own, or at the hosted/sandbox/webhook-sink, keep itswhsec_secret, and runlisten({apiBase, apiKey, secret, webhookId, forwardTo: 'http://localhost:3000/webhooks/zeropoint'})beside your app. Every 2 seconds it reads that endpoint's new deliveries (GET /v1/webhooks/{webhook_id}/deliveries) and each event (GET /v1/events/{event_id}), and posts it to your local URL with the same body bytes and the sameZeroPoint-Signature,ZeroPoint-Event-IdandZeroPoint-Delivery-Idheaders a delivery has, signed with your secret on your machine. Your real verification code runs unchanged. ZeroPoint shows a secret once, when you register or rotate the endpoint, and no route reads it back; the helper uses the one you already hold. It refuses azp_live_key, anhttp://API base other than this machine, and a non-loopback target, never follows a redirect from your receiver, and does not rebuild the Stripe view of an endpoint withstripe_compatible_payload. - A tunnel: any HTTPS tunnel to your machine gives you a public HTTPS URL to register. Deliveries then arrive for real, with retries, and
verify_webhookscores your receiver. - Polling instead of a receiver:
GET /v1/events(MCPlist_events) withtypesandsincereturns the same events withdata.object; apply eachevent.idonce. Use it to catch up, or while you have no receiver.
On a test clock, events are delivered a few seconds after get_test_clock reports ready (see test-billing-with-test-clocks).
5. Retries and idempotency
A non-2xx or a timeout is retried on one of two schedules. Which one is fixed when the delivery is created, and GET /v1/webhooks/{webhook_id}/deliveries shows each delivery's attempt and next_attempt:
| Delivery | Retried after each failure | Attempts | Dead at the latest |
|---|---|---|---|
| Payment events, and every delivery in test mode | 1, 5 and 15 minutes | 4 attempts, the last 21 minutes after the first | 24 hours after it was created |
| Billing events delivered to a live endpoint | 1, 5 and 15 minutes, then 1, 3, 6, 12, 24 and 24 hours | 10 attempts, the last 70 hours 21 minutes after the first | 72 hours after it was created |
Payment events, and every delivery in test mode, keep the short schedule: a payment usually has an API answer behind it, test endpoints are often left unanswered, and test events are deleted after 14 days. A billing event (a renewal, a cancellation) often has no request behind it, so in live mode it gets about 3 days, as at Stripe. Billing events are opt-in (section 1), so an endpoint that does not list them never sees this schedule. After the last attempt the delivery is dead. The same event can arrive more than once: store ZeroPoint-Event-Id (or id) and ignore repeats. Inspect attempts with GET /v1/webhooks/{webhook_id}/deliveries, and resend one with POST /v1/deliveries/{delivery_id}/redeliver after fixing your receiver.
Delivery order is not guaranteed, between endpoints or within one: a retry, a redelivery or a pause can put a later event ahead of an earlier one. Never order by arrival, and not by created either: it is whole seconds, and one change can write several events in the same second.
What is ordered is the ledger. GET /v1/events and the list_events tool list events newest first in event id order, and for billing events id order is the order they were written: events written together in one change are listed in the order written, and a later change's events come after. Use the list, not arrival order, when order matters.
How to handle events that arrive late or out of order:
- Deduplicate by event id, and only by event id. Run each event's handler once per
id, whatever else the event says. - Billing events carry
data.object_version, a number per object that rises with each change. Use it only to decide whether to replace your stored copy of the object: replace it when the event'sobject_versionis greater than or equal to the one you stored, and keep your copy when it is lower. Never use it to skip a handler. One change can send two events for one object with the sameobject_version(invoice.paidandinvoice.payment_succeeded,invoice.payment_failedandinvoice.voided,invoice.payment_failedandinvoice.marked_uncollectible), and a rule that drops an event whose version is not higher than the last one loses the second event of each pair. - Decide access and plan from your stored copy after step 2, not from the
data.objectof the event in hand. A latecustomer.subscription.updatedshowingactivemust not give access back after a newercustomer.subscription.deletedwas stored. Event-specific actions, such as sending a receipt oninvoice.paid, run once per event id. - Or, when order matters, read the current object from the API instead of trusting the event's copy.
Catching up. A delivery that dies is not sent again on its own, so a receiver that was down for longer than its retry window misses those events. Every event stays in GET /v1/events, on either schedule and after its delivery is dead, so that list is the catch-up path: poll it every few minutes and on startup, and pass each event through the same handler, deduplicated by id. Set since to the newest created you have handled minus 300, and repeat types once per type you handle:
types takes up to 50 names and cannot be combined with type. Page to the end: pass next_cursor as cursor until has_more is false. Keep the 300-second overlap: since compares created, which is set when an event is written, not when its change is saved, so an event can show up in the list a moment after a later one, and a poll that starts exactly at the newest created it saw could miss it. The overlap also covers whole-second created values and your own clock. Reading an event twice costs nothing, because the handler deduplicates by id.
Deliveries are sent a few per endpoint and per account at a time, taking turns between accounts and endpoints, live mode first with a share of every pass kept for test mode, so a backlog or a slow receiver on one endpoint does not hold up another.
Pauses. After three strikes in a row on one endpoint, a strike being a failed attempt or a 2xx that took 5 seconds or longer, sending to it pauses for 1 minute, then 5, then 15 for as long as the strikes continue. While it is paused, its due deliveries are postponed to the end of the pause without using an attempt; next_attempt shows the postponed time. When the pause ends one delivery is sent as a probe:
- A prompt
2xxends the pause. The postponed deliveries go out straight away, a few per pass. - A slow
2xxis delivered, and the pause starts again. Nothing else is charged. - A failure starts the pause again and counts as a failed attempt for every delivery of that endpoint that was due, not only the one that was sent: each uses one of its attempts and takes its next retry delay, with
last_errorbeginningnot sent: endpoint paused after repeated failures. A delivery that is not yet due is not charged. A delivery is only everdeadafter all its attempts (4, or 10 on the long schedule) counted this way or made for real, or at a limit below.
Live billing deliveries have their own pauses, kept apart from the endpoint's payment deliveries: a billing handler that keeps failing never pauses or charges payment deliveries, and the other way round. In test mode billing deliveries are on the short schedule and share the endpoint's pauses with payment events. When our service restarts it forgets pauses, so until an endpoint answers again it gets one live billing delivery per pass; the rest wait, uncharged.
What this means for timing on the short schedule: a retry is never sooner than the 1, 5, 15 minute schedule, and can be later. Against an endpoint that never answers, the deliveries that were first to fail are dead 21 minutes after they were first due, exactly as the schedule says; a backlog queued behind them is dead one pause later, at 36 minutes; and the worst case for any delivery, one that becomes due just after a probe has failed, is 60 minutes (four pauses of 15). Nothing waits longer than that for a dead endpoint. On the long schedule a retry is likewise never sooner than its step and can be up to one pause (15 minutes) later; against an endpoint that never answers a live billing delivery is dead about 70 hours 21 minutes after it was first due, and never later than 72 hours after it was created.
Age limit. A delivery still not delivered 24 hours after it was created (72 hours on the long schedule) is marked dead with last_error beginning not delivered within 24 hours (or not delivered within 72 hours; any earlier error follows it), however many attempts it has used. In practice it applies to a queue behind a receiver that keeps being paused for slow answers without ever failing. A dead delivery, from this or from its last attempt, can still be sent again with redeliver, and the event stays in GET /v1/events.
Backlog limit. One endpoint holds at most 10,000 live billing deliveries waiting to be sent. Past that, the oldest are marked dead with last_error beginning backlog limit. Nothing is deleted: their events stay in GET /v1/events.
When live billing deliveries die, you hear about it without polling. The delivery list shows each one with status: dead, and we email your account's contact email with the endpoint URL, how many billing events died and their event ids, once per endpoint per day at most while more die. Fetch the events from GET /v1/events with types (catching up, above) and redeliver from the console or with POST /v1/deliveries/{delivery_id}/redeliver.
Getting back after you fix a receiver: any prompt 2xx from it ends the pause, and a successful POST /v1/webhooks/{webhook_id}/test is the quick way to produce one. Deliveries the pause had postponed then go out at once; deliveries that have already failed, or were charged for a failed probe, keep their own retry time (next_attempt), or you can redeliver them.
redeliver answers 429 rate_limited with Retry-After, and queues nothing, while the endpoint already has 10 or more deliveries waiting for their first attempt. If the endpoint is paused, Retry-After is the rest of the pause and the message says so; a successful /test ends the pause sooner. Otherwise it is a few seconds: let the queue go out, then redeliver.
Code written for Stripe's webhooks
Two switches per endpoint, both off unless you set them on POST /v1/webhooks or PATCH /v1/webhooks/{webhook_id}:
stripe_signature_header: true: every delivery also carriesStripe-Signaturewith the same value asZeroPoint-Signature, so Stripe'swebhooks.constructEventverifies it with yourwhsec_secret.ZeroPoint-Signatureis always sent. Leave it off for a URL that also receives real Stripe deliveries while you migrate.stripe_compatible_payload: true: a checkout session whose payment is still being confirmed is delivered withpayment_status: "unpaid"andzeropoint_payment_status: "processing", so a handler copied from Stripe grants nothing early. The signature covers the bytes sent.
6. Rotate the secret
POST /v1/webhooks/{webhook_id}/rotate-secret (requires an Idempotency-Key header, like every POST that creates something) returns a new secret. For 24 hours deliveries carry two v1= values, one per secret, so update your receiver at your own pace. PATCH /v1/webhooks/{webhook_id} with {"active": false} pauses deliveries; DELETE /v1/webhooks/{webhook_id} removes the endpoint.
Event types
Payment events, sent to an endpoint with an empty event_types: payment.processing, payment.succeeded, payment.failed, payment.canceled, payment.expired, payment.reversed_late, payment.needs_attention, refund.succeeded, refund.failed, terminal.online, terminal.offline, merchant.state_changed, webhook.test. GET /v1/events lists the ledger for reconciliation.
Billing events, sent only to endpoints that list them or use ["*"]: checkout.session.completed, checkout.session.expired, invoice.paid, invoice.payment_succeeded, invoice.payment_failed, invoice.upcoming, invoice.voided, invoice.marked_uncollectible, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, payment_method.attached, payment_method.detached, customer.created, customer.updated, customer.deleted. You can subscribe to each name now; a type arrives once the feature that produces it is available in your account. billing-webhooks covers the payloads, the Stripe mapping and the differences from Stripe.
payment.reversed_late and refund.succeeded each have two producers: your own actions (a late tap on a terminal, a refund you called), and our background reconciliation, which polls the processor independently every five minutes and can raise the same events for something it found with no call of yours behind it. Both look the same on the wire; your handler does not need to know which one fired them. refund.succeeded carries an origin field (api or external) if you want to tell them apart anyway. payment.needs_attention is reconciliation-only: a discrepancy it found but would not act on alone. The reconciliation guide covers all of this in full.
refund.failed is not always final. Read data.object.failure_code: with processor_unverified the refund's outcome at the processor is unknown, not refused, and the same refund id can later produce refund.succeeded or a second refund.failed with a definite code. Do not refund by other means on a processor_unverified event; retry the same request with the same Idempotency-Key or contact support. Every other refund failure_code (processor_rejected, not_settled, processor_not_connected, operator_confirmed_not_processed) is final. The refunds-and-voids guide has the table.