> ## 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.

# Modify a ledger entry

> Edits the ledger entry with the given id. The entry keeps its id and its receipts. When the booking changes, Infinity re-books the VAT and recalculates the balances of the accounts involved.

Which fields can be changed depends on the source of the entry:
- `manual`: every field except `reviewState`
- `bank`: only `description`, `taxCode`, `reviewState` and the contra account, i.e. whichever of `debitAccount` or `creditAccount` is not the bank account

Entries with any other source, reversed entries, and entries in a closed fiscal year or a closed VAT period cannot be edited.

## Editing a ledger entry

Only the fields you provide are changed. For example, the following payload changes the text, the income account and the tax code of an entry:

```json theme={null}
{
  "description": "Beratung März",
  "creditAccount": 3400,
  "taxCode": "UN81"
}
```

* The entry keeps its `id` and its attached receipts.
* When the booking changes, the VAT is booked again and the balances of the accounts involved are recalculated.
* To remove the VAT, set `taxCode` to `""` or `null`.

The response contains the edited entry as `ledgerEntry`, in the same shape as when you [get a ledger entry](/api/accounting/get).

## What can be changed

Which fields can be changed depends on the [source](/api/accounting/sources) of the entry:

* `manual`: every field except `reviewState`.
* `bank`: only `description`, `taxCode`, `reviewState` and the contra account. The date, amount and currency come from the bank transaction, and the bank account side may only be sent unchanged.

