Settlement ledger API¶
RevenueDesk reads the platform’s settlement ledger (bazaar#211 / ADR-0034). The ledger is an append-only, balanced journal: every money fact is one journal header (the source event) plus lines across the parties it touches (seller, platform, partner, payment provider, FX counterparty), and each journal balances to zero per currency. Nothing here computes money — it reads what the journal recorded.
Money rules (read these first)¶
minorUnitsis a signed integer in the smallest unit ofcurrency(scan), which is stored on every row together with itscurrency(ISO-4217) andscale(JPY=0, USD/EUR=2). ¥1,200 is{"minorUnits": 1200, "currency": "JPY", "scale": 0}.Amounts are never divided, rounded, or summed across currencies by this API.
sumsgroups by currency and scale; a client that wants one number must pick a currency.quantityDeltais signed:+Nsold,-Nreturned. A reversal is a new journal, never an edit.
Endpoints¶
All four are tenant-external under the edge capability software-settlement
(/software-settlement/v1/... at api.flexgalaxy.ai), serve the caller’s own
account only, and authorize before any query or count — a denied caller
cannot probe a population through totals.
GET /software-settlement/v1/ledger — action bazaar:Settlement:Read¶
Query parameters (all optional):
Parameter |
Meaning |
|---|---|
|
ISO-4217 alpha-3, upper-cased for you; anything else is a 400. |
|
One of the journal vocabulary ( |
|
ISO-8601 instants. |
|
Only the lines of that statement. Sums to its |
|
Opaque position from the previous page’s |
|
Page size, capped at 200. |
Response is the cursor envelope {items, next_cursor, total}: walk until
next_cursor is null (that is exactly the last page). total is an exact
count of the filtered set, not an estimate. Each item carries journalId,
lineNo, occurredAt, entryKind, partyRole, listingId, quantityDelta,
minorUnits, currency, scale, sourceSystem, sourceEventId. The page
carries no aggregate; sums are their own read.
GET /software-settlement/v1/ledger/summary — action bazaar:Settlement:Read¶
The same filters (currency, entry_kind, occurred_from, occurred_to,
cutoff), no paging. Response: {"sums": [{currency, byEntryKind, scale, netMinorUnits, lineCount}]}, one entry per currency, computed over the whole
filtered set — a separate read so a client walking the ledger never re-reads a
whole-population aggregate per page.
GET /software-settlement/v1/ledger/export — action bazaar:Settlement:Export¶
Same filters, text/csv response. The row cap is 10,000; the response carries
X-Export-Row-Count and X-Export-Truncated: true|false so a short file is
never mistaken for a complete one. Export is a distinct grant: holding
Settlement:Read does not imply it.
GET /software-settlement/v1/payout-settings?currency=USD — action bazaar:PayoutSettings:Read¶
currency is optional: omit it for the account’s one settings row, or name the
account’s payout currency. Asking for a currency the account does not settle in
is a 404, never a silent substitute. The response is
{currency, settings: {...}} — the mask below applies inside settings.
The response is masked, so the read is authorized by its own read action,
bazaar:PayoutSettings:Read (bazaar#273). SettlementReadAccess
grants it on frn:<account>:bazaar:payout-settings/*, alongside the settlement
ledger grants. bazaar:PayoutSettings:Manage is reserved for the payout
destination write path and is not implied by — and does not imply — the
read grant.
Settings are one row per account in that account’s payout currency. The
settings object carries currency, provider, cadence (DAILY | WEEKLY |
MONTHLY | MANUAL), reserveBps, minimum (minorUnits + currency),
verificationRequired, payeeBankName, payeeLast4Masked (always
****1234-form), payeeHolderInitial, updatedAt.
No raw financial identifier is ever stored, and the provider reference is
never returned. What the payout integration needs from bazaar is the
provider’s own opaque token plus the amount/currency/idempotency key of a
transfer — nothing else; the bank account lives at the provider. The table’s
shape CHECKs refuse a token that looks like an IBAN, a card number, or a bare
account/routing digit run, and the response rendering of the mask happens in
the service, not in the client. A currency that differs from the account’s
configured payout currency is a 404, never a silent substitute; no settings row
is a 404; a malformed currency is a 400.
Errors¶
validation_failed (400, with fields), forbidden (403, with
required_action naming the action the caller would need),
payout_settings_not_found (404), authorization_unavailable (503) — the PDP
being unreachable fails closed and never reads as “no restrictions”. The
required_action key is additive to the existing {error, fields} body.
Where the data comes from¶
No sales are posted yet. Today the only entries written to the ledger are
reviewed adjustments. Sales, refunds and payouts are not posted, so a figure read
here is not a statement of earnings. Check salesPosted before presenting one.
This API reads the journal that ADR-0034 defines, and the invariants (per-journal balance, append-only, replay refusal) are enforced in the database, not in this service. There is no mutable balance column anywhere to disagree with the lines.
Changing the payee¶
PUT /software-settlement/v1/payout-settings/payee replaces the payee on your
existing payout settings. It needs bazaar:PayoutSettings:Manage, an
Idempotency-Key and the current revision as expectedRevision.
Send
payeeRef(the payout provider’s opaque token) and optionallypayeeBankName,payeeLast4andpayeeHolderInitial. A raw IBAN, card number or account number is refused, and so is any other member.The new payee is recorded with
payeeVerificationState: PENDING. No provider is contacted, so it stays pending.Provider, cadence, reserve, minimum and currency are your payout contract and can’t be changed here. An account with no payout settings gets
payout_settings_not_found.A stale
expectedRevisiongetsstale_revision(409).It needs a recent sign-in: your token’s
auth_timemust be no more than 900 seconds old. Otherwise you get401with codestep_up_required, areason(stale_auth_time, ormissing_auth_timewhen the credential carries no sign-in time) and aWWW-Authenticate: Bearer error="insufficient_user_authentication", max_age="900"challenge. Sign in again and retry. A caller without the permission gets403first.
Balances¶
GET /software-settlement/v1/balances returns one row per currency and scale:
netMinorUnits, lineCount and byEntryKind, summed from the recorded lines
only, with an optional currency and cutoff. There is no total across
currencies.
Pending, available and paid are not computed. Each is a row of unavailable
naming why: NO_SETTLEMENT_TIMING_RECORDED means nothing recorded says when an
entry becomes payable, and NO_TRANSFER_OUTCOME_RECORDED means no transfer
outcome exists to report.
Statements¶
GET /software-settlement/v1/statements and
GET /software-settlement/v1/statements/{statementId} return one statement per
month and currency, derived from the ledger on each read.
A line belongs to the statement of the JST calendar month it was posted in. A correction posted later appears on a later statement, so a
CLOSEDstatement does not change.The id is
<YYYY-MM>-<currency>-<scale>, for example2026-10-JPY-0.openingMinorUnits + netMinorUnits = closingMinorUnits, within one currency.cutoffon the list keeps statements whose period ended at or before it.Pass the id as
statement_idtoGET /software-settlement/v1/ledger, its/summaryor its/exportto reproduce a statement line by line.The month groups posted lines. It is not a payout schedule.