Webhook Spec
When async events complete (card opened, recharge succeeded, card closed, etc.), Brand actively POSTs to your configured URL. Clients must verify the signature + return 2xx within the timeout window.
Inbound HTTP Request
POST https://customer-server.example/your-webhook-path HTTP/1.1
Content-Type: application/json
Webhook-Id: 550e8400-e29b-41d4-a716-446655440000
Webhook-Timestamp: 1714377612
Webhook-Signature: v1,9b8e7f6d5c4b3a2918273645d4e3c2b1a0f9e8d7c6b5a4938271605f4e3d2c1b
Webhook-Type: card.opened
User-Agent: Brand-Webhook/1.0
<JSON body>Signature Verification
signInput = WebhookTimestamp + "." + raw_body_bytes
expected = "v1," + lowercase_hex( HMAC_SHA256(webhook_secret_bytes, signInput) )
verify_ok = constant_time_compare(Webhook-Signature, expected)Use the raw body bytes
Do NOT JSON.parse then re-stringify — whitespace / key-order may change and the signature will fail. Use your framework's raw body capability (bodyParser.raw in Express, io.ReadAll(r.Body) in Go, etc.).
webhook_secret is NOT the API secret
- API
SECRET— used for client → server signing. webhook_secret— used for server → client webhook signing.
The webhook_secret returned from set_webhook is independent.
Timestamp Replay Protection
abs(server_now_unix - WebhookTimestamp) <= 300 # ±5 minutesReject anything outside the window.
Receiver Requirements
| Item | Requirement |
|---|---|
| Response status | Must be 2xx; otherwise retry triggers |
| Response-header timeout | 5 seconds — server must receive the response status line + headers within 5 s of finishing the TLS handshake |
| Total request timeout | 10 seconds — full request including response body must complete within 10 s; slow body streaming counts as a failure |
| Idempotency | Same Webhook-Id may arrive multiple times (delivery retries) — dedupe by Webhook-Id |
Pratical guideline
Push heavy work to a background queue and respond 200 immediately. Aim for < 200 ms end-to-end on the webhook endpoint to leave headroom for network jitter.
Idempotency required
Even after you respond 200, packet loss may make Brand retry. Always dedupe by Webhook-Id to avoid double-processing.
Event Types
| event_type | Trigger | Payload | Card-types covered |
|---|---|---|---|
webhook.test | Console "test" / set_webhook async fire-and-test | {message, sent_at, acknowledge_to_complete_verification} | All |
card.opened | Virtual card opened | {card_id, card_type, status: "opened", opened_at, last_four?} | virtual_l / p / v / r / g / a / s921 |
card.open_failed | Open failed | {card_id, card_type, status: "open_failed", fail_reason, failed_at} | virtual_l / p / v / r / g / a / s921 |
card.recharged | Recharge succeeded | {transaction_id, card_id, status: 2, amount, currency, completed_at} | virtual_l / p / v / r / g / a / s921 |
card.recharge_failed | Recharge failed (funds returned to the wallet) | {transaction_id, card_id, status: 3, amount, currency, fail_reason, failed_at} | virtual_l / p / v / r / g / a / s921 |
card.closed | Card close completed | {card_id, card_type, status: "closed", closed_at, last_four?} | virtual_l / p / v / r / g / a / s921 |
card.status_changed | Any other status change: freeze / unfreeze, close requested, provider-pushed changes, close-refund rejected | {card_id, card_type, from_status, to_status, from_status_code, to_status_code, changed_at, last_four?} | virtual_l / p / v / r / g / a / s921 |
cardholder.status_changed | The review / identity verification status of a cardholder registered through OpenAPI changed (v1.6) | {cardholder_id, external_id, registration_status, full_name, kyc, kyc_levels, bindings, proof_of_address_status, updated_at} | — (cardholder event) |
Status convention
- Open / close
statusis a string:"opened"/"open_failed"/"closed" - Recharge
statusis a number:2= success /3= failure card_typeis lowercase:virtual_v, notVIRTUAL_V- Every
card.*event covers all OpenAPI virtual card types:virtual_l/virtual_p/virtual_v/virtual_r/virtual_g/virtual_a/virtual_s921 cardholder.status_changedis about a cardholder, not a card: it carriescardholder_id(chd_<id>) and nocard_id- v1.5:
card.recharged/card.recharge_failedare delivered for every virtual card type (before v1.5virtual_v/virtual_r/virtual_g/virtual_a/virtual_s921cards never received them), andcard.status_changedis delivered for the first time.
Full Payload Examples
webhook.test
{
"message": "This is a test event from Brand OpenAPI",
"sent_at": "2026-04-29T11:00:00Z",
"acknowledge_to_complete_verification": true
}card.opened
{
"card_id": "card_12345",
"card_type": "virtual_v",
"status": "opened",
"opened_at": "2026-04-29T11:00:12Z",
"last_four": "4242"
}card.open_failed
{
"card_id": "card_12345",
"card_type": "virtual_v",
"status": "open_failed",
"fail_reason": "kyc rejected",
"failed_at": "2026-04-29T11:00:12Z"
}card.recharged
{
"transaction_id": "txn_KCZ20260429120000123456",
"card_id": "card_12345",
"status": 2,
"amount": "100.00",
"currency": "USDT",
"completed_at": "2026-04-29T12:00:00Z"
}transaction_id / amount / currency are the same values the recharge endpoint returned: amount is the requested amount in the package's recharge asset (currency, e.g. USDT), not the amount credited to the card. Compare amount numerically — the number of decimal places in the string may differ from the recharge response. Delivered for every OpenAPI virtual card type once the provider settles the top-up; a top-up rejected synchronously by /card/recharge returns an error response and produces no webhook. card.recharge_failed means the frozen funds have been returned to your wallet.
card.recharge_failed
{
"transaction_id": "txn_KCZ20260429120000123456",
"card_id": "card_12345",
"status": 3,
"amount": "100.00",
"currency": "USDT",
"fail_reason": "provider declined",
"failed_at": "2026-04-29T12:00:01Z"
}card.closed
{
"card_id": "card_12345",
"card_type": "virtual_v",
"status": "closed",
"closed_at": "2026-04-29T13:00:00Z",
"last_four": "4242"
}Delivered once when the provider confirms the close and the card becomes closed (5) with balance 0 — including closes with a zero or negative balance and closes whose refund was auto-rejected for a currency mismatch (before v1.5 those were missing). Duplicate provider callbacks do not produce a second event. For virtual_s921 this happens after the provider's clearing period (about one day); until then the card stays closing (4). The balance refund is reviewed afterwards: an approved refund is credited to your wallet (no card event); a rejected refund restores the card to active and is notified with card.status_changed.
card.status_changed
Delivered after any card status change that is not an open result (card.opened / card.open_failed) or a close completion (card.closed). Implemented in v1.5 — earlier versions documented this event but never sent it.
{
"card_id": "card_12345",
"card_type": "virtual_v",
"from_status": "active",
"to_status": "frozen",
"from_status_code": 2,
"to_status_code": 6,
"changed_at": "2026-04-29T14:30:00Z",
"last_four": "4242"
}from_status/to_status: lowercase text —pending/active/failed/closing/closed/frozen.from_status_code/to_status_code: the same numbers asstatusin/card/info.last_fouris omitted while the card number is not yet available.- The event is sent after the change is committed;
changed_atis when it happened.
Fired for:
| Transition | Example |
|---|---|
| Freeze / unfreeze | Through /card/freeze / /card/unfreeze, the app, the platform admin, risk control or the system (incl. unfreeze-by-recharge) — active ↔ frozen |
| Close requested | Through /card/close, the app, the platform admin, risk control or the system — active / frozen → closing |
| Provider-pushed change | The card provider freezes, unfreezes or closes the card on its side. A provider-initiated closure arrives as to_status: "closed"; the refund for such a card is settled after manual reconciliation |
| Close refund rejected | The platform rejects the close-refund review — the card is restored to active |
| Stuck close recovered | The platform confirms with the provider that a close never took effect and restores the card to active |
Not fired for: open results (card.opened / card.open_failed) and close completion (card.closed).
VIRTUAL-S921: card.opened can precede the card number
For virtual_s921 the provider issues the card number shortly after opening (usually seconds, up to about 90 s). card.opened may arrive first without last_four, and /card/info shows status=2 with an empty masked_card_no until the number is available. Poll /card/info until masked_card_no is non-empty before topping up (a recharge before that returns 40000 card_number_not_ready).
cardholder.status_changed
Delivered when the review or identity verification status of one of your cardholders changes (v1.6). The payload is the cardholder's complete current status — not a diff — so you can simply overwrite what you stored.
{
"cardholder_id": "chd_1024",
"external_id": "cust-0001",
"registration_status": 1,
"full_name": "John Doe",
"kyc": {
"status": "APPROVED",
"retry_allowed": false,
"retry_remaining": 0,
"updated_at": "2026-10-26T18:05:00+08:00"
},
"kyc_levels": [],
"bindings": [
{
"card_type_codes": ["virtual_g", "physical_g"],
"status": 3,
"failure_reason": "",
"reviewed_at": "2026-10-26T18:30:00+08:00",
"requires_resubmission": false,
"terminal": false
}
],
"proof_of_address_status": { "provided": true, "issue_date": "2026-09-01", "issuing_country": "SG" },
"updated_at": "2026-10-26T10:30:05Z"
}| Field | Description |
|---|---|
cardholder_id | chd_<id> |
external_id | Your own ID from create (empty string when none) |
registration_status | 0 draft / 1 registered |
full_name | first_name + space + last_name |
kyc | Same as on the Cardholder object: status NOT_STARTED / IN_PROGRESS / APPROVED / REJECTED / CANCELLED, with retry_allowed / retry_remaining when rejected |
kyc_levels | Deprecated — kept for compatibility, always []. Use kyc |
bindings | Same as on the Cardholder object: status 1 submitting / 2 under review / 3 approved / 4 failed (failure_reason; terminal=true on a final rejection) |
proof_of_address_status | Same as on the Cardholder object; null when unknown |
updated_at | When the platform recorded the change (RFC3339) |
When it fires:
| Change | Example |
|---|---|
| Review result | A bindings[] entry becomes approved (3) or failed (4) |
| Review progress | A submission is picked up (1 → 2), or requires_resubmission changes after you updated reviewed information |
| Verification result | kyc.status becomes APPROVED or REJECTED, or the retry count changes |
| Verification progress | A verification is started (IN_PROGRESS) or canceled / voided (CANCELLED) |
| Proof of address | proof_of_address_status changes |
It fires for every change of kyc, bindings or proof_of_address_status, including changes caused by your own calls (create, update, submit, kyc/init, kyc/cancel) — for example right after a create, when the cardholder's initial status is first recorded. Changes to profile fields alone (e.g. a new email) do not trigger it. It is sent only when the content actually changes — a status refresh that finds nothing new sends nothing. Status updates that arrive out of order on the platform are discarded. Deliveries can still repeat or overlap with retries: dedupe by Webhook-Id and keep the event with the latest updated_at (ignore one older than what you stored). To act on results, compare the new bindings[].status / kyc.status with what you stored.
Only cardholders registered through OpenAPI produce this event.
Retry Backoff
| Failure # | Next attempt in |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 15 minutes |
| 4 | 1 hour |
| 5 | 6 hours |
| 6 | 24 hours |
| 7 | dead_letter — no more retries |
Total delivery attempts
Each event has 7 delivery attempts (1 initial + 6 retries). After the 7th failure the event moves to dead_letter and stops retrying.
Inspect dead-letter status via the Webhook events history endpoint.
fail_reason — Server-Side Desensitization
fail_reason on card.recharge_failed and card.open_failed payloads is a sanitized, short, human-readable description. The server strips:
- Provider URLs / IPv4 addresses / email addresses / domain names
- Go-style transport templates (e.g.
Post,dial tcp ...) - HTML and special characters
- Truncates to 120 characters
| Situation | What you'll see in fail_reason |
|---|---|
| The provider gave no reason, or nothing was left after sanitizing | "" (empty string) — render a generic message |
| The provider gave a reason | Cleaned short description like "Insufficient funds", "Card blocked" — never contains provider domain / IP / internal trace IDs / stack traces |
A top-up rejected synchronously by /card/recharge produces no webhook at all — the error is in the API response (error_key).
Need the raw provider error?
Call /api/v1/openapi/webhook_events/list and look at last_error for ops-level diagnostic info. The full provider response is retained server-side; contact support if you need it for an investigation.
URL Constraints (set_webhook)
Verification lifecycle
Each call to set_webhook rotates webhook_secret and clears the verified flag on the credential. The flag is re-set the moment the next outbound delivery (typically the auto-fired webhook.test) returns 2xx, signaling that the new endpoint is reachable. You can read the flag via get_webhook to detect "configured but never reached" misconfigurations.
The same rules are enforced when you save the URL and again before every delivery; a URL that violates any of them is rejected.
| Constraint | Rule |
|---|---|
| Protocol | HTTPS only |
| Port | 443 only (may be omitted) |
| Host | Must be a domain name with an alphabetic top-level domain. IP addresses in any form (dotted, decimal, octal, hex, shortened) and single-label hosts are rejected |
| Userinfo / fragment | user@host and #fragment are not allowed |
| Query | Query parameters must not contain URLs (including percent-encoded ones) |
| Blocked domains | localhost, cloud-metadata hosts, wildcard-DNS services (nip.io, sslip.io, …) and the platform's own domains and servers |
| DNS | Every resolved address must be a public IP; private, loopback, link-local and reserved ranges are rejected. Redirects are never followed |
| URL length | At most 512 characters |
| Change frequency | Changes are rate-limited per account; exceeding the limit returns HTTP 429 api_credential_webhook_update_rate_limited |
SSRF protection
Rejection of internal / cloud-metadata (169.254.169.254) / loopback is mandatory. If your receiver is internal, expose it via a reverse proxy with public HTTPS. Submitting obviously malicious targets (internal addresses, encoded IPs, the platform's own endpoints) or changing the URL too frequently triggers automatic security action on the account, including freezing it and disabling its API credential.
Verification Code Snippets
import hmac, hashlib
def verify_webhook(sig_header, ts_header, raw_body, webhook_secret):
if not sig_header.startswith("v1,"):
return False
sig = sig_header[3:]
expected = hmac.new(
webhook_secret.encode(),
f"{ts_header}.".encode() + raw_body,
hashlib.sha256,
).hexdigest()
return hmac.compare_digest(sig, expected)import crypto from 'node:crypto'
import express from 'express'
const app = express()
app.post('/webhook',
express.raw({ type: 'application/json' }), // raw body
(req, res) => {
const sigHeader = req.header('Webhook-Signature') || ''
const tsHeader = req.header('Webhook-Timestamp') || ''
if (!sigHeader.startsWith('v1,')) return res.sendStatus(401)
const sig = sigHeader.slice(3)
const expected = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(`${tsHeader}.`).update(req.body)
.digest('hex')
const ok =
Buffer.byteLength(sig) === Buffer.byteLength(expected) &&
crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected))
if (!ok) return res.sendStatus(401)
// process...
res.sendStatus(200)
})func verifyWebhook(sigHeader, tsHeader string, rawBody []byte, webhookSecret string) bool {
const prefix = "v1,"
if !strings.HasPrefix(sigHeader, prefix) {
return false
}
sig := sigHeader[len(prefix):]
mac := hmac.New(sha256.New, []byte(webhookSecret))
mac.Write([]byte(tsHeader))
mac.Write([]byte("."))
mac.Write(rawBody)
expected := hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(sig), []byte(expected))
}function verifyWebhook(string $sigHeader, string $tsHeader, string $rawBody, string $webhookSecret): bool {
if (strpos($sigHeader, 'v1,') !== 0) return false;
$sig = substr($sigHeader, 3);
$expected = hash_hmac('sha256', $tsHeader . '.' . $rawBody, $webhookSecret);
return hash_equals($sig, $expected);
}Common Pitfalls
| Pitfall | Fix |
|---|---|
| Signing over the parsed JSON object | Use raw body bytes |
Confusing webhook_secret with API SECRET | They are two independent secrets |
Comparing signatures with == | Use constant-time compare to prevent timing attacks |
| Not returning 2xx within 5 seconds | Push heavy work to a queue; respond 200 immediately. Total request must finish within 10 s (response-header timeout 5 s) |
No Webhook-Id dedup | Add an idempotency table; same Webhook-Id returns 200 without re-processing |