Skip to content

Mercury: List the live chart of accounts

Mercury books.getBooksLedgers: arguments, response, policy and SDK examples.

← Books operations · Get started

Operation mercury.getbooksledgers

Provider route: GET /books/ledgers. 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"]["getBooksLedgers"]>[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.getBooksLedgers(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_ledgers(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.typestringOptionalOnly return ledgers of this type.
One of: asset, liability, equity, revenue, expense
query.subTypestringOptionalOnly return ledgers of this sub-type.
One of: currentAssets, nonCurrentAssets, transfersBetweenAccounts, uncategorizedAssets, currentLiabilities, nonCurrentLiabilities, equity, operatingRevenues, otherIncome, costOfGoodsSold, operatingExpenses, otherExpenses, retainedEarnings
query.debitCreditstringOptionalOnly return ledgers with this natural balance.
One of: debit, credit
query.idsarrayOptionalComma-separated list of at most 100 distinct ledger IDs. Only return these ledgers. Every ID must belong to the Books instance. Results are still paginated, so pass a `limit` of at least the number of IDs to get them all in one page.
query.ids[]stringEach itemunique id for a ledger; emitted as base-58, but a base-16 UUID is also accepted
Format: base58 (max length 22)
query.pageTokenstringOptionaltoken for pagination
query.limitintegerOptionalThe maximum number of accounts to return per page, from 1 to 1000. Defaults to 50.
Default: 50
Maximum: 1000
Minimum: 1

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

FieldTypePresenceDescription and constraints
$ModelRootExpand List the live chart of accounts — response body

Referenced models: List the live chart of accounts — response body

List the live chart of accounts — response body
FieldTypePresenceDescription and constraints
$objectRootResponse containing a paginated list of ledgers in the organization's live chart of accounts.
ledgersarrayRequired within parentThe ledgers on this page. Use each ledger's @parentId@ to reconstruct hierarchy.
ledgers[]ModelEach itemExpand List the live chart of accounts — response body — ledgers item
nextPageTokenJSONOptional
nextPageToken (anyOf 1)stringAlternativeToken to fetch the next page of results
nextPageToken (anyOf 2)nullAlternative
prevPageTokenJSONOptional
prevPageToken (anyOf 1)stringAlternativeToken to fetch the previous page of results
prevPageToken (anyOf 2)nullAlternative

Referenced models: List the live chart of accounts — response body — ledgers item

