# Check XRechnung invoices with the official KoSIT rules

**Use case:** 

Validates three XRechnung 3.0.2 invoices with the official KoSIT validator: a valid UBL invoice, a valid CII invoice and one with a wrong amount due. Each row says whether the invoice is valid and lists every failing rule ID (here BR-CO-16) with its message and XPath. Swap in your own URLs, XML or PDFs. From $0.02 per document, less on paid plans, so about $0.06 here.

## Input

```json
{
  "operation": "validate",
  "documents": [
    {
      "name": "xrechnung-ubl-valid.xml",
      "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/v2026-08-31/src/test/business-cases/standard/01.01a-INVOICE_ubl.xml"
    },
    {
      "name": "xrechnung-cii-valid.xml",
      "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/v2026-08-31/src/test/business-cases/standard/01.01a-INVOICE_uncefact.xml"
    },
    {
      "name": "wrong-amount-due.xml",
      "xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ubl:Invoice xmlns:ubl=\"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2\"\n             xmlns:cac=\"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2\"\n             xmlns:cbc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\">\n    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</cbc:CustomizationID>\n    <cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>\n    <cbc:ID>123456XX</cbc:ID>\n    <cbc:IssueDate>2016-04-04</cbc:IssueDate>\n    <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>\n    <cbc:Note>#ADU#Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden.</cbc:Note>\n    <cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>\n    <cbc:BuyerReference>04011000-12345-03</cbc:BuyerReference>\n    <cac:AccountingSupplierParty>\n        <cac:Party>\n            <cbc:EndpointID schemeID=\"EM\">seller@email.de</cbc:EndpointID>\n            <cac:PartyName>\n                <cbc:Name>[Seller trading name]</cbc:Name>\n            </cac:PartyName>\n            <cac:PostalAddress>\n                <cbc:StreetName>[Seller address line 1]</cbc:StreetName>\n                <cbc:CityName>[Seller city]</cbc:CityName>\n                <cbc:PostalZone>12345</cbc:PostalZone>\n                <cac:Country>\n                    <cbc:IdentificationCode>DE</cbc:IdentificationCode>\n                </cac:Country>\n            </cac:PostalAddress>\n            <cac:PartyTaxScheme>\n                <cbc:CompanyID>DE 123456789</cbc:CompanyID>\n                <cac:TaxScheme>\n                    <cbc:ID>VAT</cbc:ID>\n                </cac:TaxScheme>\n            </cac:PartyTaxScheme>\n            <cac:PartyLegalEntity>\n                <cbc:RegistrationName>[Seller name]</cbc:RegistrationName>\n                <cbc:CompanyID>[HRA-Eintrag]</cbc:CompanyID>\n                <cbc:CompanyLegalForm>123/456/7890, HRA-Eintrag in […]</cbc:CompanyLegalForm>\n            </cac:PartyLegalEntity>\n            <cac:Contact>\n                <cbc:Name>nicht vorhanden</cbc:Name>\n                <cbc:Telephone>+49 1234-5678</cbc:Telephone>\n                <cbc:ElectronicMail>seller@email.de</cbc:ElectronicMail>\n            </cac:Contact>\n        </cac:Party>\n    </cac:AccountingSupplierParty>\n    <cac:AccountingCustomerParty>\n        <cac:Party>\n            <cbc:EndpointID schemeID=\"EM\">buyer@info.de</cbc:EndpointID>\n            <cac:PartyIdentification>\n                <cbc:ID>[Buyer identifier]</cbc:ID>\n            </cac:PartyIdentification>\n            <cac:PostalAddress>\n                <cbc:StreetName>[Buyer address line 1]</cbc:StreetName>\n                <cbc:CityName>[Buyer city]</cbc:CityName>\n                <cbc:PostalZone>12345</cbc:PostalZone>\n                <cac:Country>\n                    <cbc:IdentificationCode>DE</cbc:IdentificationCode>\n                </cac:Country>\n            </cac:PostalAddress>\n            <cac:PartyLegalEntity>\n                <cbc:RegistrationName>[Buyer name]</cbc:RegistrationName>\n            </cac:PartyLegalEntity>\n        </cac:Party>\n    </cac:AccountingCustomerParty>\n    <cac:PaymentMeans>\n        <cbc:PaymentMeansCode>58</cbc:PaymentMeansCode>\n        <cac:PayeeFinancialAccount>\n            <!-- dies ist eine nicht existerende aber valide IBAN als test dummy -->\n            <cbc:ID>DE79000000001234567890</cbc:ID>\n        </cac:PayeeFinancialAccount>\n    </cac:PaymentMeans>\n    <cac:PaymentTerms>\n        <cbc:Note>Zahlbar sofort ohne Abzug.</cbc:Note>\n    </cac:PaymentTerms>\n    <cac:TaxTotal>\n        <cbc:TaxAmount currencyID=\"EUR\">22.04</cbc:TaxAmount>\n        <cac:TaxSubtotal>\n            <cbc:TaxableAmount currencyID=\"EUR\">314.86</cbc:TaxableAmount>\n            <cbc:TaxAmount currencyID=\"EUR\">22.04</cbc:TaxAmount>\n            <cac:TaxCategory>\n                <cbc:ID>S</cbc:ID>\n                <cbc:Percent>7</cbc:Percent>\n                <cac:TaxScheme>\n                    <cbc:ID>VAT</cbc:ID>\n                </cac:TaxScheme>\n            </cac:TaxCategory>\n        </cac:TaxSubtotal>\n    </cac:TaxTotal>\n    <cac:LegalMonetaryTotal>\n        <cbc:LineExtensionAmount currencyID=\"EUR\">314.86</cbc:LineExtensionAmount>\n        <cbc:TaxExclusiveAmount currencyID=\"EUR\">314.86</cbc:TaxExclusiveAmount>\n        <cbc:TaxInclusiveAmount currencyID=\"EUR\">336.9</cbc:TaxInclusiveAmount>\n        <cbc:PayableAmount currencyID=\"EUR\">999.99</cbc:PayableAmount>\n    </cac:LegalMonetaryTotal>\n    <cac:InvoiceLine>\n        <cbc:ID>Zeitschrift [...]</cbc:ID>\n        <cbc:Note>Die letzte Lieferung im Rahmen des abgerechneten Abonnements erfolgt in 12/2016 Lieferung erfolgt / erfolgte direkt vom Verlag</cbc:Note>\n        <cbc:InvoicedQuantity unitCode=\"XPP\">1</cbc:InvoicedQuantity>\n        <cbc:LineExtensionAmount currencyID=\"EUR\">288.79</cbc:LineExtensionAmount>\n        <cac:InvoicePeriod>\n            <cbc:StartDate>2016-01-01</cbc:StartDate>\n            <cbc:EndDate>2016-12-31</cbc:EndDate>\n        </cac:InvoicePeriod>\n        <cac:OrderLineReference>\n            <cbc:LineID>6171175.1</cbc:LineID>\n        </cac:OrderLineReference>\n        <cac:Item>\n            <cbc:Description>Zeitschrift Inland</cbc:Description>\n            <cbc:Name>Zeitschrift [...]</cbc:Name>\n            <cac:SellersItemIdentification>\n                <cbc:ID>246</cbc:ID>\n            </cac:SellersItemIdentification>\n            <cac:CommodityClassification>\n                <cbc:ItemClassificationCode listID=\"IB\">0721-880X</cbc:ItemClassificationCode>\n            </cac:CommodityClassification>\n            <cac:ClassifiedTaxCategory>\n                <cbc:ID>S</cbc:ID>\n                <cbc:Percent>7</cbc:Percent>\n                <cac:TaxScheme>\n                    <cbc:ID>VAT</cbc:ID>\n                </cac:TaxScheme>\n            </cac:ClassifiedTaxCategory>\n        </cac:Item>\n        <cac:Price>\n            <cbc:PriceAmount currencyID=\"EUR\">288.79</cbc:PriceAmount>\n        </cac:Price>\n    </cac:InvoiceLine>\n    <cac:InvoiceLine>\n        <cbc:ID>Porto + Versandkosten</cbc:ID>\n        <cbc:InvoicedQuantity unitCode=\"XPP\">1</cbc:InvoicedQuantity>\n        <cbc:LineExtensionAmount currencyID=\"EUR\">26.07</cbc:LineExtensionAmount>\n        <cac:Item>\n            <cbc:Name>Porto + Versandkosten</cbc:Name>\n            <cac:ClassifiedTaxCategory>\n                <cbc:ID>S</cbc:ID>\n                <cbc:Percent>7</cbc:Percent>\n                <cac:TaxScheme>\n                    <cbc:ID>VAT</cbc:ID>\n                </cac:TaxScheme>\n            </cac:ClassifiedTaxCategory>\n        </cac:Item>\n        <cac:Price>\n            <cbc:PriceAmount currencyID=\"EUR\">26.07</cbc:PriceAmount>\n        </cac:Price>\n    </cac:InvoiceLine>\n</ubl:Invoice>\n"
    }
  ],
  "profile": "xrechnung-ubl",
  "pdfProfile": "facturx-xrechnung",
  "language": "en"
}
```

## Output

```json
{
  "name": {
    "label": "File name",
    "format": "string"
  },
  "operation": {
    "label": "Operation",
    "format": "string"
  },
  "ok": {
    "label": "Processed without an error",
    "format": "boolean"
  },
  "result.valid": {
    "label": "Passed every rule",
    "format": "boolean"
  },
  "result.profile": {
    "label": "Matched profile",
    "format": "string"
  },
  "result.syntax": {
    "label": "UBL or CII",
    "format": "string"
  },
  "result.durationMs": {
    "label": "Validation time in milliseconds",
    "format": "integer"
  },
  "error.code": {
    "label": "Error",
    "format": "string"
  },
  "charged": {
    "label": "Billed as one event on this run. False for errors and for documents that were not evaluated (no_matching_scenario, no_embedded_invoice)",
    "format": "boolean"
  }
}
```

## 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 "Check XRechnung invoices with the official KoSIT rules". [Sign up or log in](https://console.apify.com/create-task-from-example/rOjThX8lfzhLgJUp0) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "Check XRechnung invoices with the official KoSIT rules" 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 "Check XRechnung invoices with the official KoSIT rules" 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, processed without an error, 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 "Check XRechnung invoices with the official KoSIT rules" 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`).
