Blog · 2026-12-01 · 7 min read · by Saoud Tamimi
Validating XRechnung and Peppol BIS invoices in CI with the official KoSIT and Schematron rules
If your software produces e-invoices for Germany (XRechnung, ZUGFeRD) or for Peppol countries such as Belgium (Peppol BIS Billing 3.0), you have probably shipped at least one invoice that looked fine in your own tests and was rejected by the receiver. The fix is boring and effective: run the same official validation artefacts the receivers use on every pull request, and fail the build when they say no.
This article shows two ways to do that in CI, both with working code:
- Run the KoSIT validator yourself (Java, fully offline, the reference for XRechnung).
- Use a small GitHub Action / CLI that calls a hosted copy of the same validators, for repos where you don't want a JVM in the pipeline.
At the end are the gotchas that make a green build lie.
What "official" means here
There is no single "e-invoice validator". There are layers:
- Syntax: the UBL 2.1 or UN/CEFACT CII XML schema (XSD).
- EN 16931 business rules: Schematron published by CEN TC 434 and maintained in ConnectingEurope/eInvoicing-EN16931 (rules like
BR-CO-15, totals must add up). - CIUS rules on top: XRechnung adds
BR-DE-*rules (for exampleBR-DE-15, the buyer reference / Leitweg-ID is mandatory), published by KoSIT on xeinkauf.de. Peppol BIS addsPEPPOL-EN16931-*andPEPPOL-COMMON-*rules, published by OpenPeppol at docs.peppol.eu.
The KoSIT validator is a generic engine that runs a configuration: a scenarios.xml that maps a document (by namespace and CustomizationID) to the XSD and Schematron files to apply. KoSIT publishes two configurations that matter here:
- validator-configuration-xrechnung: XRechnung 3.0.x, UBL and CII.
- validator-configuration-bis: Peppol BIS Billing 3.0 (CEN + Peppol Schematron for UBL).
The engine is the same; you pick the configuration that matches the invoices you produce.
Option 1: the KoSIT validator in your pipeline
Fetch pinned versions
Pin exact releases. Rule sets change a few times a year, and you want an upgrade to be a reviewed pull request, not a surprise on a Tuesday.
#!/usr/bin/env bash
# fetch-kosit.sh: download the validator and both configurations into .kosit/
set -euo pipefail
mkdir -p .kosit && cd .kosit
get() { curl -fsSL --retry 3 -o "$1" "$2"; }
get validator.jar https://github.com/itplr-kosit/validator/releases/download/v1.6.3/validator-1.6.3-standalone.jar
get xrechnung.zip https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/v2026-08-31/xrechnung-3.0.2-validator-configuration-2026-08-31.zip
get bis.zip https://github.com/itplr-kosit/validator-configuration-bis/releases/download/release-3.0.21/validation-configuration-bis-3.0.21.zip
unzip -qo xrechnung.zip -d xrechnung
unzip -qo bis.zip -d bis
These were the latest releases when this was written (December 2026). Check the release pages before you copy them, and compare the BIS configuration version with the Peppol BIS version currently in force on docs.peppol.eu.
Run it
# XRechnung (UBL or CII)
java -jar .kosit/validator.jar \
-s .kosit/xrechnung/scenarios.xml -r .kosit/xrechnung \
-o reports fixtures/xrechnung/*.xml
# Peppol BIS Billing 3.0
java -jar .kosit/validator.jar \
-s .kosit/bis/scenarios.xml -r .kosit/bis \
-o reports fixtures/peppol/*.xml
-s is the scenario file, -r the repository the scenario paths are resolved against, -o the output directory for one XML report per input. Add -h if you also want HTML reports to upload as build artefacts. The process exits with 0 when every file is acceptable and 1 when at least one is rejected, which is all CI needs.
A valid file prints:
|fixtures/xrechnung/RE-2026-0042.xml | Y | Y |ACCEPTABLE| |
Remove the BuyerReference from that invoice and you get the classic German rejection:
|missing-buyer-reference.xml | Y | N | REJECT |[BR-DE-15] ... |
Acceptable: 0 Rejected: 1
And for Peppol, a Belgian enterprise number with a wrong check digit in EndpointID schemeID="0208":
|INV-BE-0007.xml | Y | N | REJECT |[PEPPOL-COMMON-R043]-Belgian enterprise number MUST be stated in the correct format.
The GitHub Actions workflow
# .github/workflows/e-invoices.yml
name: e-invoices
on: [pull_request]
jobs:
kosit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: actions/cache@v4
with:
path: .kosit
key: kosit-1.6.3-xr-2026-08-31-bis-3.0.21
- name: Fetch validator
run: test -f .kosit/validator.jar || bash scripts/fetch-kosit.sh
- name: Generate invoices from fixtures
run: make invoices # your own build step writes XML to out/
- name: Validate XRechnung
run: java -jar .kosit/validator.jar -s .kosit/xrechnung/scenarios.xml -r .kosit/xrechnung -o reports -h out/de/*.xml
- name: Validate Peppol BIS
run: java -jar .kosit/validator.jar -s .kosit/bis/scenarios.xml -r .kosit/bis -o reports -h out/be/*.xml
- uses: actions/upload-artifact@v4
if: always()
with:
name: validation-reports
path: reports/
The cache key contains every pinned version, so bumping one version invalidates the cache. The if: always() on the upload matters: you want the reports most when the job failed.
Validate what you generate, not just hand-made fixtures. The useful test is "our code produced this XML from this order, and the receiver's rules accept it". Keep a handful of representative orders (domestic, reverse charge, mixed VAT rates, credit note, discounts at document level) and render them in CI.
Option 2: no JVM, using the CLI or GitHub Action
Sometimes you can't or don't want to run Java in a pipeline: a Python or Node monorepo, a small service, or a repo where only a few XML fixtures change. For that I maintain valifakt-cli (MIT) and the validate-einvoice Action. They send the file to a hosted service that runs the same KoSIT XRechnung configuration and the CEN/Peppol Schematron, and they return the rule IDs. Validation is free, needs no account and is rate-limited per minute.
# .github/workflows/e-invoices.yml (no Java)
name: e-invoices
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: saoudaltamimi/validate-einvoice@v1
with:
files: |
fixtures/**/*.xml
mode: online-fallback # offline pre-flight checks if the API is unreachable
Failures appear as annotations on the pull request (::error file=…,title=BR-DE-15::…), and the step's result output is valid or invalid.
The same thing from a shell, for local runs or other CI systems:
pip install "valifakt-cli @ git+https://github.com/saoudaltamimi/valifakt-cli@v0.1.1"
valifakt validate fixtures/xrechnung/*.xml fixtures/must-fail/*.xml
OK fixtures/xrechnung/RE-2026-0042.xml [xrechnung-ubl · kosit] 0 error(s), 0 warning(s)
FAIL fixtures/must-fail/missing-buyer-reference.xml [xrechnung-ubl · kosit] 1 error(s), 0 warning(s)
✗ BR-DE-15: "Buyer reference" (BT-10) muss übermittelt werden.
Exit codes are 0 valid, 1 invalid, 2 usage or network error, so a flaky network doesn't look like a broken invoice. -o github prints annotations and -o json gives you something to post-process.
Privacy trade-off. Online mode uploads the XML (to a server in Germany, deleted after processing). Invoice fixtures are usually synthetic, but if your CI renders real customer data, use Option 1 or mode: offline. Offline mode checks the KSeF FA(3) XSD and, for UBL/CII, the mandatory EN 16931 terms, the totals arithmetic and BR-DE-15. It is a pre-flight check, not the full Schematron.
Gotchas that make a green build lie
1. Wrong configuration, silent mismatch. KoSIT picks a scenario by matching the document. Feed an XRechnung file to the BIS configuration and it is rejected with no rule ID at all, because no scenario matched. The reverse also happens: an invoice with a Peppol CustomizationID sent to a German public buyer is checked against the wrong rules. Assert the CustomizationID you emit in a unit test:
from lxml import etree
NS = {"cbc": "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"}
XRECHNUNG = "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"
PEPPOL = "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0"
def customization_id(path):
return etree.parse(path).findtext("cbc:CustomizationID", namespaces=NS)
assert customization_id("out/de/RE-2026-0042.xml") == XRECHNUNG
assert customization_id("out/be/INV-BE-0007.xml") == PEPPOL
2. Warnings are not nothing. Some rules have flag="warning", and receivers sometimes treat them as errors. Decide on purpose: either fail on warnings (--fail-on-warnings in the CLI, fail-on-warnings: true in the Action), or parse the KoSIT report and keep a short allow-list.
3. Schema valid is not valid. A file that passes the XSD can still break a dozen business rules: rounding in BR-CO-10 (sum of line net amounts), VAT breakdown per category in BR-CO-17, and so on. Never stop at the XSD.
4. Unpinned rule sets. "Download latest" in CI means the build turns red the morning a new rule set is published, on a commit that didn't touch invoicing. Pin, and bump on purpose.
5. ZUGFeRD is a PDF. The validators above check the XML. For ZUGFeRD / Factur-X you also need the embedded XML to be extracted correctly and the PDF to be PDF/A-3. Validate the extracted factur-x.xml with the XRechnung or EN 16931 configuration, and run a PDF/A check separately if you produce the PDF.
6. Test the negative path. Keep one deliberately broken fixture per rule you care about and assert that it fails. Otherwise a misconfigured step that validates zero files passes forever.
# the broken fixture must be rejected, or the pipeline is not testing anything
if java -jar .kosit/validator.jar -s .kosit/xrechnung/scenarios.xml -r .kosit/xrechnung -o reports fixtures/must-fail/missing-buyer-reference.xml; then
echo "expected a rejection" && exit 1
fi
Summary
- For XRechnung, the KoSIT validator plus the XRechnung configuration is the reference. Run it in CI with pinned versions.
- For Peppol BIS, use the same engine with KoSIT's BIS configuration, or the OpenPeppol Schematron directly.
- If you don't want Java in the pipeline, the CLI and Action give you the same rule IDs with a one-line setup.
- Assert the
CustomizationID, keep failing fixtures, and decide what to do about warnings.
The commands, flags and outputs above are on the Valifakt API, CLI and GitHub Action reference page.
Disclosure: I build Valifakt, the hosted validator behind the CLI and Action mentioned in Option 2. This article was drafted with AI assistance and every command and output was run and checked by me before publishing.
Guides on valifakt.com
- Valifakt API
- XRechnung Validator online kostenlos
- Peppol validator online (free): check a Peppol BIS 3.0 invoice
- Peppol BIS 3.0 validation errors
- ZUGFeRD vs XRechnung: which e-invoice format do you need?