List the live chart of accounts — response body — ledgers item
FieldTypePresenceDescription and constraints
$objectRootA general ledger in an organization's live chart of accounts.
debitCreditJSONRequired within parent
debitCredit (allOf 1)stringAll variants applyKnown values: debit, credit
debitCredit (allOf 2)JSONAll variants applyWhether the ledger has a natural debit or credit balance.
deletablebooleanRequired within parentWhether the ledger can be deleted now. A ledger can't be deleted if it is required, has line entries, is linked to a bank or card account, or has an integration (invoicing, commerce, or a linked Plaid account) mapped to it. `deleteBlockedReason` says which.
deleteBlockedReasonJSONOptional
deleteBlockedReason (anyOf 1)JSONAlternative
deleteBlockedReason (anyOf 1) (allOf 1)stringAll variants applyKnown values: required, hasActivity, linkedSource, integrationMapped
deleteBlockedReason (anyOf 1) (allOf 2)JSONAll variants applyWhy the ledger can't be deleted. Absent when `deletable` is true. When several reasons apply, only one is given: `required` first, then `linkedSource` for a ledger fed by a Mercury account, since neither can be fixed. Fixing any other reason may reveal another.
deleteBlockedReason (anyOf 2)nullAlternative
editablebooleanRequired within parentWhether line entries can be manually added to or removed from the ledger, for example by categorizing a transaction to it. False for ledgers whose activity a system controls, such as Mercury bank and card account ledgers and the accounts receivable and accounts payable required ledgers.
financialAccountTypeJSONOptional
financialAccountType (anyOf 1)JSONAlternative
financialAccountType (anyOf 1) (allOf 1)stringAll variants applyKnown values: bankAccount, creditCard, payments, payroll, loan, prepaidCard, accountsReceivable, accountsPayable, investment, treasury
financialAccountType (anyOf 1) (allOf 2)JSONAll variants applyThe real-world financial account represented by this ledger, if any.
financialAccountType (anyOf 2)nullAlternative
idstringRequired within parentThe stable identifier for the ledger.
Format: base58 (max length 22)
isRequiredbooleanRequired within parentWhether the ledger is a required ledger, which the accounting system needs to operate. Required ledgers can't be deleted, and only their `name`, `sortCode`, and `parentId` can be changed.
namestringRequired within parentThe ledger's display name.
Format: size < 256
openingBalanceJSONOptional
openingBalance (anyOf 1)JSONAlternative
openingBalance (anyOf 1) (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
openingBalance (anyOf 1) (allOf 2)JSONAll variants applyThe ledger's opening balance in its natural direction (`debitCredit`): positive is a balance on the ledger's natural side, negative on the opposite side. Absent when the ledger has no opening balance. Returned by getBooksLedgers and getBooksLedger only; absent from the ledgers in create and update results. Set or clear it with setBooksLedgerOpeningBalances.
openingBalance (anyOf 2)nullAlternative
parentIdJSONOptional
parentId (anyOf 1)stringAlternativeThe identifier of the ledger's parent, if it is nested.
Format: base58 (max length 22)
parentId (anyOf 2)nullAlternative
requiredLedgerPurposeJSONOptional
requiredLedgerPurpose (anyOf 1)JSONAlternative
requiredLedgerPurpose (anyOf 1) (allOf 1)ModelAll variants applyExpand Retrieve ledger balances over a date range — response body — ledger Balances item special Type string string
requiredLedgerPurpose (anyOf 1) (allOf 2)JSONAll variants applyThe system function a required ledger fulfills, such as holding uncategorized inflows. Absent for ledgers that aren't required.
requiredLedgerPurpose (anyOf 2)nullAlternative
sortCodestringRequired within parentThe ledger/account number used for chart ordering and template mapping.
Format: size < 21
subTypeJSONRequired within parent
subType (allOf 1)stringAll variants applyKnown values: currentAssets, nonCurrentAssets, transfersBetweenAccounts, uncategorizedAssets, currentLiabilities, nonCurrentLiabilities, equity, operatingRevenues, otherIncome, costOfGoodsSold, operatingExpenses, otherExpenses, retainedEarnings
subType (allOf 2)JSONAll variants applyThe ledger's more specific accounting classification. It must belong to the ledger's `type`: `asset`: `currentAssets`, `nonCurrentAssets`, `transfersBetweenAccounts`, `uncategorizedAssets`; `liability`: `currentLiabilities`, `nonCurrentLiabilities`; `equity`: `equity`, `retainedEarnings`; `revenue`: `operatingRevenues`, `otherIncome`; `expense`: `costOfGoodsSold`, `operatingExpenses`, `otherExpenses`. A child ledger has the same type and sub-type as its parent.
typeJSONRequired within parent
type (allOf 1)stringAll variants applyKnown values: asset, liability, equity, revenue, expense
type (allOf 2)JSONAll variants applyThe ledger's top-level accounting classification. A sub-ledger has the same type as the root of its hierarchy.

Referenced models: Create a product — response body — unit Price value, Retrieve ledger balances over a date range — response body — ledger Balances item special Type string string

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 ledger balances over a date range — response body — ledger Balances item special Type string string
FieldTypePresenceDescription and constraints
$stringRootKnown values: uncatInflow, uncatOutflow, accountTransfers, openingBalances, accountsReceivable, accountsPayable, wagesExpense, bonusExpense, commissionsExpense, contractorExpense, employeeReimbursements, severanceExpense, payrollTaxExpense, employerBenefitsExpense, healthInsuranceExpense, wagesPayable, payrollTaxPayable, employeeBenefitLiabilities, payrollLiabilities, payrollAdjustmentsClearing, retainedEarnings, currentYearEarnings, benefitsExpense, donationsExpense, benefitsPayable, payrollTaxAccruals, stockExerciseClearing, payrollClearing

SDK function policy ID: mercury.getbooksledgers. Catalog operation: mercury:getBooksLedgers. 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.