Refund a transaction (partial or full)
Books an inverse transaction for the requested amount,
scaling every leg of the original (including legs in other
currencies) by amount / gross_in(currency). Banker’s
rounding; residual on the largest leg per currency, so the
new transaction is balanced per currency.
currency is the base currency the caller is refunding. For
single-currency originals it may be omitted and is inferred.
For multi-currency originals it is required; omitting it
returns refund_currency_required (422).
Sum of prior refunds is tracked per currency: a 100% USDC
refund does not block a later 100% BTC refund on a USDC+BTC
original. Refunds that would exceed the original’s remaining
amount in the requested currency return
partial_refund_exceeds_original (422). Idempotent on
Idempotency-Key.
Authorizations
Same flow; ledger:write is required for any mutation.
Headers
Required on writes. Stable identifier you choose. The same key
always returns the same transaction, forever. Can also be supplied as
idempotency_key in the request body. Header wins.
Allowed character set: A-Z, a-z, 0-9, _, :, ., -.
Max 255 bytes. Replays of an accepted key return the original
response with header Idempotent-Replayed: true so callers can
tell a replay from a freshly-committed result.
1 - 255^[A-Za-z0-9_:.\-]+$"pi_acme_1234_capture"
Path Parameters
Query Parameters
Comma-separated. postings.account inlines each posting's
account object; balances adds the post-commit balance of every
touched account.
postings.account, balances Body
Refund amount in minor units. Accepts a positive decimal string (recommended) or an integer on write.
^\d+$"5000000"
The base currency to refund. Optional for
single-currency originals (inferred). Required
for multi-currency originals; omitting returns
refund_currency_required (422).
"USDC"
Optional body alternative to the Idempotency-Key header. Header wins.
Response
Idempotency replay (original refund returned)
Discriminator naming the shape of this resource (e.g. account, transaction).
transaction "account"
"3061ec4e-c959-49ba-a0f6-99186a7bd5d8"
"pi_acme_1234_capture"
Set when this transaction reverses another.
Set when this transaction has been reversed.
Set when this transaction refunds another (partial or full).
Minor units refunded, as a decimal string. Parse with a big-integer or decimal type, never a JS number. Present only on refund transactions.
^-?\d+$Decimal string. Present only when the transaction has postings in more than one currency. The rate that was in effect at write time. It is persisted for audit and restatement, never recomputed.
"1.0823"
Currency that the exchange rate quotes from. Set with exchange_rate.
"USD"
Currency that the exchange rate quotes to. Set with exchange_rate.
"USDC"
Returned only when ?expand=balances.