Webhook
The webhook notification system alerts you in real time to payment state changes. Interpreting them correctly is critical to avoid releasing products without confirmation or keeping a customer waiting.
Configuration
Section titled “Configuration”- Webhook URL: configured in the dashboard, on the device settings (
notification_url). - Scope: webhooks operate per device. Each device can have its own URL.
- HTTP method:
POST. - Body: JSON.
Headers
Section titled “Headers”POST /your/endpoint HTTP/1.1Content-Type: application/jsonX-NONCE: 1645634942X-SIGNATURE: 395a6c0294f0896fcc0e5827e926e12308f4fdca5c18da69d3af6879e5c80e2dX-NONCE: Unix timestamp in seconds at the moment B4bit Pay generated the signature.X-SIGNATURE:hex(HMAC_SHA256(bytes.fromhex(secret_key), nonce_ascii + body_utf8)).
Signature algorithm
Section titled “Signature algorithm”signature = hex(HMAC_SHA256(secret_hex → bytes, nonce + body))- The Secret Key of the device comes from the dashboard in hexadecimal format; decode it to bytes before use.
nonceis the ASCII timestamp string ("1645634942", not the integer).bodyis the raw request body, unparsed and unmodified (no extra trailing newline).- The concatenation is
nonce + bodywithout separators.
Time window
Section titled “Time window”Retry policy
Section titled “Retry policy”Idempotency
Section titled “Idempotency”Deduplicate by identifier + status + edited_at before applying side effects. Even though the backend does not retry, network retries at the TCP level or merchant deployments can cause duplicates in practice.
Official test vector
Section titled “Official test vector”See Webhook — test vectors for reproducible values you can use to verify your HMAC implementation before connecting to production.
Expected response
Section titled “Expected response”Return HTTP 2xx (200/201/202/204) fast — ideally in less than 5 seconds. Process the heavy logic asynchronously.