> ## Documentation Index
> Fetch the complete documentation index at: https://www.bitnob.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bitnob has two APIs. The Business API (payouts, cards, trading, virtual accounts, stablecoin and bitcoin transfers) is at https://api.bitnob.com. The Enterprise API (non-custodial wallets) is at https://api.platform.bitnob.com.
> Business API auth: sign every request with HMAC-SHA256 and send four headers: `X-Auth-Client` (your client ID), `X-Auth-Timestamp` (Unix seconds), `X-Auth-Nonce` (16 random bytes, hex), and `X-Auth-Signature`, the hex HMAC-SHA256 of `CLIENT_ID:TIMESTAMP:NONCE:BODY` keyed with your client secret. BODY is the exact request body string you send, or an empty string. A missing header, a bad signature, or a timestamp more than about 5 minutes off returns `401`.
> Enterprise API auth: send your key in the `X-API-Key` header. Write requests such as creating a transaction also need an `Idempotency-Key` header, or they fail with `idempotency_key_required` before anything happens.
> Sandbox and production share the Business API base URL. The credentials you sign with select the environment, and `GET /api/whoami` returns it in `data.environment`. Use sandbox credentials in sample code and tests, and never put live credentials in code.
> Amounts are strings unless stated otherwise. Never parse them into floats. Balances, transactions, withdrawals (`POST /api/withdrawals`) and virtual accounts use integer strings in the smallest unit: satoshis for BTC, 6 decimals for USDT and USDC, kobo for NGN, and cents for KES and UGX (100 is 1 KES or 1 UGX). A mobile money collection takes `amount` as a JSON integer in cents.
> Payouts and trading use decimal strings in major units: a payout quote `amount` of `"1"` is 1 USDT, and a trading `quantity` of `"0.0001"` is 0.0001 BTC. Payout responses also carry `cent_amount`, the settlement amount in minor units.
> Card amounts are micro-units (1 USD = 1,000,000). Send them as JSON integers. Card responses return them as integer strings, and card webhooks as integers.
> Generate a unique `reference` for each money movement before the first attempt, and reuse it on retries. A reused reference returns `409` on payout quotes (`ALREADY_EXISTS`), withdrawals (`DUPLICATE_KEY_ERROR`) and card creation (`ALREADY_EXISTS`). It returns the existing record on NGN-pair trading orders, NGN virtual accounts and active mobile money collections. On a mobile money collection that has closed or failed it returns `409` `DUPLICATE_REFERENCE`. It isn't checked on crypto-pair trading orders, so look the order up with `GET /api/trading/orders/{reference}` before resending.
> Quotes expire at `expires_at`; read it from the response instead of assuming a window. An expired trading quote returns `422` `PRECONDITION_FAILED`, and an expired payout quote returns `400` `VALIDATION_ERROR`. Create a new quote rather than retrying. A payout quote can be initialized once, and a trading quote is consumed by the order that fills it.
> Webhooks: verify the `x-bitnob-signature` header, the hex HMAC-SHA512 of the raw request body keyed with your webhook secret, before parsing JSON. Compare in constant time and de-duplicate on `event_id`. A successful API response means accepted: confirm the outcome from the webhook, such as `payouts.withdrawal.success`.
> Errors return `status`, `code` and `detail`. Branch on `code`, never on `detail`. Since the November 5, 2026 response format change, each company gets either the current or the new error codes until its cutoff date, so handle both: `PROVIDER_ERROR` or `PROCESSING_ERROR`, and `BVN_PROVIDER_UNAVAILABLE` or `BVN_VERIFICATION_UNAVAILABLE`. A body that fails to parse returns `{"error": {"code": "BAD_REQUEST"}}`.

# Handle payout failures

> Every way a payout can fail and what to do about it, from expired quotes and underpayment to delivery rejection and compliance blocks.

A payout crosses a blockchain, an FX conversion, a compliance check, and a local banking rail. Each can fail independently, and each failure surfaces differently: some as API errors, some as webhook events, and some only in the record's status. This page covers every case.

Two rules underpin all of them:

