Skip to content

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.

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 os
from alter_sdk import App
from 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()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
queryobjectOptionalAdditional keys: not allowed
query.booksIdstringOptionalThe Books instance to act on. Must be the token organization’s own instance, which it defaults to.
Format: uuid
query.startDatestringOptionalThe 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.endDatestringOptionalThe 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.periodstringOptionalThe 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.includeOnlyClosedbooleanOptionalWhether to include only activity dated before the latest close. Defaults to false.

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Retrieve a cash flow report — response body

Referenced models: Retrieve a cash flow report — response body

Retrieve a cash flow report — response body
FieldTypePresenceDescription and constraints
$objectRootA cash flow report broken down into columns.
columnsarrayRequired within parentThe report's columns, in chronological order.
columns[]ModelEach itemExpand Retrieve a balance sheet — response body — columns item
endingBalancesarrayRequired within parentThe top-level cash ledgers' balances at the end of each column.
endingBalances[]ModelEach itemExpand Retrieve a cash flow report — response body — ending Balances item
endingCashBalancesarrayRequired within parentFor each column, the total debit balance of all cash ledgers at the end of the column.
endingCashBalances[]ModelEach itemExpand Create a product — response body — unit Price value
ledgersarrayRequired within parentThe top-level ledgers that cash moved through.
ledgers[]ModelEach itemExpand Retrieve a cash flow report — response body — ledgers item
startingBalancesarrayRequired within parentThe top-level cash ledgers' balances at the start of each column.
startingBalances[]ModelEach itemExpand Retrieve a cash flow report — response body — ending Balances item
startingCashBalancesarrayRequired within parentFor each column, the total debit balance of all cash ledgers at the start of the column.
startingCashBalances[]ModelEach itemExpand 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
FieldTypePresenceDescription and constraints
$JSONRoot
$ (anyOf 1)numberAlternativeA dollar amount
Format: double
$ (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
Retrieve a balance sheet — response body — columns item
FieldTypePresenceDescription and constraints
$objectRootA report column. The amount lists on each row are ordered to match the report's columns.
endDateJSONOptional
endDate (anyOf 1)JSONAlternative
endDate (anyOf 1) (allOf 1)stringAll variants applyFormat: date
endDate (anyOf 1) (allOf 2)JSONAll variants applyThe 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)nullAlternative
isPartialbooleanRequired within parentWhether @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.
labelstringRequired within parentThe 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.
startDateJSONOptional
startDate (anyOf 1)JSONAlternative
startDate (anyOf 1) (allOf 1)stringAll variants applyFormat: date
startDate (anyOf 1) (allOf 2)JSONAll variants applyThe 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)nullAlternative
Retrieve a cash flow report — response body — ending Balances item
FieldTypePresenceDescription and constraints
$objectRootThe cash balance of a cash ledger at the start or end of each column of a cash flow report.
balancesarrayRequired within parentFor each column, the ledger's own debit balance, excluding its children.
balances[]ModelEach itemExpand Create a product — response body — unit Price value
childrenarrayRequired within parentThe ledgers nested under this ledger.
children[]ModelEach itemExpand Retrieve a cash flow report — response body — ending Balances item
ledgerIdstringRequired within parentThe cash ledger this row represents.
Format: base58 (max length 22)
namestringRequired within parentThe ledger's display name.
parentIdJSONOptional
parentId (anyOf 1)stringAlternativeThe parent ledger, if this ledger is nested.
Format: base58 (max length 22)
parentId (anyOf 2)nullAlternative
sortCodestringRequired within parentThe ledger/account number used for chart ordering.
totalBalancesarrayRequired within parentFor each column, the debit balance of the ledger and all of its children.
totalBalances[]ModelEach itemExpand 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
FieldTypePresenceDescription and constraints
$objectRootNet cash movement through a ledger in each column of a cash flow report.
childrenarrayRequired within parentThe ledgers nested under this ledger.
children[]ModelEach itemExpand Retrieve a cash flow report — response body — ledgers item
ledgerIdstringRequired within parentThe ledger this row represents.
Format: base58 (max length 22)
namestringRequired within parentThe ledger's display name.
netCashFlowsarrayRequired within parentFor each column, the sum of the ledger's own cash line entries, excluding its children.
netCashFlows[]ModelEach itemExpand Create a product — response body — unit Price value
parentIdJSONOptional
parentId (anyOf 1)stringAlternativeThe parent ledger, if this ledger is nested.
Format: base58 (max length 22)
parentId (anyOf 2)nullAlternative
totalNetCashFlowsarrayRequired within parentFor each column, the sum of the cash line entries in the ledger and all of its children.
totalNetCashFlows[]ModelEach itemExpand 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

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.

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.