Books

Update ledgers (general ledger accounts)

Changed on

Updates up to 100 existing ledgers, i.e. general ledger (GL) accounts, in the organization's live chart of accounts: rename (name), renumber (sortCode, the account number), re-parent (parentId), or retype (type, subType, debitCredit) them. To find ledger IDs, use getBooksLedgers. Each item names a ledgerId and only the fields to change; omitted fields are left unchanged. To remove a ledger's parent, list parentId in clearFields (and don't also set parentId). Each ledgerId may appear at most once.

Chart-of-accounts rules. Teal validates each update: subType must belong to type (see the type and subType fields of a ledger, as returned by getBooksLedgers); a child ledger has the same type and sub-type as its parent, so a sub-ledger can't be retyped in place; a parent can't be the ledger itself or one of its descendants; names and sort codes must be unique; required ledgers allow changes only to name, sortCode, and parentId; expense and revenue ledgers can't be cash-flow ledgers, so a cash-flow ledger can't be retyped to either; and ledgers linked to a financial account may refuse some changes.

Per-item results. The response has exactly one result per requested update, in request order: the updated ledger, in the same shape as getBooksLedgers returns, or an error with 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, missingParameters, duplicateName, duplicateSortCode, invalidLedgerType, invalidLedgerParent, invalidLedgerReportCashFlow, modifyingRequiredLedger, and unknownError; treat any code not listed here as unknownError.

Request errors. These are returned as an HTTP error status, and nothing is updated: the token lacks the scope to update ledgers; a ledger or new parent ledger is outside the Books instance or read-only (linked to a Mercury account); the list is empty; it has more than 100 updates; or a ledgerId is repeated.

put/books/ledgers

Request

Query parameters

booksIdstring uuid

The Books instance to act on. Must be the token organization's own instance, which it defaults to.

Request body

Example request

{
  "ledgers": [
    {
      "ledgerId": "7JRNsKwy2Lw66caxVU7WGC",
      "parentId": "7JRNsKwy2Lw66caxVU7WGC"
    }
  ]
}

Response

Example response

{
  "results": [
    {
      "ledger": {
        "id": "7JRNsKwy2Lw66caxVU7WGC",
        "parentId": "7JRNsKwy2Lw66caxVU7WGC"
      }
    }
  ]
}

Changes