Mercury: Retrieve a cash flow report
Mercury books.getBooksCashFlow: arguments, response, policy and SDK examples.
← Books operations · Get started
Operation mercury.getbookscashflow
Provider route: GET /books/reports/cash-flow. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/mercury with npm, or alter-sdk-mercury with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { MercuryIntegration } from "@alter-ai/mercury";
async function execute(input: Parameters<MercuryIntegration["books"]["getBooksCashFlow"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new MercuryIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.books.getBooksCashFlow(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_mercury import MercuryIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = MercuryIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.books.get_books_cash_flow(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
query | object | Optional | Additional keys: not allowed |
query.booksId | string | Optional | The Books instance to act on. Must be the token organization’s own instance, which it defaults to. Format: uuid |
query.startDate | string | Optional | The report covers the period containing this day and every later period. Defaults to the Books entries start date, or the earliest date the span limit allows for the end date, whichever is later, but never after the end date. Format: date |
query.endDate | string | Optional | The report covers the period containing this day and every earlier period. Must be on or after startDate. Defaults to today (UTC), or the latest date the span limit allows for startDate, whichever is earlier, but never before startDate. Format: date |
query.period | string | Optional | The length of time each column covers. Daily reports can span at most 1 year; other periods at most 5 years. Defaults to a single column covering the whole range, which can also span at most 5 years. One of: daily, monthly, quarterly, yearly |
query.includeOnlyClosed | boolean | Optional | Whether to include only activity dated before the latest close. Defaults to false. |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Retrieve a cash flow report — response body |
Referenced models: Retrieve a cash flow report — response body
Schemas
Section titled “Schemas”Retrieve a cash flow report — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A cash flow report broken down into columns. |
columns | array | Required within parent | The report's columns, in chronological order. |
columns[] | Model | Each item | Expand Retrieve a balance sheet — response body — columns item |
endingBalances | array | Required within parent | The top-level cash ledgers' balances at the end of each column. |
endingBalances[] | Model | Each item | Expand Retrieve a cash flow report — response body — ending Balances item |
endingCashBalances | array | Required within parent | For each column, the total debit balance of all cash ledgers at the end of the column. |
endingCashBalances[] | Model | Each item | Expand Create a product — response body — unit Price value |
ledgers | array | Required within parent | The top-level ledgers that cash moved through. |
ledgers[] | Model | Each item | Expand Retrieve a cash flow report — response body — ledgers item |
startingBalances | array | Required within parent | The top-level cash ledgers' balances at the start of each column. |
startingBalances[] | Model | Each item | Expand Retrieve a cash flow report — response body — ending Balances item |
startingCashBalances | array | Required within parent | For each column, the total debit balance of all cash ledgers at the start of the column. |
startingCashBalances[] | Model | Each item | Expand Create a product — response body — unit Price value |
Referenced models: Create a product — response body — unit Price value, Retrieve a balance sheet — response body — columns item, Retrieve a cash flow report — response body — ending Balances item, Retrieve a cash flow report — response body — ledgers item
Create a product — response body — unit Price value
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (anyOf 1) | number | Alternative | A dollar amount Format: double |
$ (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
Retrieve a balance sheet — response body — columns item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A report column. The amount lists on each row are ordered to match the report's columns. |
endDate | JSON | Optional | |
endDate (anyOf 1) | JSON | Alternative | |
endDate (anyOf 1) (allOf 1) | string | All variants apply | Format: date |
endDate (anyOf 1) (allOf 2) | JSON | All variants apply | The last day (inclusive) of the column that falls between the Books entries start date and today. Omitted, along with @startDate@, when no day of the column falls in that window. |
endDate (anyOf 2) | null | Alternative | |
isPartial | boolean | Required within parent | Whether @startDate@ and @endDate@ cover fewer days than the column's label, because the label extends before the Books entries start date or after today. Always true when @startDate@ and @endDate@ are omitted. |
label | string | Required within parent | The column's name: @yyyy@ (yearly), @yyyy-Qn@ (quarterly), @yyyy-MM@ (monthly), @yyyy-MM-dd@ (daily), or @yyyy-MM-dd - yyyy-MM-dd@ when the report is not broken down by period. |
startDate | JSON | Optional | |
startDate (anyOf 1) | JSON | Alternative | |
startDate (anyOf 1) (allOf 1) | string | All variants apply | Format: date |
startDate (anyOf 1) (allOf 2) | JSON | All variants apply | The first day (inclusive) of the column that falls between the Books entries start date and today. Omitted, along with @endDate@, when no day of the column falls in that window. |
startDate (anyOf 2) | null | Alternative |
Retrieve a cash flow report — response body — ending Balances item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | The cash balance of a cash ledger at the start or end of each column of a cash flow report. |
balances | array | Required within parent | For each column, the ledger's own debit balance, excluding its children. |
balances[] | Model | Each item | Expand Create a product — response body — unit Price value |
children | array | Required within parent | The ledgers nested under this ledger. |
children[] | Model | Each item | Expand Retrieve a cash flow report — response body — ending Balances item |
ledgerId | string | Required within parent | The cash ledger this row represents. Format: base58 (max length 22) |
name | string | Required within parent | The ledger's display name. |
parentId | JSON | Optional | |
parentId (anyOf 1) | string | Alternative | The parent ledger, if this ledger is nested. Format: base58 (max length 22) |
parentId (anyOf 2) | null | Alternative | |
sortCode | string | Required within parent | The ledger/account number used for chart ordering. |
totalBalances | array | Required within parent | For each column, the debit balance of the ledger and all of its children. |
totalBalances[] | Model | Each item | Expand Create a product — response body — unit Price value |
Referenced models: Create a product — response body — unit Price value, Retrieve a cash flow report — response body — ending Balances item
Retrieve a cash flow report — response body — ledgers item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Net cash movement through a ledger in each column of a cash flow report. |
children | array | Required within parent | The ledgers nested under this ledger. |
children[] | Model | Each item | Expand Retrieve a cash flow report — response body — ledgers item |
ledgerId | string | Required within parent | The ledger this row represents. Format: base58 (max length 22) |
name | string | Required within parent | The ledger's display name. |
netCashFlows | array | Required within parent | For each column, the sum of the ledger's own cash line entries, excluding its children. |
netCashFlows[] | Model | Each item | Expand Create a product — response body — unit Price value |
parentId | JSON | Optional | |
parentId (anyOf 1) | string | Alternative | The parent ledger, if this ledger is nested. Format: base58 (max length 22) |
parentId (anyOf 2) | null | Alternative | |
totalNetCashFlows | array | Required within parent | For each column, the sum of the cash line entries in the ledger and all of its children. |
totalNetCashFlows[] | Model | Each item | Expand Create a product — response body — unit Price value |
Referenced models: Create a product — response body — unit Price value, Retrieve a cash flow report — response body — ledgers item
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: mercury.getbookscashflow. Catalog operation: mercury:getBooksCashFlow. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.