> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infinity.swiss/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete a ledger entry

> Deletes the ledger entry with the given id, together with the VAT that was booked with it. Receipts attached to the entry return to the document inbox, and the balances of the accounts involved are recalculated.

Only entries with the source `manual` can be deleted. Entries that another part of Infinity posted, such as invoice, bank, VAT, closing, salary or reversal entries, have to be undone through the feature that owns them.

## Deleting a ledger entry

Deleting an entry removes it from the ledger completely, just like deleting a booking in the app:

```bash theme={null}
curl -X DELETE https://api.infinity.swiss/v1/ledger-entries/682338d9e9500b3ffe4baa5a \
  -H "x-api-token: your-api-token"
```

* The VAT booked alongside the entry is deleted with it.
* Receipts attached to the entry are not deleted. They return to the document inbox, from where they can be attached to another entry.
* The balances of the accounts involved are recalculated.

A successful deletion returns `204 No Content` with an empty body.

## Entries that cannot be deleted

Only entries with the source `manual` — posted by hand in Infinity or through this API — can be deleted here. Every other entry belongs to a feature that owns it, for example an invoice, a bank transaction or the VAT settlement, and has to be undone there. See [ledger entry sources](/api/accounting/sources) for what each source means.

Deletion is refused with `403 Forbidden` and one of these error codes:

* `ledger/entry-not-deletable` if the source of the entry is not `manual`. The response also carries the `source` of the entry, so you know which part of Infinity it has to be undone in.
* `ledger/annulment-deletion` if the entry has already been reversed (Storno). Its `reversedBy` property tells you which entry reversed it.
* `fiscal-year/closed` if the entry lies in a closed fiscal year.
* `transactions/from-closed-vat-period` if the entry lies in a closed VAT period.

<Note>
  As with the other ledger endpoints, the id must be that of the ledger entry.
  An unknown id, an id from another organisation, or the id of the VAT
  transaction booked alongside an entry results in a `404 Not Found` response
  with the error code `transactions/not-found`.
</Note>


## OpenAPI

````yaml DELETE /v1/ledger-entries/{ledgerEntryId}
openapi: 3.1.0
info:
  title: infinity.swiss Open API
  version: '1.0'
  summary: ''
servers:
  - url: https://api.infinity.swiss
security:
  - apiKey: []
paths:
  /v1/ledger-entries/{ledgerEntryId}:
    parameters:
      - schema:
          type: string
        name: ledgerEntryId
        in: path
        description: The id of the ledger entry
        required: true
    delete:
      tags: []
      summary: Delete a ledger entry
      description: >-
        Deletes the ledger entry with the given id, together with the VAT that
        was booked with it. Receipts attached to the entry return to the
        document inbox, and the balances of the accounts involved are
        recalculated.


        Only entries with the source `manual` can be deleted. Entries that
        another part of Infinity posted, such as invoice, bank, VAT, closing,
        salary or reversal entries, have to be undone through the feature that
        owns them.
      operationId: delete-ledger-entry-v1
      responses:
        '204':
          description: The ledger entry was deleted. The response has no body.
        '401':
          $ref: '#/components/responses/Unauthorised'
        '403':
          description: The ledger entry exists but cannot be deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      The specific error code for this request.

                      May be:

                      - `ledger/entry-not-deletable` when the source of the
                      entry is not `manual`

                      - `ledger/annulment-deletion` when the entry has already
                      been reversed

                      - `fiscal-year/closed` when the entry lies in a closed
                      fiscal year

                      - `transactions/from-closed-vat-period` when the entry
                      lies in a closed VAT period
                  source:
                    $ref: '#/components/schemas/LedgerEntrySource'
                    description: >-
                      The source of the ledger entry. Only returned with the
                      error code `ledger/entry-not-deletable`, to tell you which
                      part of Infinity the entry has to be undone in.
        '404':
          $ref: '#/components/responses/LedgerEntryNotFound'
components:
  responses:
    Unauthorised:
      description: >-
        An unauthorised request was submitted. You may be using an incorrect or
        expired API token, or are attempting to access a document outside of the
        scope of the token.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                x-stoplight:
                  id: 08hkw8ukmi2lp
                description: Specific error code
          examples:
            Unauthorised request:
              value:
                code: general/unauthorised
    LedgerEntryNotFound:
      description: >-
        No ledger entry with this id exists in this organisation. This is also
        returned when the id refers to the VAT transaction that Infinity booked
        alongside an entry, rather than to the ledger entry itself.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                description: Specific error code.
          examples:
            Not found:
              value:
                code: transactions/not-found
  schemas:
    LedgerEntrySource:
      title: LedgerEntrySource
      type: string
      description: >-
        Which part of Infinity a ledger entry originates from:

        - `manual`: posted by hand in Infinity, or through this API

        - `customer-invoice`: posted by a customer invoice (Forderung), for
        example its positions, payments, discounts or rebates

        - `vendor-invoice`: posted by a vendor invoice (Kreditor), for example
        its positions or payments

        - `bank`: posted from a synchronised bank transaction in Live Accounting

        - `vat`: posted by a VAT settlement or a VAT payment

        - `closing`: posted when a fiscal year is opened or closed, for example
        accruals, depreciation or the profit appropriation

        - `reversal`: posted to reverse another ledger entry (Storno)

        - `salary`: posted by a salary payment
      enum:
        - manual
        - customer-invoice
        - vendor-invoice
        - bank
        - vat
        - closing
        - reversal
        - salary
      example: manual
  securitySchemes:
    apiKey:
      name: x-api-token
      type: apiKey
      in: header
      description: >-
        API token for authentication. Obtain from your Infinity account
        settings.

````