DEV Community

PatrickPi1312
PatrickPi1312

Posted on

How to create a valid XRechnung (EN 16931) e-invoice in 5 minutes

E-invoicing is now mandatory across much of the EU (Germany B2B from 2025, Austria e-Rechnung, Peppol EU-wide), and a lot of software suddenly needs to emit a valid XRechnung / Peppol invoice — not a PDF. Here's the shortest path I've found, without becoming an EN 16931 expert.

1. Start from a neutral JSON

You don't hand-write UBL. You describe the invoice in plain JSON and let the API produce the XML:

curl -X POST "https://einvoice.installateur1210.at/v1/einvoice/generate?key=demo" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_number": "AT-2026-001",
    "issue_date": "2026-07-12",
    "currency": "EUR",
    "seller": "My Company GmbH", "seller_country": "AT", "seller_vat": "ATU12345678",
    "buyer": "Client Ltd", "buyer_country": "DE",
    "total_net": 100, "tax_amount": 20, "total_gross": 120, "vat_rate": 20,
    "line_items": [{ "name": "Consulting", "quantity": 1, "line_amount": 100 }]
  }'
Enter fullscreen mode Exit fullscreen mode

The profile field switches the target: peppol (EU-wide, incl. Austria — the default), xrechnung (Germany) or en16931.

2. Prove it's actually compliant

This is the part most home-grown solutions skip. The output above is validated ACCEPTABLE by the official German KoSIT validator (EN 16931 + XRechnung Schematron). You can check any invoice yourself:

curl -X POST "https://einvoice.installateur1210.at/v1/einvoice/validate/official?key=demo" \
  -H "Content-Type: application/xml" --data-binary @invoice.xml
Enter fullscreen mode Exit fullscreen mode

It returns a verdict plus the exact failed business rules (BR-CO-15, BR-DE-…), so you know why something is rejected.

3. Read incoming invoices too — including ZUGFeRD PDFs

Incoming invoices arrive in many shapes. Parse XRechnung (UBL), ZUGFeRD (CII) or Austrian ebInterface into one clean JSON — and yes, you can throw a ZUGFeRD PDF straight in; the embedded XML is extracted for you:

curl -X POST "https://einvoice.installateur1210.at/v1/einvoice/parse?key=demo" \
  -H "Content-Type: application/pdf" --data-binary @zugferd.pdf
Enter fullscreen mode Exit fullscreen mode

4. Convert between formats

Got an Austrian ebInterface file but need Peppol? One call:

curl -X POST "https://einvoice.installateur1210.at/v1/einvoice/convert?to=peppol&key=demo" \
  -H "Content-Type: application/xml" --data-binary @ebinterface.xml
Enter fullscreen mode Exit fullscreen mode

Wrap-up

Free demo key demo (50/day), EU-hosted, no invoice data stored. Full code examples (Node, Python, PHP): https://github.com/PatrickPi1312/xrechnung-api-examples

Not legal or tax advice — but a fast way to stop wrestling with EN 16931 by hand. What format is giving you trouble?

Top comments (0)