Mercury: Retrieve a balance sheet
Mercury books.getBooksBalanceSheet: arguments, response, policy and SDK examples.
← Books operations · Get started
Operation mercury.getbooksbalancesheet
Provider route: GET /books/reports/balance-sheet. 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"]["getBooksBalanceSheet"]>[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.getBooksBalanceSheet(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_balance_sheet(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 endDate. 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 daily. One of: daily, monthly, quarterly, yearly |
query.includeEmpty | boolean | Optional | Whether to include ledgers with no balance. Defaults to false. |
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 balance sheet — response body |
Referenced models: Retrieve a balance sheet — response body
Schemas
Section titled “Schemas”Retrieve a balance sheet — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | An income statement or balance sheet 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 |
retainedEarnings | JSON | Optional | |
retainedEarnings (anyOf 1) | JSON | Alternative | |
retainedEarnings (anyOf 1) (allOf 1) | Model | All variants apply | Expand Retrieve a balance sheet — response body — retained Earnings calculated Current Year Earnings, calculated Retained Earnings calculated Current Year Earnings, calculated Retained Earnings |
retainedEarnings (anyOf 1) (allOf 2) | JSON | All variants apply | System-calculated equity amounts. Present on balance sheets; omitted on income statements. |
retainedEarnings (anyOf 2) | null | Alternative | |
rows | array | Required within parent | The report's top-level rows. |
rows[] | Model | Each item | Expand Retrieve a balance sheet — response body — rows item |
Referenced models: Retrieve a balance sheet — response body — columns item, Retrieve a balance sheet — response body — rows item, Retrieve a balance sheet — response body — retained Earnings calculated Current Year Earnings, calculated Retained Earnings calculated Current Year Earnings, calculated Retained Earnings
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 balance sheet — response body — rows item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A row in an income statement or balance sheet. |
amounts | array | Required within parent | The row's own amount for each column, excluding its children. |
amounts[] | Model | Each item | Expand Create a product — response body — unit Price value |
children | array | Required within parent | The rows nested under this row. |
children[] | Model | Each item | Expand Retrieve a balance sheet — response body — rows item |
debitCredit | JSON | Required within parent | |
debitCredit (allOf 1) | string | All variants apply | Known values: debit, credit |
debitCredit (allOf 2) | JSON | All variants apply | Whether the row's amounts have a natural debit or credit balance. |
ledgerId | JSON | Optional | |
ledgerId (anyOf 1) | string | Alternative | The ledger this row represents. Omitted unless @rowKind@ is @ledger@. Format: base58 (max length 22) |
ledgerId (anyOf 2) | null | Alternative | |
name | string | Required within parent | The ledger name, the summary heading, or the name of the calculated metric. |
parentId | JSON | Optional | |
parentId (anyOf 1) | string | Alternative | The parent ledger of this row's ledger, if it is nested. Format: base58 (max length 22) |
parentId (anyOf 2) | null | Alternative | |
rowKind | JSON | Required within parent | |
rowKind (allOf 1) | string | All variants apply | Known values: ledger, summary, computed |
rowKind (allOf 2) | JSON | All variants apply | What the row represents. |
sortCode | JSON | Optional | |
sortCode (anyOf 1) | string | Alternative | The ledger/account number used for chart ordering. Omitted unless @rowKind@ is @ledger@. |
sortCode (anyOf 2) | null | Alternative | |
subType | JSON | Optional | |
subType (anyOf 1) | JSON | Alternative | |
subType (anyOf 1) (allOf 1) | string | All variants apply | Known values: currentAssets, nonCurrentAssets, transfersBetweenAccounts, uncategorizedAssets, currentLiabilities, nonCurrentLiabilities, equity, operatingRevenues, otherIncome, costOfGoodsSold, operatingExpenses, otherExpenses, retainedEarnings |
subType (anyOf 1) (allOf 2) | JSON | All variants apply | The ledger's more specific accounting classification. Omitted unless @rowKind@ is @ledger@. |
subType (anyOf 2) | null | Alternative | |
totalAmounts | array | Required within parent | The row's amount for each column, including all of its children. |
totalAmounts[] | Model | Each item | Expand Create a product — response body — unit Price value |
type | JSON | Optional | |
type (anyOf 1) | JSON | Alternative | |
type (anyOf 1) (allOf 1) | string | All variants apply | Known values: asset, liability, equity, revenue, expense |
type (anyOf 1) (allOf 2) | JSON | All variants apply | The top-level accounting classification of the row's ledger or summary grouping. Omitted on @computed@ rows. |
type (anyOf 2) | null | Alternative |
Referenced models: Create a product — response body — unit Price value, Retrieve a balance sheet — response body — rows item
Retrieve a balance sheet — response body — retained Earnings calculated Current Year Earnings, calculated Retained Earnings calculated Current Year Earnings, calculated Retained Earnings
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | System-calculated equity amounts that are added to the Retained Earnings and Current Year Earnings ledger rows. |
calculatedCurrentYearEarnings | array | Required within parent | For each column, current-year revenues minus current-year expenses, before journal entries posted to the Current Year Earnings ledger. |
calculatedCurrentYearEarnings[] | Model | Each item | Expand Create a product — response body — unit Price value |
calculatedRetainedEarnings | array | Required within parent | For each column, prior-year revenues minus prior-year expenses, before journal entries posted to the Retained Earnings ledger. |
calculatedRetainedEarnings[] | Model | Each item | Expand Create a product — response body — unit Price value |
Referenced models: Create a product — response body — unit Price value
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]+)?$ |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: mercury.getbooksbalancesheet. Catalog operation: mercury:getBooksBalanceSheet. 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.