---
title: "Delete ledgers (general ledger accounts)"
method: DELETE
path: "/books/ledgers"
tags: ["Books"]
---

# Delete ledgers (general ledger accounts)

`DELETE /books/ledgers`

## Request

- Base URL: `https://api.mercury.com/api/v1`
- URL: `https://api.mercury.com/api/v1/books/ledgers`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/mercurytechnologies/apis/mercury-api/docs/books/ledgers/delete.ts> (a function with typed inputs; its response is checked against the schema)

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.

## Query parameters

- `booksId` string, uuid: The Books instance to act on. Must be the token organization's own instance, which it defaults to.

## Request body

- DeleteBooksAPILedgersRequest: Request to delete general ledgers.
  - `ledgerIds` string[], 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.

## Response `200`

- DeleteBooksAPILedgersResponse: One result per distinct requested ledger ID, in request order.
  - `results` BooksAPIDeleteLedgerResult[], required: One result per distinct requested ledger ID, in request order. A failed item does not fail the others.
    - `deleted` boolean, required: Whether the ledger was deleted.
    - `error` object, nullable: Why the ledger was not deleted, when it wasn't.
      - `code` 'invalidLedger' | 'missingParameters' | 'duplicateName' | 'duplicateSortCode' | 'invalidLedgerType' | 'invalidLedgerParent' | 'invalidLedgerReportCashFlow' | 'deletingRequiredLedger' | 'deletingLedgerWithActivity' | 'deletingLinkedLedger' | 'deletingParentLedger' | 'modifyingRequiredLedger' | 'integrationMapped' | 'mercuryAccountLedger' | 'unknownError', required: Stable code for the failure.
      - `message` string, required: What went wrong and how to fix it, suitable to show to a user.
    - `ledgerId` string, base58 (max length 22), required: The requested ledger ID.

## Other responses

- `400`: Invalid `body` or `booksId`

## Changes

- **2026-11-03** `95c77a617769`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/mercurytechnologies/apis/mercury-api/changes/books/ledgers/delete.md)

---

[API](https://skmtc.dev/mercurytechnologies/apis/mercury-api.md) - [All operations](https://skmtc.dev/mercurytechnologies/apis/mercury-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mercurytechnologies/apis/mercury-api/revisions/95c77a617769?raw)
