# Factur-X PDF/A-3 Attachment Extraction & Validation API
> Extract the embedded UN/CEFACT CII XML from Factur-X and ZUGFeRD PDF/A-3 hybrid invoices and return the validated invoice model as JSON.

- **Canonical URL:** https://stanzaapi.com/tools/factur-x-validator/standards/pdf-a-3-factur-x-extraction
- **Governing Standard:** Factur-X 1.0.x / ZUGFeRD 2.x (EN 16931) (International Standards Organization)
- **Latency:** <5ms
- **Privacy:** In-memory execution only (zero data stored or logged)

## Technical Overview & Governing Rules
Factur-X and ZUGFeRD invoices are PDF/A-3 files with an embedded UN/CEFACT CrossIndustryInvoice XML attachment named factur-x.xml or zugferd-invoice.xml.

Send the PDF as application/pdf or pdf_base64 and the engine extracts the attachment before validation; the response echoes the attachment name and MIME type.

If no recognized attachment exists the API returns HTTP 200 with valid:false and an exact FX-PDF-01, FX-PDF-02, or FX-PDF-03 diagnostic instead of a generic failure.

## Specification Matrix
| Diagnostic | Condition | Response |
| --- | --- | --- |
| factur-x.xml / zugferd-invoice.xml | Recognized CII attachment found | Validated against the detected Factur-X profile |
| FX-PDF-01 | No embedded file attachment was found in the PDF | HTTP 200, valid:false |
| FX-PDF-02 | Attachment is not a recognized Factur-X or ZUGFeRD XML file | HTTP 200, valid:false |
| FX-PDF-03 | PDF corrupt, encrypted, or over the processing budget | HTTP 200, valid:false |

## Standard JSON Response Model
```json
{
  "valid": true,
  "container": "PDF",
  "attachment": {
    "name": "factur-x.xml",
    "mimeType": "text/xml"
  },
  "syntax": "CII",
  "profile": "EN16931",
  "summary": {
    "status": "COMPLIANT",
    "fatalCount": 0,
    "warningCount": 0
  }
}
```

## Frequently Asked Questions & Edge Cases
### Q: Do I have to send the PDF or can I send the XML?
**A:** Both work. Send the PDF/A-3 file (application/pdf or pdf_base64) and the API extracts the embedded XML, or send the CII XML directly as raw XML or a JSON xml field.

### Q: What happens when no Factur-X attachment is found?
**A:** The API returns HTTP 200 with valid:false and the FX-PDF-01 diagnostic, so AP pipelines can route the document to manual review without treating a valid PDF as a server error.
