Skip to main content
POST
Post a ledger entry

Creating a new ledger entry

For example, the following payload will create a new ledger entry for the amount of CHF 120.50, with the VAT booked alongside it because of the UN81 tax code:
The taxCode accepts the statutory tax codes as well as the organisation’s own simplified codes (Saldosteuersatz) such as SS53, and the empty string for an entry without VAT. Use list available tax codes to find out which codes the organisation can use on a given date. The response contains the posted entry as ledgerEntry, in the same shape as when you find ledger entries — including its id, and its vat object with the VAT amount and accounts that were booked. The individual transactions behind the entry are not listed separately.

Foreign currency entries

To post an entry in another currency, send amount in that currency and set currency accordingly. The currency has to be enabled in the organisation. Infinity converts the amount to CHF, and the entry returned in the response reports the original amount in its fx object. You can either give the exchange rate as the value of one unit of the foreign currency in CHF:
Or you can give the CHF amount that should be booked as baseAmount, for example the amount your bank actually credited. Infinity then derives the exchange rate from it:
  • If neither is given, the exchange rate set for the currency in Infinity on that date is used.
  • Sending exchangeRate and baseAmount together is rejected with 400 Bad Request and the error code general/missing-fields, listing both fields in invalidFields.
  • Sending baseAmount for an entry in CHF is rejected the same way, listing baseAmount.

Retrying safely with idempotency keys

If a request fails or times out, you may not know whether the ledger entry was posted. To retry safely without creating duplicate bookings, provide a unique Idempotency-Key header (for example a UUID) with your request:
When you retry a request with the same key and payload, the API returns the status and response of the original request – including the ledger entry it posted – instead of posting the entry again.
  • Keys are scoped to your organisation and API key.
  • Keys are retained for 24 hours. After that, a key can be used again and will post a new entry.
  • Reusing a key with a different payload returns 409 Conflict with error code rest-api/idempotency-key-payload-mismatch.
  • While a request is still being processed, concurrent requests with the same key return 409 Conflict with error code rest-api/idempotency-key-request-in-progress.
  • If a request fails, its key is released, so the same key can be used to retry.
Generate a new idempotency key for every new ledger entry, and reuse it only when retrying the same request.

Authorizations

x-api-token
string
header
required

API token for authentication. Obtain from your Infinity account settings.

Headers

Idempotency-Key
string

A unique key that makes this request idempotent, for example a UUID. If a request fails or times out, it can safely be retried with the same key without creating a duplicate: a retry with the same key and payload returns the status and response of the original request, including the resource it created.

Keys are scoped to your organisation and API key, and are retained for 24 hours. Reusing a key with a different payload returns 409 Conflict. While a request is still being processed, other requests with the same key also return 409 Conflict.

Required string length: 1 - 200

Body

application/json

Provide a single ledger entry to create.

date
string<date>
required

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

Example:

"2025-01-30"

description
string
required

The single-line text line for the ledger entry.

Required string length: 1 - 128
debitAccount
integer
required

The account number of the debit account of this ledger entry. An account with this account number must exist to post the transaction.

Required range: 1000 <= x <= 9999
creditAccount
integer
required

The account number of the credit account of this ledger entry. An account with this account number must exist to post the transaction.

Required range: 1000 <= x <= 9999
amount
integer
required

The gross transaction amount in cents (e.g. 12030 = 120.30).

Required range: x >= 1
Example:

12030

currency
string
default:CHF

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.

Required string length: 3
Example:

"EUR"

exchangeRate
number

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.

baseAmount
integer

The amount of this ledger entry in CHF, in cents, as an alternative to exchangeRate. The exchange rate is derived from amount and baseAmount, so that exactly this CHF amount is booked.

Only allowed for ledger entries in a foreign currency. Sending baseAmount together with exchangeRate, or sending it for an entry in CHF, is rejected with 400 Bad Request and the error code general/missing-fields.

Required range: x >= 1
Example:

9800

taxCode

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.

Which codes are accepted depends on the VAT settings of the organisation and on the date of the entry. Use GET /v1/tax-codes to list the codes available for a date.

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

See “Liste der MWST-Codes“ for details.

Available options:
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
Example:

"UN81"

Response

The ledger entry was posted successfully.

ledgerEntry
LedgerEntry · object
required

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.