A ZUGFeRD invoice is a PDF/A-3 with an embedded XML file according to the European standard EN 16931. Instead of implementing PDF/A, XML syntax and validation rules yourself, your software can send the invoice data as JSON to a REST API and receives a validated ZUGFeRD or XRechnung file in return. At E-Rechnungsfreund, that takes three calls: create the invoice, generate the file, validate the file.
As of: Dec. 2, 2026
This guide is a machine translation of the German original as of Dec. 2, 2026. Only the German version is authoritative: read the German version. If you contact us, please write in German or English.
The problem: e-invoices from your own software
You run a shop, an industry-specific program or an internal tool that currently sends invoices as PDFs. From Jan. 1, 2027, businesses with a total turnover (Gesamtumsatz) of more than 800,000 € in the previous year have to issue e-invoices (E-Rechnungen) to other domestic businesses, from Jan. 1, 2028 all businesses (§ 27 para. 38 UStG). Whether and from when this affects your customers is shown by the E-invoicing mandate check; the deadlines in detail are explained in the article E-invoicing from 2027: what businesses need to do now.
A PDF alone is not enough for this. An e-invoice is an invoice that is issued, transmitted and received in a structured electronic format and enables electronic processing (§ 14 para. 1 sentence 3 UStG). The format must comply with the European standard EN 16931 or be agreed between the parties involved (§ 14 para. 1 sentence 6 UStG). An agreed format is only sufficient if the required invoice details can be extracted from it correctly and completely into a format that complies with EN 16931 or is interoperable with it (§ 14 para. 1 sentence 7 UStG).
What a ZUGFeRD file is technically
ZUGFeRD is a hybrid format of the Forum elektronische Rechnung Deutschland (FeRD): a PDF/A-3, i.e. a PDF for long-term archiving, in which the invoice data is embedded as an XML file in the syntax UN/CEFACT Cross Industry Invoice (CII). The PDF is the view for humans, the XML file the data for programs. From version 2.0.1, a ZUGFeRD file is an e-invoice, except for the profiles MINIMUM and BASIC-WL (section 14.1 para. 14 UStAE as amended by the BMF letter of 15 October 2025). The XRechnung, by contrast, is a pure XML file (section 14.1 para. 13 UStAE); it is usually requested for invoices to public authorities, then with a Leitweg-ID.
If you implement this yourself, you need, among others:
- XML generation that correctly fills the fields of the standard (BT numbers such as BT-1 for the invoice number), including the tax breakdown and totals,
- PDF/A-3 generation with an embedded XML file and the appropriate metadata,
- validation against the official validation rules, for example with the validator of KoSIT (Koordinierungsstelle für IT-Standards) and the XRechnung validator configuration,
- maintenance when new versions of the standards and validation rules are published.
The PDF and the XML should show the same invoice. FeRD therefore recommends that invoice issuers carry out their own checks that both parts match in content. If a program generates both parts from the same data, this is easier than adding XML to an existing PDF afterwards.
The alternative: three API calls
With the public API of E-Rechnungsfreund (REST, JSON, OpenAPI description), your software only sends the
invoice data. You authenticate with an API key in the header Authorization: Api-Key <key>;
you create the key in your account after free registration.
- Create the invoice:
POST /api/v1/invoices/with invoice number, date, seller, buyer, line items and tax breakdown as JSON. The response contains theidof the invoice. If no profile is specified, the EN 16931 profile applies; for an XRechnung, create the invoice with the XRechnung profile ("profile": "XRECHNUNG"). - Generate the file:
POST /api/v1/invoices/{id}/generate_zugferd_pdf/returns a ZUGFeRD PDF (PDF/A-3b with an embedded XML file in the selected profile, by default EN 16931),POST /api/v1/invoices/{id}/generate_xrechnung/an XRechnung as XML (CII). The endpoint must match the profile: invoices with the XRechnung profile are only available as XRechnung, all others only as ZUGFeRD PDF. Before the output, the invoice is validated against the KoSIT validation rules; if it fails, you receive an error with the violated rules instead of the file. - Validate the file:
POST /api/v1/validate/with the file in the form fieldinvoice_filereturnsis_validand the messages. This way you can also validate invoices that you receive yourself.
Ready-made scripts for curl, Python, PHP and Node.js with exactly these three steps are available in the public example repo linked from the API page. The quickstart shows how to get started step by step, the API reference lists all fields. If you prefer to work without code, you can create the same files in the web form, see Create a ZUGFeRD invoice.
Validating via API: what the validation reports
The validation endpoint accepts XML files in CII or UBL (XRechnung, ZUGFeRD XML) and PDF files with an
embedded XML file. Validation uses the KoSIT validator, depending on the format complemented by Mustang
and the EN16931 Schematron. Each message carries the ID of the validation rule; with
include_explanations=true, the explanation is included right away. A common example from
in-house invoice generation is
BR-CO-15: the total amount including VAT does
not match the sum of the net amount and the tax amount, often because of rounding.
A passed validation means: the format and business rules of the standard are complied with. Whether the content is correct for tax purposes, for example the correct tax rate, cannot be answered by any technical validation; if in doubt, clarify this with your tax advisor. You can also validate a single file without an account in the validator in your browser.
Errors and limits
- Errors are returned uniformly according to RFC 7807 as JSON with
type,title,statusand a readable message indetail. 400when creating: field errors;400when generating: the invoice is incomplete, the profile does not match the endpoint or the invoice fails validation. Only if the invoice fails validation does the response list the violated rules; in the other cases, there is only a message.402: the monthly quota of your plan is used up;429: rate limit reached. The limits are listed on the API page.- The API is available in all plans, including the free plan with 5 invoices and 30 validations per month.
How to proceed
- Clarify which format your customers need: ZUGFeRD for business customers, XRechnung usually for public authorities. What the files look like is shown in the e-invoice examples.
- Create a free account, generate an API key and run the example script from the quickstart once.
- Validate the generated file in the validator or via
/api/v1/validate/and map the fields of your software to the JSON of the API.
Frequently asked questions
Is there an API for creating e-invoices?
Yes. The public API of E-Rechnungsfreund creates an invoice from JSON and generates a ZUGFeRD PDF from it (PDF/A-3b with an embedded XML file in the selected profile, by default EN 16931) or an XRechnung as XML. You authenticate with an API key from your account.
Can I validate e-invoices via API?
Yes. You send the file (XRechnung or ZUGFeRD XML in CII or UBL, ZUGFeRD PDF with an embedded XML file) to the validation endpoint and receive the result with the violated validation rules as JSON.
Do I need a ZUGFeRD library in my programming language?
Not if you use an API: your software only needs HTTP and JSON, whether in Python, PHP, Node.js, Java or C#. Generation, PDF/A and validation run on the server.
What does it cost to test the API?
The API is available in all plans, including the free one, within the quotas of the plan. In the free plan, that is 5 invoices and 30 validations per month.
Sources
- BMF-Schreiben zur Einführung der obligatorischen E-Rechnung zwischen inländischen Unternehmern (BMF letter on the introduction of mandatory e-invoicing between domestic businesses) (Oct. 15, 2025, III C 2 - S 7287-a/00019/007/243)
- BMF-Schreiben zur obligatorischen E-Rechnung – ergänzende Regelungen (BMF letter on mandatory e-invoicing – supplementary rules) (Oct. 15, 2026, III C 5 - S 7287-a/00019/021/017)
- § 14 UStG (Ausstellung von Rechnungen) (issuing invoices)
- § 27 Abs. 38 UStG (Übergangsregelungen) (transitional provisions)
- FeRD: Was ist ZUGFeRD? (What is ZUGFeRD?)
- KoSIT: XRechnung (Spezifikation, Validator und Validatorkonfiguration) (specification, validator and validator configuration)
This article summarises the sources listed in general terms and is not tax or legal advice. For your individual case, please consult a tax advisor.