Skip to content

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.

FieldMeaning
confirmedConfirmed money in, minus money out
heldHeld for payouts and sweeps in progress, network fees included
availableconfirmed minus held, less the treasury's reserve on native XRP and SOL, or "0" while spendable is false
spendablefalse 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.

Networkdestination
Bitcoin, TRON, and native SOL on Solanaaddress
EVMaddress, with its EIP-55 checksum
Solana tokensThe owner's address, with type: "wallet_owner"
XRPLaddress, plus tag when the receiver needs one
Every networkmemo 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 sendYou get
The same external_id and body, at any age and with any keyThe first response, with Idempotent-Replayed: true. Nothing new is queued.
The same external_id with another asset, amount, destination or fee_policy409 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 ofWhat happens
available, while spendable is trueThe payout fails with insufficient_balance, and nothing is sent.
Treasury funds, while available covers itThe 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 available cannot cover may first wait with treasury_underfunded, then fail with insufficient_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.code names 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.code names 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.code says 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_reasonWhyIt ends when
treasury_underfundedYour balance covers the payout, but the treasury cannot fund it yet.The treasury can fund it.
treasury_busyOn 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_driftOn 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_unavailableThe 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_progressA reorg is being resolved on the network, and spendable is false.The reorg is resolved.
set_asideThe 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_scheduledAn 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 · payout
  1. queuedpayout.queued
  2. signingno event
  3. broadcastpayout.broadcastpayout.reorg_resolved
  4. confirmingpayout.confirmingpayout.reorg_resolved
  5. confirmedfinalpayout.confirmedpayout.reorg_resolved
  6. failedfinalpayout.failedpayout.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.

EventMeaning
payout.confirmedThe payout arrived.
payout.failedFinal: 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 queued with 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.failed is sent as usual: with attempts_exhausted when 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 (its failure.code says 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.