To change the currency, also send the new `amount`. `exchangeRate` and `baseAmount` work as when [posting a ledger entry](/api/accounting/create#foreign-currency-entries); changing only the exchange rate keeps the foreign amount and recalculates the CHF amount.

Sending a field that cannot be changed is rejected with `400 Bad Request` and the error code `ledger/entry-field-not-editable`. The response lists the refused fields in `fields` and the `source` of the entry.

## Reviewing bank entries

Entries posted from a bank transaction by AI accounting carry a review state. Set `reviewState` to `reviewed` to confirm an entry, or to `ai-proposed` to mark it as awaiting review again. Editing other fields does not change the review state.

## Entries that cannot be edited

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

* `ledger/entry-not-editable` if the source of the entry is neither `manual` nor `bank`. The response also carries the `source` of the entry, so you know which part of Infinity it has to be changed in.
* `ledger/entry-reversed` if the entry has already been reversed (Storno).
* `fiscal-year/closed` if the current or new date lies in a closed fiscal year.
* `transactions/from-closed-vat-period` if the current or new date lies in a closed VAT period.


## OpenAPI

````yaml PATCH /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
    patch:
      tags: []
      summary: Modify a ledger entry
      description: >-
        Edits the ledger entry with the given id. The entry keeps its id and its
        receipts. When the booking changes, Infinity re-books the VAT and
        recalculates the balances of the accounts involved.


        Which fields can be changed depends on the source of the entry:

        - `manual`: every field except `reviewState`

        - `bank`: only `description`, `taxCode`, `reviewState` and the contra
        account, i.e. whichever of `debitAccount` or `creditAccount` is not the
        bank account


        Entries with any other source, reversed entries, and entries in a closed
        fiscal year or a closed VAT period cannot be edited.
      operationId: modify-ledger-entry-v1
      requestBody:
        description: >-
          Provide the changes to save to the ledger entry in the request body.
          Any fields that are not provided are left unchanged.
        content:
          application/json:
            schema:
              type: object
              x-examples:
                Example 1:
                  description: Beratung März
                  creditAccount: 3400
                  taxCode: UN81
              properties:
                date:
                  type: string
                  format: date
                  example: '2025-01-30'
                  description: >-
                    The new date in YYYY-MM-DD format. Only for entries with the
                    source `manual`. Both the current and the new date must lie
                    in an open fiscal year and outside a closed VAT period.
                description:
                  type: string
                  minLength: 1
                  maxLength: 128
                  description: The new single-line text of the ledger entry.
                debitAccount:
                  type: integer
                  minimum: 1000
                  maximum: 9999
                  description: >-
                    The account number of the new debit account. For entries
                    with the source `bank`, only the contra account can be
                    changed; the bank account may only be sent unchanged.
                creditAccount:
                  type: integer
                  minimum: 1000
                  maximum: 9999
                  description: >-
                    The account number of the new credit account. For entries
                    with the source `bank`, only the contra account can be
                    changed; the bank account may only be sent unchanged.
                amount:
                  type: integer
                  minimum: 1
                  example: 12030
                  description: >-
                    The new gross amount in cents, in the currency of the entry.
                    Only for entries with the source `manual`. Required when
                    `currency` changes.
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                  example: EUR
                  description: >-
                    The new 3-character currency code (ISO 4217). Only for
                    entries with the source `manual`. Must be a currency enabled
                    in the organisation; `CHF` turns a foreign currency entry
                    into a CHF entry. If neither `exchangeRate` nor `baseAmount`
                    is given, the exchange rate set for the currency in Infinity
                    applies.
                exchangeRate:
                  type: number
                  exclusiveMinimum: 0
                  description: >-
                    The new exchange rate as 1 unit of the foreign currency = X
                    CHF. Only for entries with the source `manual`, and ignored
                    for entries in CHF. Changing only the rate keeps the foreign
                    amount and recalculates the CHF amount.
                baseAmount:
                  type: integer
                  minimum: 1
                  example: 9800
                  description: >-
                    The CHF amount in cents, as an alternative to
                    `exchangeRate`. Only for entries with the source `manual`.


                    Sending `baseAmount` together with `exchangeRate`, or for an
                    entry in CHF, is rejected with `400 Bad Request` and the
                    error code `general/missing-fields`.
                taxCode:
                  oneOf:
                    - title: Statutory tax code
                      description: >-
                        A statutory tax code, such as `UN81` for the normal
                        rate.
                      enum:
                        - UN81
                        - UN77
                        - UR26
                        - UR25
                        - US38
                        - US37
                        - UO81
                        - UO77
                        - BZB81
                        - BZB77
                        - BZM81
                        - BZM77
                        - VM81
                        - VM38
                        - VM26
                        - VB81
                        - VB38
                        - VB26
                        - VM77
                        - VM37
                        - VM25
                        - VB77
                        - VB37
                        - VB25
                        - ES81
                        - ES26
                        - ES77
                        - ES25
                        - UNO
                        - UEX
                        - ULA
                        - ZOLLM
                        - ZOLLB
                    - title: Simplified tax code
                      description: >-
                        One of the organisation's own simplified tax codes
                        (Saldosteuersatz), such as `SS53` or `SS06R`. Only
                        accepted if the organisation accounts for VAT with the
                        simplified method.
                      type: string
                      pattern: ^SS\d{2}[RS]?$
                      example: SS53
                    - title: No VAT
                      description: >-
                        The empty string or `null` removes the VAT from the
                        ledger entry.
                      enum:
                        - ''
                        - null
                  description: >-
                    The new VAT tax code. Changing it re-books the VAT of the
                    entry.


                    Which codes are accepted depends on the VAT settings of the
                    organisation and on the date of the entry. Use [GET
                    /v1/tax-codes](/api/accounting/tax-codes) to list the codes
                    available for a date.
                  example: UN81
                reviewState:
                  $ref: '#/components/schemas/LedgerEntryReviewState'
                  description: >-
                    Only for entries with a review state, i.e. entries posted
                    from a bank transaction. `reviewed` confirms the entry,
                    `ai-proposed` marks it as awaiting review again. Editing
                    other fields does not change the review state.
      responses:
        '200':
          description: Changes saved successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ledgerEntry
                properties:
                  ledgerEntry:
                    $ref: '#/components/schemas/LedgerEntry'
        '400':
          description: >-
            A bad request is thrown if the provided changes are invalid or
            cannot be applied to this ledger entry.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                properties:
                  code:
                    type: string
                    description: >-
                      The specific error code for this request.

                      May be:

                      - `general/missing-fields` if no field to change was
                      provided, if `baseAmount` is combined with `exchangeRate`
                      or used for an entry in CHF, or if `currency` changes
                      without `amount`

                      - `general/invalid-date`

                      - `ledger/entry-field-not-editable` if a field cannot be
                      changed for this entry, for example the amount of an entry
                      with the source `bank`

                      - `transactions/same-debit-and-credit-account`

                      -
                      `transactions/exchange-rate-required-for-foreign-currency-account`

                      - `transactions/original-currency-mismatch`

                      - `transactions/incompatible-foreign-currency-accounts`

                      - `vat/invalid-tax-code`

                      - `vat/tax-code-not-allowed-in-simplified-mode`

                      - `vat/simplified-tax-code-not-configured-for-period`
                  invalidFields:
                    type: array
                    uniqueItems: true
                    description: A list of the fields which were invalid, if applicable.
                    items:
                      type: string
                      example: baseAmount
                  fields:
                    type: array
                    description: >-
                      The request fields that cannot be changed for this entry.
                      Only returned with the error code
                      `ledger/entry-field-not-editable`.
                    items:
                      type: string
                      example: amount
                  source:
                    $ref: '#/components/schemas/LedgerEntrySource'
                    description: >-
                      The source of the ledger entry. Only returned with the
                      error code `ledger/entry-field-not-editable`.
        '401':
          $ref: '#/components/responses/Unauthorised'
        '403':
          description: The ledger entry exists but cannot be edited.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      The specific error code for this request.

                      May be:

                      - `ledger/entry-not-editable` when the source of the entry
                      is neither `manual` nor `bank`

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

                      - `fiscal-year/closed` when the current or new date lies
                      in a closed fiscal year

                      - `transactions/from-closed-vat-period` when the current
                      or new date 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-editable`, to tell you which
                      part of Infinity the entry has to be changed in.
        '404':
          description: The ledger entry, an account or the currency was not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      The specific error code for this request.

                      May be:

                      - `transactions/not-found` when there is no ledger entry
                      with this id

                      - `ledger/account-not-found` when the debit or credit
                      account does not exist

                      - `fiscal-year/not-found` when the new date lies outside
                      every fiscal year

                      - `currency/not-found` when the currency is not enabled in
                      the organisation
components:
  schemas:
    LedgerEntryReviewState:
      title: LedgerEntryReviewState
      type: string
      description: >-
        Whether a person stands behind a ledger entry:

        - `ai-proposed`: AI accounting posted the entry from a synchronised bank
        transaction, and nobody has reviewed it yet. Treat it as provisional:
        reviewing may still change or remove it.

        - `reviewed`: a person posted the entry, or reviewed one that AI
        accounting had posted. Entries posted by hand, through this API, or by
        another part of Infinity are always `reviewed`.
      enum:
        - ai-proposed
        - reviewed
      example: reviewed
    LedgerEntry:
      title: LedgerEntry
      type: object
      description: >-
        A ledger entry is a single booking in the ledger: one amount, posted
        from a debit to a credit account on a date.


        Infinity books the VAT of an entry as a separate VAT transaction
        internally, but the API never returns it on its own: it is folded into
        the `vat` property of the entry it belongs to.
      required:
        - id
        - date
        - description
        - debitAccount
        - creditAccount
        - amount
        - netAmount
        - currency
        - source
        - reviewState
        - receiptIds
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          description: >-
            A unique hex identifier for the ledger entry. It stays the same when
            the entry is edited.
          example: 682338d9e9500b3ffe4baa5a
        date:
          type: string
          format: date
          description: The date of the ledger entry in YYYY-MM-DD format.
          example: '2025-02-05'
        description:
          type: string
          description: The single text-line description of the ledger entry.
          example: Consulting revenue
        debitAccount:
          type: integer
          minimum: 1000
          maximum: 9999
          description: The account number of the debit account of the ledger entry.
          example: 1020
        creditAccount:
          type: integer
          minimum: 1000
          maximum: 9999
          description: The account number of the credit account of the ledger entry.
          example: 3400
        amount:
          type: integer
          description: >-
            The gross amount of the ledger entry in cents (e.g. 108100 =
            1081.00), in CHF.


            For entries without VAT, this is the same as `netAmount`. It is also
            the same for reverse charge tax codes (acquisition tax), where the
            VAT is booked on top of the entry instead of being contained in it.
          example: 108100
        netAmount:
          type: integer
          description: >-
            The amount in cents that is booked between the debit and the credit
            account, in CHF, without the VAT booked alongside it.
          example: 100000
        currency:
          type: string
          minLength: 3
          maxLength: 3
          description: >-
            The 3-character alphanumeric currency code (ISO 4217) of `amount`
            and `netAmount`. These are always given in the accounting currency,
            which currently is always `CHF`. The currency the entry was posted
            in is reported in `fx`.
          example: CHF
        vat:
          $ref: '#/components/schemas/LedgerEntryVat'
          description: >-
            The VAT booked with this entry. Present for every entry that has a
            tax code.
        fx:
          $ref: '#/components/schemas/LedgerEntryFx'
          description: >-
            The original amount of this entry in a foreign currency. Present for
            every entry that was posted in a currency other than CHF.
        source:
          $ref: '#/components/schemas/LedgerEntrySource'
          description: Which part of Infinity this entry originates from.
        reviewState:
          $ref: '#/components/schemas/LedgerEntryReviewState'
          description: >-
            Whether a person stands behind this entry, or AI accounting posted
            it and it still awaits review.
        receiptIds:
          type: array
          description: >-
            The ids of the receipts attached to this ledger entry, in the order
            in which they were attached.
          items:
            type: string
            example: 686f1b2ce9500b3ffe4bbc71
        reversedBy:
          type: string
          description: >-
            The id of the ledger entry that reverses this entry (Storno). Only
            present if the entry has been reversed; such an entry can no longer
            be deleted.
          example: 6851f42ae9500b3ffe4bb0c4
        reverses:
          type: string
          description: >-
            The id of the ledger entry that this entry reverses. Only present
            for entries with the source `reversal`.
          example: 682338d9e9500b3ffe4baa5a
        createdAt:
          type: string
          format: date-time
          description: The time at which the ledger entry was created.
          example: '2025-02-05T09:12:44.000Z'
        updatedAt:
          type: string
          format: date-time
          description: >-
            The time at which the ledger entry was last changed. Use it together
            with the `updatedSince` filter to synchronise changes incrementally.
          example: '2025-02-05T09:12:44.000Z'
    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. Only its description, tax code, contra account and review
        state can be edited

        - `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
    LedgerEntryVat:
      title: LedgerEntryVat
      type: object
      description: >-
        The VAT that was booked with a ledger entry, as it stands in the ledger.


        With reverse charge tax codes (acquisition tax, `BZB…` and `BZM…`), the
        VAT is booked on top of the entry rather than contained in it: the
        `amount` of the entry equals its `netAmount`, and the VAT booking runs
        between two VAT accounts.
      required:
        - taxCode
        - amount
      properties:
        taxCode:
          type: string
          description: >-
            The tax code of the ledger entry, either a statutory code such as
            `UN81`, or one of the organisation's own simplified codes
            (Saldosteuersatz) such as `SS53`.
          examples:
            - UN81
            - SS53
        rate:
          type: number
          description: >-
            The VAT rate in percent that was actually booked, e.g. `8.1`. With
            the simplified method (Saldosteuersatz), this is the organisation's
            simplified rate, e.g. `5.3`.


            Absent only for tax codes that are no longer defined.
          example: 8.1
        statutoryRate:
          type: number
          description: >-
            The statutory VAT rate in percent that the tax code stands for, e.g.
            `8.1`. Only present for simplified tax codes (Saldosteuersatz),
            where the rate charged to the customer differs from the rate booked.
          example: 8.1
        amount:
          type: integer
          description: >-
            The VAT amount in cents that was booked, in CHF.


            `0` if no VAT booking was made after all, for example because the
            VAT amount rounded to zero.
          example: 8100
        debitAccount:
          type: integer
          minimum: 1000
          maximum: 9999
          description: >-
            The account number of the debit account of the VAT booking. Absent
            if no VAT booking was made.
          example: 1020
        creditAccount:
          type: integer
          minimum: 1000
          maximum: 9999
          description: >-
            The account number of the credit account of the VAT booking. Absent
            if no VAT booking was made.
          example: 2200
    LedgerEntryFx:
      title: LedgerEntryFx
      type: object
      description: >-
        The foreign currency details of a ledger entry. Only present if the
        entry has an amount in a foreign currency; the amounts of the entry
        itself are always converted to CHF.
      required:
        - amount
        - currency
      properties:
        amount:
          type: integer
          description: >-
            The gross amount of the ledger entry in cents (e.g. 10000 = 100.00),
            in the foreign currency.
          example: 10000
        currency:
          type: string
          minLength: 3
          maxLength: 3
          description: >-
            The 3-character alphanumeric currency code (ISO 4217) of the foreign
            currency.
          example: EUR
        exchangeRate:
          type: number
          description: >-
            The exchange rate that was used to convert the amount, as the value
            of one unit of the foreign currency in CHF. Absent only for legacy
            entries that were posted without a rate.
          example: 0.95
  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
  securitySchemes:
    apiKey:
      name: x-api-token
      type: apiKey
      in: header
      description: >-
        API token for authentication. Obtain from your Infinity account
        settings.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.