ZUGFeRD Embedding API
Combine a PDF and a UN/CEFACT CII XML into a ZUGFeRD compliant PDF/A-3 with the XML embedded as the factur-x.xml attachment.
https://api.invoicexml.com/v1/embed/zugferd
- Your own PDF layout kept as it is
- Profile read from your XML
- XRechnung CII embedded too
- Validated before embedding
Technical reference
Combine a user-supplied PDF and a user-supplied UN/CEFACT Cross Industry Invoice (CII) XML into a single ZUGFeRD compliant PDF/A-3 with the XML embedded as the factur-x.xml attachment (per the modern ZUGFeRD / Factur-X convergence on the attachment filename; the XRechnung reference profile is embedded as xrechnung.xml), packaged per the German (FeRD) conventions expected by German B2B and B2G readers. The XML is validated with the full /v1/validate/zugferd rule set before embedding, so a non-compliant invoice never leaves the API (pass skipValidation=true to package without business-rule checks).
Code Example
curl -X POST https://api.invoicexml.com/v1/embed/zugferd \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "[email protected]" \ -F "[email protected]" \ -F "validationLanguage=de"
Request
| Parameter | Type | Description |
|---|---|---|
| pdf * | binary | The base PDF to embed the XML into. Any standard PDF is accepted, it will be promoted to PDF/A-3 by the embedder. |
| xml * | binary | A UN/CEFACT Cross Industry Invoice (CII) XML document. The root element must be CrossIndustryInvoice in the CII namespace, UBL documents are not accepted. The Specification identifier (BT-24) must declare one of the official ZUGFeRD/Factur-X profile URNs, see the accepted profiles below. |
| skipValidation | boolean | Optional, defaults to false. When true, the business-rule (Schematron) validation is skipped and only the structural checks run (CII root, official BT-24 profile URN, profile XSD). See the validation section below. |
| validationLanguage | string | Optional. Language of the finding messages when the XML is rejected: en (default), de or fr, in any letter case. Only each finding's message changes; rule, btCodes, fields and raw stay the same. Any other value is rejected with a 400 (errorCode 4002). See localized error messages. |
Content-Type: multipart/form-data
Validation Before Embedding
The XML is embedded into the PDF verbatim, byte for byte, so whatever this endpoint accepts is exactly what your recipient's validator will see. To catch faults on your side of the exchange rather than at the buyer's portal, the uploaded XML is validated with the full rule set of the matching validation endpoint (the declared profile's official XSD plus the Schematron business rules) before anything is embedded.
- Fatal findings reject the request with a 400 response (
errorCode 4001) carrying the complete findings array, in the same shape as the validation endpoints. Fix the reported fields and resubmit. - Warnings never block: a request can succeed while the document carries advisory findings.
- Pass
validationLanguage=deorfrto receive the findings' messages in German or French; rule ids and field paths stay the same in every language. - Pass
skipValidation=trueto package without business-rule checks, for example while migrating historical documents. The structural checks always apply: the XML root must be a CII invoice, BT-24 must declare an official profile URN, and the document must conform to the profile's official XSD, because a schema-invalid attachment can never yield a compliant hybrid PDF.
Accepted Profiles (BT-24)
A hybrid PDF mirrors the invoice's Specification identifier (BT-24, the
GuidelineSpecifiedDocumentContextParameter/ID element) into the PDF/A-3
XMP metadata as the conformance level, and the ZUGFeRD/Factur-X specification enumerates the values
allowed there. That makes BT-24 a closed list on this endpoint: an invoice declaring anything else can
never yield a compliant hybrid PDF and is rejected with a 400 response
(errorCode 4017). This is a requirement of the format specification,
not an InvoiceXML limitation. Standalone CII validation
(/v1/validate/cii) has no such restriction, because EN 16931 treats
BT-24 as an open identifier.
| Profile | BT-24 Specification identifier |
|---|---|
| MINIMUM | urn:factur-x.eu:1p0:minimum |
| BASIC WL | urn:factur-x.eu:1p0:basicwl |
| BASIC | urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic |
| EN 16931 (Comfort) | urn:cen.eu:en16931:2017 |
| EXTENDED | urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended |
| EXTENDED-CTC-FR (reference profile, France) | urn:cen.eu:en16931:2017#conformant#urn.cpro.gouv.fr:1p0:extended-ctc-fr |
| XRECHNUNG (reference profile) | urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0 |
| E-REPORTING (France) | urn.cpro.gouv.fr:1p0:ereporting |
The legacy ZUGFeRD 2.0 identifiers (urn:zugferd.de:2p0:* and their
#compliant#/#conformant# forms) and the
older XRechnung CIUS URNs (1.2 through 2.3) are also accepted for backwards compatibility. Matching is
case-insensitive.
Common mistake: #compliant# vs #conformant#
The EXTENDED profile is a superset of EN 16931, so its URN uses the
#conformant# keyword. The narrower profiles (BASIC, XRECHNUNG) use
#compliant#. A mixed form such as
urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:extended is not
defined by any version of the specification and is rejected with
errorCode 4017, even though the same XML passes
/v1/validate/cii as a plain EN 16931 invoice (with a
PROFILE-DETECTION warning).
Headers
| Header | Value |
|---|---|
| Authorization * | Bearer YOUR_API_KEY |
| Content-Type | multipart/form-data |
Response
200 Embedded PDF
Returns the embedded PDF/A-3 as a binary file.
The response filename is derived from the uploaded PDF: {original-name}-facturx.pdf.
The Content-Disposition header is set to attachment for direct download.
How the Embed XML API Works
The API takes two uploads and produces a single hybrid PDF/A-3 ready for B2B exchange:
Receive the PDF and the CII XML
Upload your already rendered invoice PDF (from your accounting system, template engine, or any source) together with the matching UN/CEFACT Cross Industry Invoice XML. The API shape-checks the XML root, only CrossIndustryInvoice documents are accepted. UBL invoices are rejected, convert them with /v1/convert/ubl/to/cii first.
Validate the XML
The XML is validated with the full rule set of the matching validation endpoint: the declared profile's official XSD plus the Schematron business rules. Fatal findings stop the request with the complete findings list before anything is packaged; warnings never block. Pass skipValidation=true to run the structural checks only.
Promote the PDF to PDF/A-3 and embed the XML
The base PDF is converted to PDF/A-3 in-place, then the XML is attached byte for byte as the factur-x.xml attachment with the metadata required by ZUGFeRD / Factur-X (relationship, MIME type, AFRelationship). The result is a single hybrid container that is both human-readable and machine-processable.
Return the embedded PDF
The API response is the new PDF/A-3 streamed back as application/pdf. The filename is derived from the uploaded PDF: {original-name}-facturx.pdf.
Useful resources
Companion material for integrating against the API.
Runnable ZUGFeRD integration samples in C#, Java, PHP, Python, Node.js, and browser JavaScript, ready to clone and adapt.
InvoiceXML/zugferd-api-examples
Run this endpoint on your own file or data straight from your browser, no code and no sign-up required.
www.invoicexml.com/api/embed/zugferd
The full OpenAPI 3.1 document. Drop it into Postman, Insomnia, or any code generator to scaffold a client.
api.invoicexml.com/v1/openapi
Browse and call every endpoint directly from the browser, powered by Scalar.
api.invoicexml.com/v1/scalar
Frequently Asked Questions
Ready to automate your invoices?
Validate, convert and embed compliant e-invoices through one API. Start your 30-day free trial. No credit card required.