* Track by the payout `id` and your `reference`; the [Trip timeline](https://www.bitnob.dev/docs/payouts/understanding-trip-timeline.md) tells you exactly which stage a payout stalled at.
* A failed payout sends `payouts.withdrawal.failed` with a `failure_reason`. Webhooks can be missed, so back them up with a reconciliation sweep against [Get payout](https://www.bitnob.dev/api-reference/payouts/get-payout.md).

## Failure scenarios

> [accordion] Expired quote
>
> The quote passed `expires_at` before you initialized, or before funding arrived.
>
> **Detection:** using an expired `quote_id` returns `400 VALIDATION_ERROR`. The reason is `expired` until a background job marks the quote expired, which runs every 5 minutes. After that, initialize returns the reason `already_initialized` and finalize returns a status transition error. An initialized but unfunded payout emits `payouts.withdrawal.expired`.
>
> **Response:** request a fresh quote and start over. Nothing was settled. In your UI, check `expires_at` before showing payment instructions, and stop showing them once it passes.

> [accordion] Underpayment
>
> The funding payment arrived short of the quoted amount.
>
> **Behavior:** the deposit is refused, except for a shortfall of up to 0.0001 on stablecoins. Bitcoin has no tolerance. The payout doesn't process, and it stays `PENDING_ADDRESS_DEPOSIT` until it expires.
>
> **Response:** show `deposit_amount` from the initialize response on your payment screen, and tell the sender their wallet network fee is on top of it. A short deposit stays in your Bitnob balance. Request a fresh quote to retry.

> [accordion] Overpayment
>
> The funding payment exceeded the quoted amount.
>
> **Behavior:** the intended fiat amount is paid out; the excess is credited to your Bitnob balance.
>
> **Response:** nothing required for delivery. Track the excess in your reconciliation so your books match your balance.

> [accordion] Payment after expiry
>
> Funds arrived on-chain after the quote window closed.
>
> **Behavior:** the payout doesn't proceed. The funds stay in your Bitnob balance, so request a fresh quote to retry.
>
> **Response:** design your payment screen so paying late is hard: show a countdown from `expires_at` and hide the address once it passes.

> [accordion] Funding stuck on the blockchain
>
> The deposit was sent with too low a fee and confirms slowly.
>
> **Detection:** the payout is still `PENDING_ADDRESS_DEPOSIT` and the Trip has no `asset_received`.
>
> **Behavior:** the payout waits for the deposit until the quote expires, 6 minutes after the quote for BTC and 16 minutes for stablecoins. A deposit that confirms after that doesn't proceed automatically. See "Payment after expiry".
>
> **Response:** show an "awaiting confirmations" state with a countdown from `expires_at`. For Bitcoin funding, recommend a competitive fee; for Lightning, this case does not exist, which is a reason to prefer it.

> [accordion] Delivery failure
>
> Funding succeeded, but the bank or mobile money operator rejected the payout: an invalid account, a closed account, or rail downtime.
>
> **Detection:** the record moves to `FAILED` and `payouts.withdrawal.failed` fires. Back this up with your reconciliation sweep against [Get payout](https://www.bitnob.dev/api-reference/payouts/get-payout.md) or [List payouts](https://www.bitnob.dev/api-reference/payouts/list-payouts.md).
>
> **Response:** read `failure_reason` from the webhook, correct the beneficiary if that was the cause, re-run [Account lookup](https://www.bitnob.dev/api-reference/payouts/account-lookup.md), and retry with a fresh quote. [Validate a beneficiary](https://www.bitnob.dev/docs/payouts/validate-a-beneficiary.md) before initializing prevents most of this class outright.

> [accordion] Compliance rejection
>
> The payout was blocked after funding by a compliance or risk check: a flagged recipient or a country restriction.
>
> **Detection:** same as delivery failure, the record moves to `FAILED`.
>
> **Response:** this is not retryable by changing details. Route it to your operations team, and engage your Bitnob account manager to resolve or refund.

> [accordion] Your webhook endpoint is down
>
> Not a payout failure, but it looks like one from inside your system: payouts complete and your records never hear about it.
>
> **Behavior:** Bitnob retries timeouts, `5xx` responses, and most `4xx` responses with increasing delays, up to the retry count set on your webhook (1 to 5 attempts in total). `400`, `404`, `410`, `422`, and `451` are final. See [Retries and duplicates](https://www.bitnob.dev/api-reference/webhooks.md#retries-and-duplicates).
>
> **Response:** idempotent handlers, fast `200`s, and the reconciliation sweep as the backstop. See [Receive payout webhooks](https://www.bitnob.dev/docs/payouts/webhook-payout.md).

## The reconciliation sweep

The single mechanism that catches everything above: on a schedule, list recent payouts and compare terminal states against your records.

**1. Sweep**

Query [List payouts](https://www.bitnob.dev/api-reference/payouts/list-payouts.md) and match the results to your open payouts by `id`.

**2. Settle**

Mark `SUCCESS` records delivered, exactly as if the success webhook had arrived.

**3. Route failures**

Send `FAILED` records to your retry or operations path.

**4. Alert on stalls**

Flag payouts that have sat in one stage beyond your corridor's expected window; per-corridor expectations are in [Corridor behavior](https://www.bitnob.dev/docs/payouts/corridor-specific-behavior.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.