Set or clear ledger opening balances
Changed onSets or clears the opening balance of up to 100 ledgers, i.e. general ledger (GL) accounts, in the organization's chart of accounts. To find ledger IDs, use getBooksLedgers; a ledger's current opening balance is its openingBalance there. Each item names a ledgerId and a balance; each ledgerId may appear at most once.
How opening balances work. Each ledger's opening balance is recorded on its own journal entry, dated the Books instance's entries start date and offset against the opening balances ledger. Setting a balance replaces any opening balance the ledger already has. A balance of 0 clears it.
Sign of balance. The balance is in the ledger's natural direction (its debitCredit): a positive balance increases the ledger on its natural side (a debit for debit-natural ledgers such as assets and expenses, a credit for credit-natural ledgers such as liabilities, equity, and revenue), and a negative balance puts it on the opposite side.
Per-item results. The response has exactly one result per requested ledger, in request order: its ledgerId and success: true, or success: false with an error that has a stable code and a message saying how to fix it. A ledger that fails does not fail the request or the other ledgers, so the status is 200 even when some or all fail; check each result. Error codes include invalidLedger (for example the opening balances ledger itself, which can't carry an opening balance), and unknownError; treat any code not listed here as unknownError.
Request errors. These are returned as an HTTP error status, and nothing is set: the token lacks the scope to update ledgers; a ledger is outside the Books instance; a ledger is linked to a Mercury account, whose transaction history determines its balance, so its opening balance can't be set (403, naming the ledger IDs); the list is empty; it has more than 100 items; or a ledgerId is repeated.
Request
- Base URLhttps://api.mercury.com/api/v1
- AuthHTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Query parameters
The Books instance to act on. Required for agent organization tokens; defaults to the token organization's instance.
Request body
Example request
{
"openingBalances": [
{
"ledgerId": "7JRNsKwy2Lw66caxVU7WGC"
}
]
}Response
Example response
{
"results": [
{
"ledgerId": "7JRNsKwy2Lw66caxVU7WGC"
}
]
}Changes
- info
endpoint added
- info