Webhooks and background updates
Zwipe POSTs an event to your HTTPS webhook URL when one of your cards reaches a final issuing state; chain accounts also get load and transaction events. Your Zwipe contact sets the URL on your partner account and hands you a signing secret over a secure channel.
Event types
Section titled “Event types”| Type | Fires when |
|---|---|
card.issued |
The card is active. On cards from POST /v1/cards, a card that was in_doubt with error_code activation_pending turns issued when a balance read (GET /v1/cards/{card_id}/balance) succeeds; the event follows it |
card.failed |
The issuer rejected the order or could not be reached; error_code says which. The same external_ref may be ordered again |
card.in_doubt |
The outcome is uncertain; when the issuer never answered, a few minutes after the order. See recovering an uncertain order |
load.succeeded / load.failed / load.in_doubt |
Chain accounts: a load reached that state; data.load is the load. An in_doubt load is reconciled by Zwipe and the final event follows |
transaction.created |
Chain accounts: the issuer reported a new money entry on the card; data.transaction is the entry |
data.card is the card as it was when the event was created. It never carries issuer.wallet_url or issuer.collect_url; read GET /v1/cards/{card_id} when you need them, so they stay out of your webhook logs.
Verify the signature
Section titled “Verify the signature”Every delivery carries Zwipe-Signature: t=<unix seconds>,v1=<hex>. Compute HMAC-SHA256 with your webhook secret over <t>.<raw request body> and compare it with v1 in constant time. Reject a t more than 5 minutes from your clock. Verify the raw bytes before any JSON parsing.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyZwipeSignature(rawBody, header, secret, now = Date.now()) { const parts = Object.fromEntries(header.split(',').map((p) => p.split('='))); const t = Number(parts.t); if (!Number.isFinite(t) || Math.abs(now / 1000 - t) > 300) return false; const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest(); const given = Buffer.from(parts.v1 ?? '', 'hex'); return given.length === expected.length && timingSafeEqual(given, expected);}Handle deliveries
Section titled “Handle deliveries”- Answer
2xxwithin 10 seconds, then process the event in a background job. Any other answer, or none, is retried with backoff for 3 days. - Delivery is at least once: dedupe on the event
id. - Order is not guaranteed. Read
GET /v1/cards/{card_id}, orGET /v1/loads/{load_id}for a load, for the current state instead of trusting the latest event you received.
Keep a polling worker
Section titled “Keep a polling worker”A webhook can be missed: your endpoint was down for longer than the retries, or the URL changed. A missing webhook never means a failed payment. Keep a background job in your application:
- Save the order and returned
card_id. - Schedule a status read while the record is
pending(GET /v1/loads/{load_id}for a chain load). - Persist the latest status; stop on
issued(succeededfor a load),failed, or, for a card fromPOST /v1/cards,in_doubt. A chain card or load inin_doubtis reconciled by Zwipe: keep reading it at a slow interval until it turns final. - Route uncertain
POST /v1/cardsrecords into your reconciliation process, including a balance read only when the issuer card ID is present. - Notify your customer through your own app after your backend confirms the outcome.
A card still pending well past a few minutes gets no event: replay the original request with the same external_ref, which requeues an unclaimed order without ordering twice.
Make the worker resumable after a restart. A missed polling job must not create another financial order. With webhooks on, the worker can run rarely, as a sweep for anything still pending.

