E-Invoice Attachment Extraction API
Extract the embedded attachments (BG-24 supporting documents) from an XRechnung, Factur-X, ZUGFeRD, UBL, or CII e-invoice as a ZIP download.
https://api.invoicexml.com/v1/extract/attachments
- All attachments in one ZIP
- UBL, CII and hybrid PDF input
- Delivery notes, timesheets and orders
- Files returned exactly as sent
Technical reference
Extract the embedded attachments from an electronic invoice: delivery notes, timesheets, the original order, or any other supporting document the sender packed into the e-invoice. The endpoint accepts a standalone XML e-invoice (UBL, CII, or XRechnung in either syntax) or a hybrid Factur-X / ZUGFeRD PDF, collects every additional supporting document (BG-24) that carries a base64 payload (BT-125), and returns them as a single ZIP download. The attachment bytes are decoded and streamed into the archive verbatim: they are never parsed, rendered, or interpreted on the server.
One of three extraction routes: the invoice extraction overview shows which endpoint fits which document.
Code Example
curl -X POST https://api.invoicexml.com/v1/extract/attachments \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "[email protected]"
Request
| Parameter | Type | Description |
|---|---|---|
| file * | binary | The invoice file to process. |
Content-Type: multipart/form-data
The source and target formats are part of the endpoint path, and everything else (syntax, declared profile, specification identifier) is read from the document itself, so there is nothing more to configure.
Headers
| Header | Value |
|---|---|
| Authorization * | Bearer YOUR_API_KEY |
| Content-Type | multipart/form-data |
Response
200 Attachment archive
Returns a ZIP archive containing every embedded attachment.
The response filename is derived from the uploaded file and the invoice number:
{original-name}-attachments-{invoice-number}.zip.
The invoice number is reduced to a file-name-safe slug and omitted when it cannot be read.
The Content-Disposition header is set to attachment for direct download.
Each ZIP entry keeps the filename the invoice declares in BT-125-2, sanitised to a flat, safe name.
Duplicate names receive a numeric suffix so no entry overwrites another on extraction, and attachments
without a declared filename are named attachment-N with an extension
derived from the declared mime code (BT-125-1).
How the E-Invoice Attachment Extraction API Works
EN 16931 e-invoices carry their supporting documents inside the invoice itself: each additional supporting document (BG-24) can embed the original file as a base64 payload (BT-125). XRechnung invoices submitted to German B2G portals, Peppol UBL invoices, and Factur-X / ZUGFeRD hybrids all use this mechanism, because the structured XML is the only artifact that travels end to end. This endpoint turns those payloads back into the original files:
Invoice ingestion
The upload is read as a standalone XML e-invoice (UBL, CII, or XRechnung in either syntax), or, for a Factur-X / ZUGFeRD hybrid PDF, the embedded invoice XML is extracted first. The syntax is auto-detected; there is nothing to configure.
Attachment collection & decoding
Every BG-24 group with a base64 payload (BT-125) is collected and decoded. Decoding is a mechanical transcoding: the file content is never parsed, sniffed, rendered, or validated on the server. Documents referenced only by external URI (BT-124) are skipped by design.
ZIP delivery
The decoded files are streamed into a ZIP archive under their declared filenames (BT-125-2), sanitised and de-duplicated, and returned as application/zip with Content-Disposition: attachment, ready for archiving, accounts-payable review, or audit workflows.
Error Reference
Errors are returned as RFC 7807 ProblemDetails, using the same envelope as every other endpoint; see Error handling for the full list. The codes specific to this endpoint:
| errorCode | HTTP status | Meaning |
|---|---|---|
| 4013 | 404 | No embedded attachments. The invoice contains no BG-24 group with a BT-125 payload. Documents referenced only by external URI (BT-124) are not downloaded. |
| 4014 | 400 | Invalid attachment. An embedded BT-125 payload is not valid base64, so the invoice XML carries a corrupt attachment. The detail names the offending document reference. |
| 4006 | 400 | No embedded XML. Returned for PDF uploads that carry no embedded invoice XML, so there is no BG-24 structure to read. |
Useful resources
Companion material for integrating against the API.
Runnable samples in C#, Java, PHP, Python, Node.js, and browser JavaScript, one repository per format.
github.com/InvoiceXML
Run this endpoint on your own file or data straight from your browser, no code and no sign-up required.
www.invoicexml.com/api/extract/attachments
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.