Skip to content

Mercury: Update ledgers (general ledger accounts)

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

← Books operations · Get started

Operation mercury.updatebooksledgers

Provider route: PUT /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"]["updateBooksLedgers"]>[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.updateBooksLedgers(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.update_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
bodyModelOptionalExpand Update ledgers (general ledger accounts) — request body — body

Referenced models: Update ledgers (general ledger accounts) — request body — body

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

FieldTypePresenceDescription and constraints
$ModelRootExpand Update ledgers (general ledger accounts) — response body

Referenced models: Update ledgers (general ledger accounts) — response body

1 more schema is linked from the tables above, on the schema pages.

Update ledgers (general ledger accounts) — response body
FieldTypePresenceDescription and constraints
$objectRootOne result per requested ledger update, in request order.
failedCountJSONRequired within parent
failedCount (anyOf 1)integerAlternativeHow many items in `results` failed, each with an `error`. Zero exactly when every item succeeded. `succeededCount` plus `failedCount` always equals the number of `results`.
Maximum: 9223372036854776000
Minimum: -9223372036854776000
failedCount (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
resultsarrayRequired within parentOne result per requested ledger update, in request order. A failed item does not fail the others.
results[]ModelEach itemExpand Update ledgers (general ledger accounts) — response body — results item
succeededCountJSONRequired within parent
succeededCount (anyOf 1)integerAlternativeHow many items in `results` succeeded.
Maximum: 9223372036854776000
Minimum: -9223372036854776000
succeededCount (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

Referenced models: Update ledgers (general ledger accounts) — response body — results item

Update ledgers (general ledger accounts) — request body — body
FieldTypePresenceDescription and constraints
$objectRootRequest to update general ledgers.
Additional keys: not allowed
ledgersarrayRequired within parentThe ledger updates to apply, from 1 to 100 ('maxBooksAPILedgerWrites'), processed in order. Each `ledgerId` may appear at most once.
ledgers[]ModelEach itemExpand Update ledgers (general ledger accounts) — request body — body ledgers item

Referenced models: Update ledgers (general ledger accounts) — request body — body ledgers item

Update ledgers (general ledger accounts) — response body — results item
FieldTypePresenceDescription and constraints
$objectRootThe outcome of updating one requested ledger: exactly one of `ledger` and `error` is set.
errorJSONOptional
error (anyOf 1)JSONAlternative
error (anyOf 1) (allOf 1)ModelAll variants applyExpand Set or clear ledger opening balances — response body — results item error code, message code, message
error (anyOf 1) (allOf 2)JSONAll variants applyWhy the ledger was not updated, when it wasn't.
error (anyOf 2)nullAlternative
ledgerJSONOptional
ledger (anyOf 1)JSONAlternative
ledger (anyOf 1) (allOf 1)ModelAll variants applyExpand List the live chart of accounts — response body — ledgers item
ledger (anyOf 1) (allOf 2)JSONAll variants applyThe updated ledger, when it was updated.
ledger (anyOf 2)nullAlternative

Referenced models: List the live chart of accounts — response body — ledgers item, Set or clear ledger opening balances — response body — results item error code, message code, message

Update ledgers (general ledger accounts) — request body — body ledgers item
FieldTypePresenceDescription and constraints
$objectRootUpdates to apply to an existing general ledger. Omitted fields are left unchanged.
Additional keys: not allowed
clearFieldsJSONOptional
clearFields (anyOf 1)arrayAlternativeFields to clear, such as the parent ledger
clearFields (anyOf 1)[]stringEach itemOne of: parentId
clearFields (anyOf 2)nullAlternative
debitCreditJSONOptional
debitCredit (anyOf 1)JSONAlternative
debitCredit (anyOf 1) (allOf 1)stringAll variants applyOne of: debit, credit
debitCredit (anyOf 1) (allOf 2)JSONAll variants applyUpdated debit or credit nature
debitCredit (anyOf 2)nullAlternative
ledgerIdstringRequired within parentThe ID of the ledger to update
Format: base58 (max length 22)
nameJSONOptional
name (anyOf 1)stringAlternativeUpdated ledger name
Format: size < 256
name (anyOf 2)nullAlternative
parentIdJSONOptional
parentId (anyOf 1)stringAlternativeUpdated parent ledger
Format: base58 (max length 22)
parentId (anyOf 2)nullAlternative
sortCodeJSONOptional
sortCode (anyOf 1)stringAlternativeUpdated numeric sort code
Format: matches ^[0-9]+$, size < 21
sortCode (anyOf 2)nullAlternative
subTypeJSONOptional
subType (anyOf 1)JSONAlternative
subType (anyOf 1) (allOf 1)stringAll variants applyOne of: currentAssets, nonCurrentAssets, transfersBetweenAccounts, uncategorizedAssets, currentLiabilities, nonCurrentLiabilities, equity, operatingRevenues, otherIncome, costOfGoodsSold, operatingExpenses, otherExpenses, retainedEarnings
subType (anyOf 1) (allOf 2)JSONAll variants applyUpdated ledger sub-type
subType (anyOf 2)nullAlternative
typeJSONOptional
type (anyOf 1)JSONAlternative
type (anyOf 1) (allOf 1)stringAll variants applyOne of: asset, liability, equity, revenue, expense
type (anyOf 1) (allOf 2)JSONAll variants applyUpdated ledger type
type (anyOf 2)nullAlternative
Set or clear ledger opening balances — response body — results item error code, message code, message
FieldTypePresenceDescription and constraints
$objectRootWhy one ledger in a bulk create, update, or delete failed. A failed item
never fails the whole request; the other items still succeed or fail on
their own.
codeJSONRequired within parent
code (allOf 1)stringAll variants applyKnown values: invalidLedger, missingParameters, duplicateName, duplicateSortCode, invalidLedgerType, invalidLedgerParent, invalidLedgerReportCashFlow, deletingRequiredLedger, deletingLedgerWithActivity, deletingLinkedLedger, deletingParentLedger, modifyingRequiredLedger, integrationMapped, invalidUnappliedPaymentsLedger, deletingMappedLedger, modifyingMappedLedger, mercuryAccountLedger, unknownError
code (allOf 2)JSONAll variants applyStable code for the failure.
messagestringRequired within parentWhat went wrong and how to fix it, suitable to show to a user.
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.updatebooksledgers. Catalog operation: mercury:updateBooksLedgers. 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.