# Generate an XRechnung invoice from JSON

**Use case:** 

Turns one invoice in plain JSON into XRechnung 3.0.2 XML, in both UBL and CII syntax, and validates each file with the official KoSIT rules before returning it. Line amounts, the VAT breakdown and the totals are computed for you. Download the XML files from the run's key-value store. From $0.03 per document, less on paid plans, so about $0.06 here.

## Input

```json
{
  "operation": "generate",
  "documents": [
    {
      "name": "RE-2026-0001-ubl",
      "invoice": {
        "number": "2026-0001",
        "issueDate": "2026-09-01",
        "dueDate": "2026-10-01",
        "typeCode": "380",
        "currency": "EUR",
        "buyerReference": "04011000-12345-03",
        "deliveryDate": "2026-08-31",
        "seller": {
          "name": "Nordlicht Elektrotechnik GmbH",
          "vatId": "DE123456789",
          "electronicAddress": {
            "value": "rechnung@nordlicht-elektro.example",
            "schemeId": "EM"
          },
          "address": {
            "line1": "Werftstrasse 14",
            "city": "Kiel",
            "postcode": "24143",
            "country": "DE"
          },
          "contact": {
            "name": "Buchhaltung",
            "phone": "+49 431 1234567",
            "email": "rechnung@nordlicht-elektro.example"
          }
        },
        "buyer": {
          "name": "Stadtwerke Musterstadt AoeR",
          "vatId": "DE987654321",
          "electronicAddress": {
            "value": "erechnung@musterstadt.example",
            "schemeId": "EM"
          },
          "address": {
            "line1": "Rathausplatz 1",
            "city": "Musterstadt",
            "postcode": "12345",
            "country": "DE"
          }
        },
        "payment": {
          "meansCode": "58",
          "iban": "DE79000000001234567890",
          "terms": "Zahlbar innerhalb von 30 Tagen ohne Abzug."
        },
        "lines": [
          {
            "name": "Schaltschrankmontage",
            "quantity": 12,
            "unitCode": "HUR",
            "unitPrice": "78.50",
            "vat": {
              "categoryCode": "S",
              "rate": 19
            }
          }
        ]
      }
    },
    {
      "name": "RE-2026-0001-cii",
      "profile": "xrechnung-cii",
      "invoice": {
        "number": "2026-0001",
        "issueDate": "2026-09-01",
        "dueDate": "2026-10-01",
        "typeCode": "380",
        "currency": "EUR",
        "buyerReference": "04011000-12345-03",
        "deliveryDate": "2026-08-31",
        "seller": {
          "name": "Nordlicht Elektrotechnik GmbH",
          "vatId": "DE123456789",
          "electronicAddress": {
            "value": "rechnung@nordlicht-elektro.example",
            "schemeId": "EM"
          },
          "address": {
            "line1": "Werftstrasse 14",
            "city": "Kiel",
            "postcode": "24143",
            "country": "DE"
          },
          "contact": {
            "name": "Buchhaltung",
            "phone": "+49 431 1234567",
            "email": "rechnung@nordlicht-elektro.example"
          }
        },
        "buyer": {
          "name": "Stadtwerke Musterstadt AoeR",
          "vatId": "DE987654321",
          "electronicAddress": {
            "value": "erechnung@musterstadt.example",
            "schemeId": "EM"
          },
          "address": {
            "line1": "Rathausplatz 1",
            "city": "Musterstadt",
            "postcode": "12345",
            "country": "DE"
          }
        },
        "payment": {
          "meansCode": "58",
          "iban": "DE79000000001234567890",
          "terms": "Zahlbar innerhalb von 30 Tagen ohne Abzug."
        },
        "lines": [
          {
            "name": "Schaltschrankmontage",
            "quantity": 12,
            "unitCode": "HUR",
            "unitPrice": "78.50",
            "vat": {
              "categoryCode": "S",
              "rate": 19
            }
          }
        ]
      }
    }
  ],
  "profile": "xrechnung-ubl",
  "pdfProfile": "facturx-xrechnung",
  "language": "en"
}
```

## Output

```json
{
  "name": {
    "label": "File name",
    "format": "string"
  },
  "operation": {
    "label": "Operation",
    "format": "string"
  },
  "result.fileKey": {
    "label": "Key of the generated file in the key value store",
    "format": "string"
  },
  "result.xmlFileKey": {
    "label": "Key of the generated XML, for generate-pdf",
    "format": "string"
  },
  "result.bytes": {
    "label": "Size of the generated file",
    "format": "integer"
  },
  "result.sha256": {
    "label": "sha256 of the generated file",
    "format": "string"
  },
  "result.profile": {
    "label": "Matched profile",
    "format": "string"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The XRechnung Validator and Generator (EN 16931) Actor is ready to run with the inputs already set for "Generate an XRechnung invoice from JSON". [Sign up or log in](https://console.apify.com/create-task-from-example/xsSr4JRxgPsbHyXi9) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "Generate an XRechnung invoice from JSON" task

The XRechnung Validator and Generator (EN 16931) Actor will start running based on the input automatically. You can also change all the input fields, like operation, documents, and more, to match your specific use case.

### 3. Receive the "Generate an XRechnung invoice from JSON" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as file name, operation, key of the generated file in the key value store, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "Generate an XRechnung invoice from JSON" task via API](https://apify.com/omargnagy/einvoice-en16931.md).

## About this Actor

This example demonstrates how to use [XRechnung Validator and Generator (EN 16931)](https://apify.com/omargnagy/einvoice-en16931.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/omargnagy/einvoice-en16931.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/omargnagy/einvoice-en16931.md

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).
