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

# Post a ledger entry

> Creates a new single ledger entry that is posted as a new transaction.

## Creating a new ledger entry

For example, the following payload will create a new ledger entry for the amount of CHF 120.50 (consisting of two ledger transactions – a net transaction and a VAT debt transaction due to the `UN81` tax code):

```json theme={null}
{
  "date": "2025-01-01",
  "description": "Einnahme von 120.50 CHF",
  "debitAccount": 1020,
  "creditAccount": 3200,
  "amount": 12050,
  "currency": "CHF",
  "taxCode": "UN81"
}
```


## OpenAPI

````yaml POST /v1/ledger-entries
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:
    post:
      tags: []
      summary: Post a ledger entry
      description: Creates a new single ledger entry that is posted as a new transaction.
      operationId: post-unreviewed-ledger-entry-v1
      requestBody:
        content:
          application/json:
            schema:
              type: object
              x-examples:
                Example 1:
                  date: '2025-01-01'
                  description: Einnahme von 120.50 CHF
                  debitAccount: 1020
                  creditAccount: 3200
                  amount: 12050
                  currency: CHF
                  taxCode: UN81
              required:
                - date
                - description
                - debitAccount
                - creditAccount
                - amount
              properties:
                date:
                  type: string
                  description: >-
                    The date of the ledger entry in YYYY-MM-DD format.


                    The transaction date must be within an editable period (e.g.
                    adding transactions in a closed VAT period or outside of an
                    open fiscal year is not allowed).
                  format: date
                  example: '2025-01-30'
                description:
                  type: string
                  description: The single-line text line for the ledger entry.
                  maxLength: 128
                  minLength: 1
                debitAccount:
                  type: integer
                  description: >-
                    The account number of the debit account of this ledger
                    entry. An account with this account number must exist to
                    post the transaction.
                  minimum: 1000
                  maximum: 9999
                creditAccount:
                  type: integer
                  minimum: 1000
                  maximum: 9999
                  description: >-
                    The account number of the credit account of this ledger
                    entry. An account with this account number must exist to
                    post the transaction.
                amount:
                  type: integer
                  minimum: 1
                  example: 12030
                  description: The gross transaction amount in cents (e.g. 12030 = 120.30).
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                  description: >-
                    The 3-character alphanumeric currency code (ISO 4217) for
                    the amount of this transaction. Must be a currency code of a
                    currency that is enabled in this organisation. Defaults to
                    the primary accounting currency of Infinity, which currently
                    is always `CHF`.
                  default: CHF
                  example: EUR
                exchangeRate:
                  type: number
                  x-stoplight:
                    id: lub9vdj2vfhuv
                  description: >-
                    A decimal number representing the conversion rate as the
                    rate of the foreign basis unit = X CHF. For example, the
                    exchange rate is 0.98 for Euro if 1 EUR = 0.98 CHF. Not
                    allowed to be zero or negative.


                    If not provided, defaults to the applicable exchange rate
                    set for the currency in Infinity.
                  exclusiveMinimum: 0
                taxCode:
                  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
                  description: >-
                    The VAT tax code applicable for this ledger entry. Based on
                    the provided tax code, the ledger entry will be
                    appropriately split into a net amount transaction and a VAT
                    debt transaction.


                    If unset, null, or "", no VAT will be applied to this
                    transaction.


                    See [“Liste der
                    MWST-Codes“](https://docs.infinity.swiss/de/docs/accounting/vat/tax-codes)
                    for details.
                  example: UN81
        description: Provide a single ledger entry to create.
      responses:
        '201':
          description: Transactions for this ledger entry were posted successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - transactions
                properties:
                  transactions:
                    type: array
                    x-stoplight:
                      id: 25yr2nmcyxeyg
                    description: >-
                      The transactions that were created for this ledger entry.
                      For transactions with VAT, this may include more than one
                      booking.
                    items:
                      $ref: '#/components/schemas/Transaction'
                      x-stoplight:
                        id: foo4llmjw95hu
        '400':
          description: >-
            A bad request is thrown if the provided ledger entry payload is
            invalid.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                properties:
                  code:
                    type: string
                    x-stoplight:
                      id: mn0l8j4nbiqtl
                    description: |-
                      The specific error code for this request.
                      May be:
                      - `general/missing-fields`
                      - `general/malformed-request`
                      - `general/zero-or-negative-amount-not-allowed`
                      - `general/negative-amount-not-allowed`
                      - `general/invalid-date`
                      - `general/input-too-long`
                  invalidFields:
                    type: array
                    x-stoplight:
                      id: grq90gsll1pvg
                    uniqueItems: true
                    description: A list of the fields which were invalid, if applicable.
                    items:
                      x-stoplight:
                        id: lxm92y2xhucrj
                      type: string
                      example: description
        '401':
          $ref: '#/components/responses/Unauthorised'
        '403':
          description: >-
            A forbidden error is thrown when posting this ledger entry is
            disallowed.
          headers: {}
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    x-stoplight:
                      id: yctwlfywky9e3
                    description: >-
                      The specific error code for this request.


                      The following errors may be thrown if the transaction date
                      is outside of a valid, editable fiscal year:

                      - `fiscal-year/not-found`

                      - `fiscal-year/closed`


                      The following error may be thrown if the transaction date
                      falls within a non-editable VAT period:

                      - `vat-period/closed`


                      The following errors may be thrown in cases where the tax
                      code can not be applied correctly:

                      - `vat/invalid-tax-code`

                      - `vat/no-tax-applicable-account`
        '404':
          description: >-
            A 404 error may be received when attempting to book to accounts
            which do not exist in the relevant fiscal year.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    x-stoplight:
                      id: a9im42ie7thqq
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `ledger/account-not-found`
components:
  schemas:
    Transaction:
      title: Transaction
      x-stoplight:
        id: 97x99tpfjv229
      type: object
      description: A transaction represents an accounting journal entry in the ledger.
      required:
        - id
        - date
        - debitAccount
        - creditAccount
        - description
        - amount
        - grossAmount
        - currency
      properties:
        id:
          type: string
          x-stoplight:
            id: zna9nqtheh70f
          description: A unique hex identifier for the transaction.
          example: 682338d9e9500b3ffe4baa5a
        date:
          type: string
          x-stoplight:
            id: rkpedcuqf5lqb
          description: The date for this transaction in YYYY-MM-DD format.
          format: date
          example: '2025-01-30'
        debitAccount:
          type: number
          x-stoplight:
            id: b0pwai5xgtruy
          minimum: 1000
          maximum: 9999
          description: The debit account number of this transaction.
          example: 1020
        creditAccount:
          type: number
          x-stoplight:
            id: ixoe9xvblw663
          description: The credit account number of this transaction.
          minimum: 1000
          maximum: 9999
          default: 3200
        description:
          type: string
          x-stoplight:
            id: z0x8ej74aecpd
          description: The single text-line description for this transaction.
          example: Einnahme aus Dienstleistungsverkauf
        amount:
          type: number
          x-stoplight:
            id: 4wmruda6gj23q
          example: 10050
          exclusiveMinimum: 0
          description: >-
            The net amount of this transaction in cents (e.g. 10050 = 100.50).


            If the transaction is a foreign currency transaction, this amount
            will be the converted amount in the primary currency.
        grossAmount:
          type: number
          x-stoplight:
            id: z7iyg6hnsr8ut
          description: >-
            The gross amount of this transaction in cents. Includes the VAT debt
            from its associated VAT transaction.


            For transactions without VAT, the gross amount is the same as the
            amount.
        currency:
          type: string
          x-stoplight:
            id: ksabekdr3unfk
          example: CHF
          minLength: 3
          maxLength: 3
          description: >-
            The 3-character alphanumeric currency code (ISO 4217) for the
            **converted amount** of this transaction.
        originalAmount:
          type: number
          x-stoplight:
            id: 958ry5vbzfkam
          exclusiveMinimum: 0
          description: >-
            Available for foreign currency transactions. This is the original
            gross amount of this transaction in cents (e.g. 10050 = 100.50) **in
            the original currency**.
        originalCurrency:
          type: string
          x-stoplight:
            id: igganf0t26o08
          description: >-
            The 3-character alphanumeric currency code (ISO 4217) for the
            **original amount** of this transaction.
        taxCode:
          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
          x-stoplight:
            id: bvikykcvio5vw
          description: >-
            The VAT tax code used for the ledger entry of this transaction. Will
            be set for both the net transaction and the VAT debt transaction.
  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.

````