A statement export covers one account for a period. Choose a grouped account statement, an
individual-movement ledger, or a balances report. Polyester builds each in the background as one CSV file: StatementExportService is the statement API, over REST and ConnectRPC.
LedgerReadService.ExportStatement and REST GET /v1/statements no longer exist. Create a
statement export with type: ACCOUNT_STATEMENT for the same account, Asset, and period instead;
its file has the same columns.Access
API keys need the READ_STATEMENTS policy action, for every call, cancel and create included. The
statement covers one account:
- Omit
subaccountIdfor the Main Account. A Subaccount-scoped key always reads its own Subaccount. - A Main Account key reads the Main Account and the Subaccounts it owns.
- A session reads the Main Account and the Subaccounts its role gives access to.
See API key and Subaccount policies. Access is
checked again on every read and cancel of an export, on every download through the file endpoint,
and whenever a download URL is issued. An export of an account you cannot read, or can no longer
read, answers 404, as one that does not exist. A download URL already issued is not checked again:
it downloads the file until it stops working, at most 60 seconds after it was issued.
Export types
Choose the required type when creating an export:
ACCOUNT_STATEMENTgroups one ledger operation into rows by balance area and Asset, with the amount, fees paid, and balance after the entry. Its columns are unchanged.LEDGERlists each individual ledger movement, with its transfer reason, side, counterparty, and balance after the movement. A trade has separate rows for its base and quote legs and each fee.BALANCESsummarizes opening and closing balances, total credits and debits, and movement counts by balance area and Asset. It is available through the API only, not in the Polyester app.
All three types have the same period limit, Asset filter, exports-in-progress and movement limits,
retention, and export lifecycle. A balances export also requires its start time to be within the
available account history. Create, get, list, and cancel return the export's type. Exports created
before 0.93.12 are returned as ACCOUNT_STATEMENT.
type: ACCOUNT_STATEMENT to request the previous CSV layout. Omitting type, sending STATEMENT_EXPORT_TYPE_UNSPECIFIED (0), or sending an undefined value returns
HTTP 400 BAD_REQUEST (invalid_argument over ConnectRPC). The suggested download filename has also changed.CSV format
All three files are RFC 4180 CSV in UTF-8 with CRLF line endings. The first row is the header. For account statements and ledgers, a period without movements gives the header row alone, and rows are oldest first. Amounts are exact decimal strings with up to 18 fractional digits and no trailing zeros.
Account statement (ACCOUNT_STATEMENT)
Each row is the effect of one entry on one balance area in one Asset. An entry is one ledger operation, such as a trade with its fees, a deposit, a withdrawal step, or an internal transfer.
The columns, in order:
time· the entry time, RFC 3339 in UTC with microsecondsentry_id· thetransferIdof the entry's first leg on the account within the export's period, asListTransfersreturns it; an unsigned 128-bit integer as a decimal string, the same across Asset filters for that periodtype·tradefor a trade's settlement and its fees; otherwise the transfer reason, such asdeposit,withdraw,internal_transfer,funding_to_trading, orsystem_adjustmentaccount· the balance area,fundingortradingasset· the Asset symbolamount· the signed balance change in whole units, without the fees infee; fees the account receives are included herefee· the fees the account paid in this Asset for the entry,0when nonebalance· the balance area's balance in this Asset after the entrylink_id· an ID shared by related legs, the match ID for a trade; empty when unavailableflow_id· the lifecycle flow ID of a deposit, withdrawal, or internal transfer linked before the export was created; empty otherwise
For consecutive rows of the same balance area and Asset, each balance equals the previous one
plus amount minus fee.
An Asset filter selects an entry's rows after the entry is built from all its movements on the
account. For the same account and covered period, an Asset-filtered file has the same entry_id, time, type, and link_id as the corresponding rows in an all-Assets file. The flow_id also matches when the links are the same at both exports' creation times. Match rows using entry_id, account, and asset within that period.
A period boundary can fall between an entry's legs. Each export then contains its own part, under
the transferId of that part's first leg, so do not join rows across periods on entry_id alone.
Reconcile amounts and balances across split periods too. Asset-filtered files produced before
0.93.10 can have different IDs for the same entry; create new exports to reconcile them with
all-Assets files.
Ledger (LEDGER)
Each row is one transfer leg on the account, as ListTransfers returns it.
The columns, in order:
time· the transfer time, RFC 3339 in UTC with microsecondstransfer_id· the transfer identifier, an unsigned 128-bit integer as a decimal string; together withaccountandside, it identifies the rowaccount· the balance area,fundingortradingasset· the Asset symboltype· the transfer reason, such astrade_base,trade_quote,maker_fee,taker_fee,rebate,deposit,withdraw,internal_transfer, orfunding_to_tradingside·debitwhen the movement takes from the balance area,creditwhen it adds to itamount· the signed balance change in whole units of the Asset; negative for a debit, positive for a creditcounterparty· the kind of the other side,funding_account,trading_account,external_address,private_counterparty,fee_account, orsystem_account; empty when unknownbalance· the balance area's balance in the Asset after the movementlink_id· an ID shared by related legs, the match ID for a trade; empty when unavailableflow_id· the lifecycle flow ID linked before the export was created; empty otherwise
There is no entry_id or separate fee column. Fees are movements in their own rows. For
consecutive rows of the same balance area and Asset, each balance equals the previous one plus amount.
An Asset filter keeps only the selected Asset's legs, without grouping or changing their transfer_id. All export types still read movements of all Assets for the covered period; all
count toward the 4,000,000-movement limit. The movements count in a ledger export counts the
retained legs, one per data row.
Balances (BALANCES)
Each row summarizes one balance area in one Asset over the covered period. Balances are posted balances at the boundaries, before any movement at that instant. The columns, in order:
account· the balance area,fundingortradingasset· the Asset symbolopening_balance· the balance atstartTimecredits· the sum of the period's credit legs, as a positive amount, or0when nonedebits· the sum of the period's debit legs, as a positive amount, or0when noneclosing_balance· the balance atcompleteThrough, not necessarily the requestedendTimemovements· the number of posted ledger transfer legs in the covered period for this balance area and Asset, including fee legs; not the number of grouped entries
Every row satisfies closing_balance = opening_balance + credits - debits. The credit and debit
totals correspond to the LEDGER file's legs for the same balance area, Asset, and covered period.
At READY, the export's movements field is the sum of the CSV's movement counts, not its row count.
Rows are sorted by account, then asset. A balance area and Asset with zero balances at both
ends and no movements has no row. A nonzero balance with no movements still has a row, with
zero credits, debits, and movements. The file has only its header when there are no qualifying
rows. An Asset filter keeps only that Asset's rows; the movement read limit still counts all Assets.
How far a statement is complete
An export covers movements from startTime up to completeThrough, exclusive. completeThrough is
the earliest of endTime, the moment the export was created, and just after the newest movement
recorded in the ledger then (its timestamp plus 1 ns), but never before startTime. It is fixed at
creation, so it can be earlier than the creation time, and time the export spends queued or
processing does not extend it. Every movement recorded before the export was created and before completeThrough is in the file, so the file never changes once it is written. Read the period's
end from the returned completeThrough rather than computing it, and create another export later
for the rest of the period.
Flow links as of creation
For ACCOUNT_STATEMENT and LEDGER, files generated under 0.93.12 use createdAt as the flow-link
cutoff, not the period end or when the file becomes ready. The export waits for transfer history to cover completeThrough and for the flow-link watermark to reach its creation time. This watermark
confirms that all link versions written before that time are available. Each movement uses its
latest link written strictly before createdAt, even when file generation resumes after an
interruption.
If a flow was not linked by creation time, its flow_id is empty. A link written later is not
added to this export, even if the export is still processing. Once the link is available, ListTransfers and a new export whose creation is after the link was written can show it.
For ACCOUNT_STATEMENT and LEDGER, if completeThrough equals startTime, the file has only its
header and needs neither watermark.
Balance history coverage
BALANCES uses the transfer history and verified balance history, not the flow-link watermark. It waits for those histories to agree before producing the file, even when there are no movements in the covered period.
Account balance history starts at a point in time. On test networks it starts again at each reset,
so periods starting before that history are refused. Exportable periods build up as history grows.
If the history is not yet verified, a create can be accepted and wait for it. Once the earliest
available instant is known, a new BALANCES request starting before it is refused with HTTP 409 STATEMENT_HISTORY_UNAVAILABLE. The problem's historyAvailableFrom member gives that instant
as an RFC 3339 timestamp in UTC. ConnectRPC returns FAILED_PRECONDITION with ERROR_CODE_STATEMENT_HISTORY_UNAVAILABLE and ErrorDetail.history_available_from.
Create again with startTime at or after that instant, keeping endTime later than the new start.
If the available history subsequently starts later than an accepted export's start, the export
can end FAILED with HISTORY_UNAVAILABLE instead.
Lifecycle
Create
Create an export for one account, a type, an optional Asset, and a period. It starts QUEUED.
Follow
Polyester writes the file in the background (PROCESSING). movements and bytes report its
progress. Poll the export until it is final: READY, FAILED, or CANCELED. Cancel it while it is QUEUED or PROCESSING if you no longer need it.
Download
Download a READY file until expiresAt, 7 days after it became ready. The export is then EXPIRED and its file is deleted; the export itself stays readable.
Endpoints
- Create · REST
POST /v1/statements/exports, ConnectRPCCreateStatementExport - Get one · REST
GET /v1/statements/exports/{exportId}, ConnectRPCGetStatementExport - List · REST
GET /v1/statements/exports, ConnectRPCListStatementExports - Cancel · REST
POST /v1/statements/exports/{exportId}/cancel, ConnectRPCCancelStatementExport - Download URL · REST
GET /v1/statements/exports/{exportId}/download-url, ConnectRPCGetStatementExportDownloadUrl - Download the file · REST
GET /v1/statements/exports/{exportId}/fileonly
Every endpoint needs a session or a signed API-key request. Only a download URL works without credentials, for 60 seconds.
Create an export
{
"idempotencyKey": "statement-2026-10",
"type": "ACCOUNT_STATEMENT",
"startTime": "2026-10-01T00:00:00Z",
"endTime": "2026-11-01T00:00:00Z",
"assetId": 1
} idempotencyKey· required, 1 to 64 letters, digits,.,_,:, or-, unique per Main Account. The same request with the same key returns the same export. The same key with other fields, including a different export type, is refused withIDEMPOTENCY_KEY_REUSED.type· required,ACCOUNT_STATEMENT,LEDGER, orBALANCES. There is no default.startTime· required, inclusive, no later than the request.endTime· required, exclusive, afterstartTimeand at most 366 days later. It may be in the future: the period then ends no later than the request; seecompleteThroughabove.assetId· optional. Omit it for every Asset; an ID that names no Asset is refused.subaccountId· optional. Omit it for the Main Account.
The response is the export, with its exportId and status QUEUED. exportId and subaccountId are public IDs, base58 strings in REST JSON.
For a balances report, send BALANCES and use dates within the available account history:
{
"idempotencyKey": "balances-2026-11",
"type": "BALANCES",
"startTime": "2026-11-01T00:00:00Z",
"endTime": "2026-12-01T00:00:00Z"
} Follow an export
Get returns one export. List returns an account's exports newest first; it takes subaccountId, limit (up to 100, default 20), and pageToken from the previous nextPageToken. Each export
reports type, status, movements and bytes, completeThrough, readyAt, expiresAt, and failureReason. REST spells the enum values without their prefix. ConnectRPC reports STATEMENT_EXPORT_STATUS_FAILED with STATEMENT_EXPORT_FAILURE_REASON_TOO_LARGE for an export
that exceeds the movement limit. This is a background failure recorded on the export; read its
status to learn the outcome.
QUEUED· waiting for transfer history to cover the period, for flow-link coverage (ACCOUNT_STATEMENT and LEDGER) or verified balance history (BALANCES), or for another export of the same account: one export per account is written at a time. Poll later.PROCESSING· the file is being written or waits for the required history coverage before resuming. BALANCES also waits if the balance and transfer histories disagree. Poll later.READY· download it beforeexpiresAt.FAILEDwithTOO_LARGE· the account's covered period holds more than 4,000,000 ledger movements across all Assets, even whenassetIdselects only one. Split the period into shorter exports, each with a newidempotencyKey, until each is within the limit. Retrying the same period or selecting fewer Assets does not avoid the limit.FAILEDwithUNAVAILABLE· the file could not be written. A processing export that resumes more than 24 hours after creation and whose history or flow-link watermark is behind or unreadable also ends in this state and frees its processing slot. Before that deadline, an unreadable watermark is retried. ConnectRPC reportsSTATEMENT_EXPORT_STATUS_FAILEDwithSTATEMENT_EXPORT_FAILURE_REASON_UNAVAILABLE. A BALANCES export also fails with this reason if the balance and transfer histories still disagree past the deadline. Create a new export with a new key.FAILEDwithHISTORY_UNAVAILABLE· a BALANCES export starts before the available balance history, for example if its origin moved after creation. The export carrieshistoryAvailableFrom(ConnectRPCStatementExport.history_available_from) and the ConnectRPC failure reason isSTATEMENT_EXPORT_FAILURE_REASON_HISTORY_UNAVAILABLE. Create a new export with a new key and a start at or after that instant.EXPIRED· the file was deleted. Create a new export.CANCELED· the export was canceled and has no file.
Exports in progress
List also returns inProgressExports and maxInProgressExports. inProgressExports counts the
exports QUEUED or PROCESSING across the whole Main Account, its Subaccounts included, whichever
account the list selects. It is the number a new create counts against maxInProgressExports;
while the two are equal, a create answers STATEMENT_EXPORT_LIMIT_REACHED. Read the count from List
instead of counting statuses yourself: another client, or the Polyester app, may have exports in
progress on the same Main Account.
Cancel an export
Cancel ends a QUEUED or PROCESSING export CANCELED at once and returns it. The export no longer
counts toward the exports in progress, the account's next queued export can start, and any partial
file is deleted.
- Repeat a cancel · canceling a
CANCELEDexport returns it as it is, so a cancel that timed out can be sent again. - Too late · a
READY,FAILED, orEXPIREDexport can no longer be canceled. Cancel answersSTATEMENT_EXPORT_NOT_CANCELABLE(REST409, ConnectRPCfailed_precondition). Read the export for its final state.
Download the file
There are two ways to download a READY file:
- Download URL · Get the download URL for the export. The answer carries
url,expiresAt, and the suggestedfilename. The URL needs no credentials, so a browser can open it to save the file. It works untilexpiresAt: 60 seconds after it was signed for your request, or when the file expires if that is sooner. Request a new URL after that. Anyone who holds the URL can download the file until it ends, so do not share, store, or log it. - Authenticated file ·
GET /v1/statements/exports/{exportId}/filewith your session or a signed API-key request returnstext/csvwithContent-Disposition, anETag, andAccept-Ranges: bytes. To resume a download, send oneRange: bytes=START-END; the answer is206withContent-Range, and a range outside the file answers416. AddIf-Rangewith theETagyou saw, so a changed file comes back whole. The file route has noredirectparameter; use the download URL instead.
Both download methods save the file as account-statement-<exportId>.csv, ledger-<exportId>.csv, or balances-<exportId>.csv, according to the export's type, rather than
the previous statement-<exportId>.csv name. Update any clients that depend on that name.
Either way, the file is not downloadable in every state:
- Before
READY·409withSTATEMENT_EXPORT_NOT_READY. FAILED·409withSTATEMENT_EXPORT_FAILED(ConnectRPCfailed_preconditionwithERROR_CODE_STATEMENT_EXPORT_FAILED). Read the export'sfailureReason; forTOO_LARGE, split the period as above. ForHISTORY_UNAVAILABLE, start at or afterhistoryAvailableFrom.CANCELED·409withSTATEMENT_EXPORT_CANCELED.- After
expiresAt·410withSTATEMENT_EXPORT_EXPIRED. A download URL is also refused this way when the file has less than 5 seconds left.
Limits
- Period · up to 366 days
- Exports in progress · at most 5
QUEUEDorPROCESSINGper Main Account, Subaccounts included. Another create answersSTATEMENT_EXPORT_LIMIT_REACHED(REST429, ConnectRPCresource_exhausted). Cancel an export you no longer need to free its place. - Movements read · up to 4,000,000 ledger movements of the account across all Assets in the
covered period, including Assets an
assetIdfilter leaves out of the file - Retention · 7 days after the file is ready
- Download URL · valid for 60 seconds
Errors
Statement export REST errors are application/problem+json with an uppercase code, such as IDEMPOTENCY_KEY_REUSED. ConnectRPC carries the same code in ledger.read.v1.ErrorDetail, such as ERROR_CODE_IDEMPOTENCY_KEY_REUSED.
400·BAD_REQUEST: a field is invalid, including a missing, unspecified, or undefined export type; the detail names it.403· the API key lacksREAD_STATEMENTS, or the role does not allow it.404· no such export or Subaccount for you.409·IDEMPOTENCY_KEY_REUSED,STATEMENT_EXPORT_NOT_READY,STATEMENT_EXPORT_FAILED,STATEMENT_EXPORT_CANCELED,STATEMENT_EXPORT_NOT_CANCELABLE, orSTATEMENT_HISTORY_UNAVAILABLE. For the latter, read the problem'shistoryAvailableFromto choose a new start time.410·STATEMENT_EXPORT_EXPIRED.413·REQUEST_TOO_LARGE: the request body is too large.416·RANGE_NOT_SATISFIABLE: theRangeof a file download is outside the file.429·STATEMENT_EXPORT_LIMIT_REACHED.500·SERVER_ERROR: the request failed unexpectedly.503· a dependency is briefly unavailable, such asUPSTREAM_ERROR: retry the same request.
idempotencyKey and fields: it returns the existing export instead of a second one.Field schemas are in the API reference, and every code under Balances, transfer history, and statements in the error codes.