Books

Delete ledgers (general ledger accounts)

Changed on

Deletes up to 100 ledgers, i.e. general ledger (GL) accounts, from the organization's chart of accounts, by ledger ID. To find ledger IDs, use getBooksLedgers. Ledgers are deleted one at a time in request order, so list each child ledger before its parent: a parent listed before its child still has that child when it is reached and is not deleted. A repeated ID is processed once, at its first position. This operation never deletes journal entries.

Per-item results. The response has one result per distinct requested ID, in request order: its ledgerId and deleted: true, or deleted: 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.

Per-item error codes (error.code) and how to fix them:

  • deletingLedgerWithActivity: the ledger has activity, such as line entries. Move or delete its journal entries first; this operation won't delete them.
  • deletingParentLedger: the ledger still has child ledgers. Delete its children first, or list them before the parent in the same request.
  • deletingLinkedLedger: the ledger is linked to a bank or other source account. Unlink the account first.
  • deletingRequiredLedger: the chart of accounts requires this ledger. It cannot be deleted.
  • integrationMapped: an accounting, invoicing, commerce, or Plaid integration is mapped to the ledger. Remove the mapping first.
  • unknownError: the ledger could not be deleted for another reason. Read message; retry, or treat any code not listed here the same way.

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

delete/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

ledgerIdsstring[] required

The IDs of the ledgers to delete, from 1 to 100 distinct IDs, processed in order. List a child ledger before its parent: a parent that still has children when it is reached is not deleted. A repeated ID is processed once, at its first position.

Example request

{
  "ledgerIds": [
    "7JRNsKwy2Lw66caxVU7WGC"
  ]
}

Response

Example response

{
  "results": [
    {
      "ledgerId": "7JRNsKwy2Lw66caxVU7WGC"
    }
  ]
}

Changes