Factur-X Embedding API
Combine a PDF and a UN/CEFACT CII XML into a Factur-X compliant PDF/A-3 with the XML embedded as the factur-x.xml attachment.
https://api.invoicexml.com/v1/embed/facturx
- Your own PDF layout kept as it is
- PDF/A-3 with embedded CII XML
- Validated before embedding
- Optional French BR-FR rules
Technical reference
Combine a user-supplied PDF and a user-supplied UN/CEFACT Cross Industry Invoice (CII) XML into a single Factur-X compliant PDF/A-3 with the XML embedded as the factur-x.xml attachment, packaged per the French (FNFE-MPE) conventions. The XML is validated with the full /v1/validate/facturx rule set before embedding, so a non-compliant invoice never leaves the API (pass skipValidation=true to package without business-rule checks). Use it when you already have a rendered invoice PDF (from your accounting system, template engine, or any source) plus a separate EN 16931 XML, and want the hybrid container produced for you without going through the full /v1/create flow.
Code Example
curl -X POST https://api.invoicexml.com/v1/embed/facturx \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "[email protected]" \ -F "[email protected]" \ -F "validationLanguage=fr"
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. |
| rules | string | Optional. Extra national rule sets to check ON TOP of the rule set the XML's declared profile selects, before embedding. br-fr runs the BR-FR Flux 2 rules of the French CTC mandate, the same set the Plateformes Agréées and the PPF apply to every domestic invoice. Violations reject the request as regular findings whose rule ids start with BR-FR; an unknown value is rejected with a 400 rather than skipped. Cannot be combined with skipValidation=true. See the French mandate 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.
French mandate rules before embedding
For invoices bound for the French exchange network, add the optional
rules form field with br-fr. The
BR-FR Flux 2 rules, the same rule set the Plateformes Agréées and the PPF apply to every
domestic French invoice, then run on top of the rule set the XML's declared profile selects, and the
hybrid PDF is only produced when the invoice passes both:
curl -X POST https://api.invoicexml.com/v1/embed/facturx \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "[email protected]" \ -F "[email protected]" \ -F "rules=br-fr"
- The declared profile (BT-24) is never changed and its own validation runs unchanged. Mandate
violations are reported in the same 400 response (
errorCode 4001) as any other fatal finding, with rule ids starting withBR-FR, so the XML is fixed before it reaches a Plateforme Agréée. - The field cannot be combined with
skipValidation=true: packaging-only mode runs no business rules, so the request is rejected with a 400 instead of returning a PDF that was never checked. - Documents declaring the MINIMUM or BASIC WL profile are rejected with a 400: the mandate reads those header-only subsets as booking aids, not invoices. A document declaring the EXTENDED-CTC-FR profile already runs these rules by default, so the field adds nothing there.
- The field is offered on this route only.
/v1/embed/zugferdrejects it with a 400 pointing back here, since the French mandate is a Factur-X concern.
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 Factur-X integration samples in C#, Java, PHP, Python, Node.js, and browser JavaScript, ready to clone and adapt.
InvoiceXML/facturx-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/facturx
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.