Payouts
Call createPayout, which answers 202 with status: "queued". The payout has arrived when payout.confirmed comes, or when getPayout shows status: "confirmed".
Balances
Payouts draw on one balance per asset, shared by the whole install. Read it with listBalances for a network.
| Field | Meaning |
|---|---|
confirmed | Confirmed money in, minus money out |
held | Held for payouts and sweeps in progress, network fees included |
available | confirmed minus held, less the treasury's reserve on native XRP and SOL, or "0" while spendable is false |
spendable | false while payouts cannot draw on it, such as before the first payment confirms, or while a reorg undoes a payout |
available counts payments not yet swept into the treasury. On native XRP it also leaves out the base reserve that each deposit address paid in XRP keeps, since no sweep can move it.
Send a payout
Send source: "treasury", an asset_id, a decimal-string amount, a destination, a fee_policy, and your own reference for the payout as external_id, which every payout needs. Every payout leaves from the treasury. A payout into one of your customers' addresses is not reported as a payment to them.
| Network | destination |
|---|---|
| Bitcoin, TRON, and native SOL on Solana | address |
| EVM | address, with its EIP-55 checksum |
| Solana tokens | The owner's address, with type: "wallet_owner" |
| XRPL | address, plus tag when the receiver needs one |
| Every network | memo must be null, and only XRPL takes a tag |
Danger
A payout cannot be cancelled. Check the address, and the XRPL tag, before you send.
A Bitcoin payout below its destination's dust limit, which no node relays, gets 422 with amount_below_dust_limit. Send at least 546 sat to a P2PKH address, 540 to P2SH, 294 to P2WPKH and 330 to P2TR.
An XRPL address has no account until a payment of at least the network's base reserve creates one, 1 XRP on mainnet when this was written. A smaller payout to it fails at once, unsigned and paying no fee, with the failure.code destination_account_below_reserve. A receiver that requires a tag fails a payout without one as destination_tag_required, and one that takes payments only from senders it authorized fails it as destination_refuses_the_sender. failure.message says what to change.
Retry a payout safely
A payout's external_id is kept for good and unique across the install, so a retry with the payout's external_id never queues a second payout. An Idempotency-Key is optional here, and the install keeps one for 24 h only.
| You send | You get |
|---|---|
The same external_id and body, at any age and with any key | The first response, with Idempotent-Replayed: true. Nothing new is queued. |
The same external_id with another asset, amount, destination or fee_policy | 409 with resource_conflict. Nothing is queued. |
getPayout and every payout.* event carry the external_id.
When money is short
available must cover the amount, and the native asset's available the network fee. Check listBalances before you send.
| Short of | What happens |
|---|---|
available, while spendable is true | The payout fails with insufficient_balance, and nothing is sent. |
Treasury funds, while available covers it | The payout waits in queued, spending no attempt, until the treasury can fund it. Its waiting_reason is treasury_underfunded. |
A reorg, a scanner that has stopped (stale, halted or failing) or is at least the network's confirmation count behind its node, or a database restore's recovery the operator has not accepted (spendable is false) | The payout waits in queued, with waiting_reason reorg_in_progress or network_unavailable. The rows above apply once it ends. |
Where networks differ:
- On native XRP and SOL, a payout that reaches into the treasury's reserve is not refused. It waits like one the treasury cannot fund.
- On EVM and Bitcoin, the fee is priced after the claim. A payout whose fee
availablecannot cover may first wait withtreasury_underfunded, then fail withinsufficient_balance. - On XRPL, an issued-currency payout whose treasury trust line refuses to send for more than its balance, such as one its issuer froze, does not wait. It fails at once, and its
failure.codenames the refusal. - On Tron and EVM, a token payout the token refuses, as under its issuer's blacklist or pause, does not wait either. It fails at once, unsigned and paying no fee, and its
failure.codenames the refusal. - On Bitcoin, a payout one of whose coins another transaction spent, so that none of its signed versions can pay it, waits for an operator, who fails it. Its
failure.codesays the coins were spent elsewhere, and the amount and fee are available again.
Warning
A waiting payout cannot be cancelled, so a second payout sent as a retry can pay twice. Retry with the same external_id.
Why a payout waits
While a payout is queued, getPayout names what holds it in waiting_reason, or shows null when nothing does. The 202 of createPayout always shows null. Each wait ends without you, and only retry_scheduled follows an attempt that counted.
waiting_reason | Why | It ends when |
|---|---|---|
treasury_underfunded | Your balance covers the payout, but the treasury cannot fund it yet. | The treasury can fund it. |
treasury_busy | On EVM the treasury sends one transaction at a time, and an earlier payout or a sweep's gas top-up is in flight. | That transaction confirms. |
treasury_nonce_drift | On EVM the treasury sent a transaction this gateway did not sign, or the network's node reports the treasury's transactions out of date. | That transaction is final, up to about 26 minutes on Ethereum, or the node reports them correctly again. |
network_unavailable | The gateway cannot use the network now: its scanner is behind its node or stopped, its node did not answer or will not take the payout yet, or the network fee is above the gateway's ceiling on EVM, Tron or Bitcoin, or above the fee it pays on XRPL. On XRPL, also while its node's validated ledger has not moved since the payout was signed. A stop, or a slow database, that cuts the payout's signing short leaves it here too, and so does a restored database until its operator accepts the recovery, and an operator's hold on every payout's send for a planned backup. | The network is usable again, the ledger moves, the operator accepts the recovery or releases the hold, or the next attempt starts. |
reorg_in_progress | A reorg is being resolved on the network, and spendable is false. | The reorg is resolved. |
set_aside | The payout failed the same way several times and waits for an operator. | The operator returns it to the line, or fails it with failed_by_operator. |
retry_scheduled | An attempt ended without paying. | The next attempt starts, shortly. When no attempt is left, the payout fails with attempts_exhausted. |
While the operator recovers the gateway's database after a restore, a queued payout waits as network_unavailable until the recovery ends. Do not send it again meanwhile.
Follow a payout
payout- queuedpayout.
queued - signingno event
- broadcastpayout.
broadcast payout.reorg_resolved - confirmingpayout.
confirming payout.reorg_resolved - confirmedfinalpayout.
confirmed payout.reorg_resolved - failedfinalpayout.
failed payout.reorg_resolved
Can return to queued from signing and broadcast.
After a reorg: reorged, sent as payout.reorg_detected.
Each status sends its event at most once per payout, except after a reorg as described below, so read getPayout for the current status. No event announces signing, and a retry returns the payout to queued with none.
| Event | Meaning |
|---|---|
payout.confirmed | The payout arrived. |
payout.failed | Final: the amount did not leave. Read failure.code, attempts_exhausted when every attempt was spent, then create a new payout to try again. |
An event's data holds part of what getPayout returns, with the same meanings: payout_id (its id), external_id, network_id, asset_id, amount, status, transaction_id (its chain_transaction_id), tx_hash, and failure without retryable. network and asset add the codes listNetworks and listAssets report; two assets of one network can share a code, so asset_id is the asset's identity.
After a reorg, getPayout shows reorged until the payout's reorg case ends: its transaction confirms again (on Bitcoin, or another version of it settles the payout), the send is proven absent, or an operator closes the case. When the transaction confirms again with the outcome it had, payout.reorg_resolved says so. Where it lands again with the other outcome, the payout takes it: a confirmed payout sends payout.failed, and a failed one sends payout.confirmed, even if it sent that event before. Payout events lists every payout.* event.
Handle an event
Store each event once by its id. Events can arrive twice, late and out of order, so apply a payout's events by occurred_at alone, never by arrival: skip an event unless its occurred_at is later than that of the last event you applied for the payout. Payout events carry no canonicality_generation. Compare occurred_at as a time, as Order events explains: applied this way, every delivery order, repeats included, ends at the payout's newest event, apart from the ties that section names.
The status of the last event you applied is the payout's status as that event left it. Some moves send no event, so getPayout can show another:
- A retry returns the payout to
queuedwith no event, and a status the payout reaches again sends none. - A reorg case that ends because the send is proven absent, or because an operator closed it, sends no event of its own. The payout shows its own status again, and a settled one keeps the status it settled with, except a confirmed Tron payout whose transaction the reorg removed and that can no longer land: the operator's step fails it. When the same step fails the payout,
payout.failedis sent as usual: withattempts_exhaustedwhen the send is proven absent with every attempt spent, and when an operator fails a payout whose nonce another transaction took, a Bitcoin payout whose coin another transaction spent (itsfailure.codesays so), or that confirmed Tron payout (failed_by_operator; nothing reached the destination).
So once getPayout shows confirmed or failed, the payout's newest event says the same, unless that event is payout.reorg_detected. While the last event you applied is payout.reorg_detected, read getPayout.