Generate a set of sample invoices in your build, validate each one against the official rules and fail the build when one no longer passes. A template change, a new rounding setting or a library update can break e-invoices without any unit test noticing — until a customer's portal rejects them.
Step 1: Produce sample invoices in the build
Write a small job that creates invoices from fixed test data with your real code: a standard invoice, mixed VAT rates, a credit note, reverse charge, a discount, many lines. Save them into one folder, for example out/invoices.
No test data of your own? POST /v1/testdata returns synthetic invoices for common cases (valid ones and ones that break a known rule each), with the expected result. Generating test data is not billed.
Step 2: Validate every file and fail on errors
The smallest version is a shell loop over the folder. The service detects the format, runs the official rules and returns valid or invalid:
for f in out/invoices/*.xml; do
status=$(curl -s "https://einvoiceengine.com/v1/invoices/validate?store=false&rules=2026-11" \
-H "Authorization: Bearer $EINV_KEY" -H "Content-Type: application/xml" \
--data-binary @"$f" | node -pe 'JSON.parse(require("fs").readFileSync(0)).status')
echo "$status $f"
[ "$status" = "valid" ] || exit 1
done
A test key is enough. rules=2026-11 pins the rule set, so a build is not changed by a new XRechnung release on its own. The full script, including ZUGFeRD PDFs, is in checking invoices in CI.
Step 3: Fail only on new problems
If some invoices already fail today, a strict check blocks every build. Record today's results as a baseline instead and fail only when something gets worse:
node einv-ci.mjs out/invoices --rules 2026-11 --update-baseline --baseline einv-baseline.json
node einv-ci.mjs out/invoices --rules 2026-11 --baseline einv-baseline.json
The first command records the baseline (commit the file). The second fails on a file that passed before, a new file that fails, or a new rule id, and lists files that were fixed. With --summary it writes a Markdown summary for your CI page.
Step 4: Move to a new rule set on purpose
When KoSIT releases a new XRechnung configuration, run --compare-rules latest next to your pinned set. It lists every file whose result would change, so you update your code before you update the pin.
Frequently asked questions
Does this work with GitHub Actions, GitLab CI or Jenkins?
Yes. It is a shell or Node script with an API key from your CI secrets, so it runs anywhere a build runs.
Do CI checks cost money?
Test keys cover CI within your plan's sandbox allowance. Create the key with the scopes ci and validate, so CI checks are recorded separately.
What should the sample invoices cover?
At least every VAT case you invoice (standard, reduced, zero, exempt, reverse charge), credit notes, discounts and charges, and the longest invoice you produce. The synthetic test data covers these cases.
Why not just unit-test the XML?
A unit test checks what you expected the XML to look like. The official rules check what the recipient will check — including rules you did not know about.
E-Invoicing API