Skip to main content
POST
/
v1
/
invoices
Create invoice
curl --request POST \
  --url https://api.infinity.swiss/v1/invoices \
  --header 'Content-Type: application/json' \
  --header 'x-api-token: <api-key>' \
  --data '
{
  "template": "<string>",
  "openingDate": "2023-12-25",
  "positions": [
    {
      "name": "<string>",
      "singleAmount": 12000,
      "quantity": 2,
      "contraAccount": 5499,
      "unit": "<string>",
      "articleNumber": "<string>",
      "description": "<string>",
      "date": "<string>",
      "discountRate": 50,
      "customTextColumns": {
        "customTextColumn1": "<string>",
        "customTextColumn2": "<string>",
        "customTextColumn3": "<string>"
      }
    }
  ],
  "isDraft": true,
  "recipient": "<string>",
  "customRecipientText": "<string>",
  "title": "<string>",
  "payableInDays": 182,
  "introductoryText": "<string>",
  "closingText": "<string>",
  "columns": [],
  "originalCurrency": "<string>",
  "exchangeRate": 123,
  "isQrInvoice": true
}
'
{
  "invoice": {
    "id": "<string>",
    "isDraft": true,
    "number": "<string>",
    "organisation": "<string>",
    "template": "<string>",
    "openingDate": "2023-12-25",
    "dueDate": "2023-12-25",
    "positions": [
      {
        "name": "<string>",
        "singleAmount": 12000,
        "quantity": 2,
        "contraAccount": 5499,
        "id": "<string>",
        "unit": "<string>",
        "articleNumber": "<string>",
        "description": "<string>",
        "date": "<string>",
        "discountRate": 50,
        "customTextColumns": {
          "customTextColumn1": "<string>",
          "customTextColumn2": "<string>",
          "customTextColumn3": "<string>"
        },
        "totalAmount": 123,
        "vatDebt": 123,
        "originalCurrency": "<string>",
        "exchangeRate": 123
      }
    ],
    "totalAmount": 123,
    "totalNetAmount": 123,
    "totalVatDebt": 123,
    "isQrInvoice": true,
    "totalAmountPaid": 123,
    "totalRestAmount": 123,
    "isPaid": true,
    "isOverpaid": true,
    "isAnnulled": true,
    "recipient": "<string>",
    "customRecipientText": "<string>",
    "title": "<string>",
    "payableInDays": 123,
    "introductoryText": "<string>",
    "closingText": "<string>",
    "originalCurrency": "<string>",
    "exchangeRate": 123,
    "columns": [],
    "emailDeliveries": [
      {
        "recipientEmail": "jsmith@example.com",
        "status": "<string>",
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ],
    "publicPdfUrl": "<string>"
  }
}

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.

Creating a customer invoice

Invoices belong to a template and are addressed to a contact (or a free-text recipient). They are made up of an ordered list of positions, each of which has a discriminator type:
  • product — a standard billable line with a quantity, singleAmount, and contraAccount
  • discount — reduces the preceding positions, by either a percentage or an absolute amount (exactly one of the two must be set)
  • text — a non-billable text line
  • subtotal — renders the running subtotal of the preceding positions

Draft vs. posted

The isDraft flag controls whether the new invoice is posted immediately:
  • isDraft: true — saves the invoice as a draft. No accounting transactions are created.
  • isDraft: false — posts the invoice and creates the underlying transactions on openingDate. The transaction date must fall within an editable fiscal year and VAT period.

Foreign-currency invoices

To issue an invoice in a non-primary currency, provide both originalCurrency (3-character ISO 4217 code) and exchangeRate. The currency must already be enabled in the organisation, and the rate is expressed as 1 originalCurrency = X primaryCurrency (e.g. 0.98 if 1 EUR = 0.98 CHF). The two fields must always be set together or omitted together.

Example

The following payload creates a posted CHF invoice with two product lines and a 10% discount:
{
  "template": "6474bb0cccc5b63aae56fa15",
  "openingDate": "2026-05-12",
  "recipient": "6474bb0cccc5b63aae56fa20",
  "title": "Beratungsleistungen Mai 2026",
  "isDraft": false,
  "payableInDays": 30,
  "amountMode": "gross",
  "language": "de",
  "positions": [
    {
      "type": "product",
      "name": "Beratung",
      "quantity": 4,
      "unit": "h",
      "singleAmount": 18000,
      "contraAccount": 3200,
      "taxCode": "UN81"
    },
    {
      "type": "product",
      "name": "Workshop-Vorbereitung",
      "quantity": 1,
      "singleAmount": 25000,
      "contraAccount": 3200,
      "taxCode": "UN81"
    },
    {
      "type": "discount",
      "percentage": 10,
      "discountText": "Rabatt"
    }
  ]
}

Authorizations

x-api-token
string
header
required

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

Body

application/json

The invoice payload.

Request body for creating a customer invoice.

template
string
required

The id of the invoice template to render the document with.

openingDate
string<date>
required

The opening date (issue date) of the document in YYYY-MM-DD format. For invoices, this is also the date used for the posted accounting transactions.

positions
(ProductPosition · object | DiscountPosition · object | TextPosition · object | SubtotalPosition · object)[]
required

The ordered list of positions on the document. At least one position is required, and discount positions must specify exactly one of percentage or amount.

A standard billable line item with a quantity, single amount, and contra account. Most invoice and estimate positions are of this type.

isDraft
boolean
required

When true the invoice is created in draft state and no transactions are posted. Set to false to immediately post the invoice.

recipient
string

The id of the contact this document is addressed to. Required unless customRecipientText is provided.

customRecipientText
string

An ad-hoc recipient text used when no contact is associated with the document.

Maximum string length: 2000
title
string

Optional document title displayed on the rendered output.

Maximum string length: 128
payableInDays
integer

Payment terms for this document in days from the opening date. Defaults to 30 on create.

Required range: 0 <= x <= 365
introductoryText
string

Text rendered above the positions.

Maximum string length: 2000
closingText
string

Text rendered below the positions.

Maximum string length: 2000
amountMode
enum<string>

Whether position amounts are entered gross (including VAT) or net (excluding VAT).

Available options:
gross,
net
language
enum<string>

The language used to render the document.

Available options:
de,
en,
fr,
it
columns
enum<string>[]

The columns to render in the positions table. If not provided the template default is used.

A column that can be shown on the rendered invoice or estimate.

Available options:
quantity,
unit,
articleNumber,
name,
date,
vatDebt,
vatRate,
singleAmount,
totalAmount,
discountRate,
positionNumber,
customTextColumn1,
customTextColumn2,
customTextColumn3
originalCurrency
string

For foreign-currency documents: the 3-character ISO 4217 currency code the document is denominated in. Must be provided together with exchangeRate. Must be a currency code that is enabled in the organisation.

Required string length: 3
exchangeRate
number

For foreign-currency documents: the conversion rate from the original currency to the primary accounting currency, expressed as 1 originalCurrency = X primaryCurrency. Must be provided together with originalCurrency.

isQrInvoice
boolean

When true the document is rendered as a QR-bill (Swiss QR-Rechnung). Defaults to false.

Response

The invoice was created successfully.

invoice
Invoice · object

The full representation of a customer invoice.