oneapi
Sign in
Anaf v1 / Interop (CII / Factur-X)

Extract from Factur-X

Extracts the invoice XML embedded in a Factur-X or ZUGFeRD PDF and says which profile it was found in. For invoices received as a single PDF file.

POST
https://oneapi.ro/api/anaf/v1/interop/facturx-extract

Request body

The request body is the whole document, sent raw (Content-Type: application/pdf) — not an object with fields.

Factur-X PDF

factura-x.pdf application/pdf · 54,3 KB — sent as is, in the request body.

A reversal's PDF

factura-x-stornare.pdf application/pdf · 53,9 KB — sent as is, in the request body.

A PDF in the BASIC profile

factura-x-intracomunitara.pdf application/pdf · 54,8 KB — sent as is, in the request body.

Query parameters

NameTypeDescriptionAccepted values
formatoptional text Shape of the returned XML: xml (default) or base64. e.g. base64

How it behaves

  • The document can also be sent as a file: multipart/form-data with the fisier field (curl -F fisier=@document.xml), instead of the raw body. The file content becomes the request body, so the result is identical; options stay in the query string, and any other form field next to fisier returns 422 camp_necunoscut.
  • Takes the bytes of a Factur-X / ZUGFeRD / XRechnung PDF (a PDF/A-3 with an embedded invoice XML attachment) and returns the embedded invoice XML — usually CII, sometimes UBL. It also detects which format it found.
  • Extraction works in two layers: first the PDF attachments, then, if needed, a direct scan of the /EmbeddedFile streams, with FlateDecode inflation.
  • We do not build Factur-X PDFs — embedding the XML into a PDF/A-3 is out of scope for this toolkit. Here we only unpack.
  • Zero retention: the PDF received is not written and not logged.

What it is for

  • Pulling the structured invoice out of a Factur-X PDF received by email, so you can validate or convert it further.
  • A first step before CII → UBL: extract the CII from the PDF, then convert it to CIUS-RO.

Response structure

FieldTypeDescription
data.format_detectat string The format of the extracted XML: CII, UBL or necunoscut.
data.xml string The extracted invoice XML; text or base64 depending on format.
meta.generat_la string When the response was built (ISO 8601).

Response examples

body: @factura-x.pdf

POSThttps://oneapi.ro/api/anaf/v1/interop/facturx-extract
{
    "data": {
        "format_detectat": "CII",
        "xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rsm:CrossIndustryInvoice xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice: 100\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity: 100\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType: 100\" xmlns:qdt=\"urn:un:unece:uncefact:data:standard:QualifiedDataType: 100\">\n  <rsm:ExchangedDocumentContext>\n    <ram:GuidelineSpecifiedDocumentContextParameter>\n      <ram:ID>urn:cen.eu:en16931: 2017</ram:ID>\n    </ram:GuidelineSpecifiedDocumentContextParameter>\n  </rsm:ExchangedDocumentContext>\n  <rsm:ExchangedDocument>\n    <ram:ID>FCT-2026-0142</ram:ID>\n    <ram:TypeCode>380</ram:TypeCode>\n    <ram:IssueDateTime>\n      <udt:DateTimeString format=\"102\">20260910</udt:DateTimeString>\n    </ram:IssueDateTime>\n  </rsm:ExchangedDocument>\n  <rsm:SupplyChainTradeTransaction>\n    <ram:IncludedSupplyChainTradeLineItem>\n      <ram:AssociatedDocumentLineDocument>\n        <ram:LineID>1</ram:LineID>\n      </ram:AssociatedDocumentLineDocument>\n      <ram:SpecifiedTradeProduct>\n        <ram:Name>Servicii de consultanţă</ram:Name>\n      </ram:SpecifiedTradeProduct>\n      <ram:SpecifiedLineTradeAgreement>\n        <ram:NetPriceProductTradePrice>\n          <ram:ChargeAmount>100.00</ram:ChargeAmount>\n        </ram:NetPriceProductTradePrice>\n      </ram:SpecifiedLineTradeAgreement>\n      <ram:SpecifiedLineTradeDelivery>\n        <ram:BilledQuantity unitCode=\"H87\">2</ram:BilledQuantity>\n      </ram:SpecifiedLineTradeDelivery>\n      <ram:SpecifiedLineTradeSettlement>\n        <ram:ApplicableTradeTax>\n          <ram:TypeCode>VAT</ram:TypeCode>\n          <ram:CategoryCode>S</ram:CategoryCode>\n          <ram:RateApplicablePercent>21</ram:RateApplicablePercent>\n        </ram:ApplicableTradeTax>\n        <ram:SpecifiedTradeSettlementLineMonetarySummation>\n          <ram:LineTotalAmount>200.00</ram:LineTotalAmount>\n        </ram:SpecifiedTradeSettlementLineMonetarySummation>\n      </ram:SpecifiedLineTradeSettlement>\n    </ram:IncludedSupplyChainTradeLineItem>\n    <ram:IncludedSupplyChainTradeLineItem>\n      <ram:AssociatedDocumentLineDocument>\n        <ram:LineID>2</ram:LineID>\n      </ram:AssociatedDocumentLineDocument>\n      <ram:SpecifiedTradeProduct>\n        <ram:Name>Licenţă software anuală</ram:Name>\n      </ram:SpecifiedTradeProduct>\n      <ram:SpecifiedLineTradeAgreement>\n        <ram:NetPriceProductTradePrice>\n          <ram:ChargeAmount>500.00</ram:ChargeAmount>\n        </ram:NetPriceProductTradePrice>\n      </ram:SpecifiedLineTradeAgreement>\n      <ram:SpecifiedLineTradeDelivery>\n        <ram:BilledQuantity unitCode=\"H87\">1</ram:BilledQuantity>\n      </ram:SpecifiedLineTradeDelivery>\n      <ram:SpecifiedLineTradeSettlement>\n        <ram:ApplicableTradeTax>\n          <ram:TypeCode>VAT</ram:TypeCode>\n          <ram:CategoryCode>S</ram:CategoryCode>\n          <ram:RateApplicablePercent>21</ram:RateApplicablePercent>\n        </ram:ApplicableTradeTax>\n        <ram:SpecifiedTradeSettlementLineMonetarySummation>\n          <ram:LineTotalAmount>500.00</ram:LineTotalAmount>\n        </ram:SpecifiedTradeSettlementLineMonetarySummation>\n      </ram:SpecifiedLineTradeSettlement>\n    </ram:IncludedSupplyChainTradeLineItem>\n    <ram:ApplicableHeaderTradeAgreement>\n      <ram:SellerTradeParty>\n        <ram:Name>Exemplu Furnizor SRL</ram:Name>\n        <ram:PostalTradeAddress>\n          <ram:LineOne>Str. Memorandumului 28</ram:LineOne>\n          <ram:CityName>Cluj-Napoca</ram:CityName>\n          <ram:CountryID>RO</ram:CountryID>\n          <ram:CountrySubDivisionName>RO-CJ</ram:CountrySubDivisionName>\n        </ram:PostalTradeAddress>\n        <ram:SpecifiedTaxRegistration>\n          <ram:ID schemeID=\"VA\">RO990000005</ram:ID>\n        </ram:SpecifiedTaxRegistration>\n      </ram:SellerTradeParty>\n      <ram:BuyerTradeParty>\n        <ram:Name>Exemplu Client SRL</ram:Name>\n        <ram:PostalTradeAddress>\n          <ram:LineOne>Calea Victoriei 1</ram:LineOne>\n          <ram:CityName>SECTOR1</ram:CityName>\n          <ram:CountryID>RO</ram:CountryID>\n          <ram:CountrySubDivisionName>RO-B</ram:CountrySubDivisionName>\n        </ram:PostalTradeAddress>\n        <ram:SpecifiedTaxRegistration>\n          <ram:ID schemeID=\"VA\">RO990000072</ram:ID>\n        </ram:SpecifiedTaxRegistration>\n      </ram:BuyerTradeParty>\n    </ram:ApplicableHeaderTradeAgreement>\n    <ram:ApplicableHeaderTradeDelivery/>\n    <ram:ApplicableHeaderTradeSettlement>\n      <ram:InvoiceCurrencyCode>RON</ram:InvoiceCurrencyCode>\n      <ram:ApplicableTradeTax>\n        <ram:CalculatedAmount>147.00</ram:CalculatedAmount>\n        <ram:TypeCode>VAT</ram:TypeCode>\n        <ram:BasisAmount>700.00</ram:BasisAmount>\n        <ram:CategoryCode>S</ram:CategoryCode>\n        <ram:RateApplicablePercent>21</ram:RateApplicablePercent>\n      </ram:ApplicableTradeTax>\n      <ram:SpecifiedTradePaymentTerms>\n        <ram:DueDateDateTime>\n          <udt:DateTimeString format=\"102\">20261010</udt:DateTimeString>\n        </ram:DueDateDateTime>\n      </ram:SpecifiedTradePaymentTerms>\n      <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n        <ram:LineTotalAmount>700.00</ram:LineTotalAmount>\n        <ram:TaxBasisTotalAmount>700.00</ram:TaxBasisTotalAmount>\n        <ram:TaxTotalAmount currencyID=\"RON\">147.00</ram:TaxTotalAmount>\n        <ram:GrandTotalAmount>847.00</ram:GrandTotalAmount>\n        <ram:DuePayableAmount>847.00</ram:DuePayableAmount>\n      </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n    </ram:ApplicableHeaderTradeSettlement>\n  </rsm:SupplyChainTradeTransaction>\n</rsm:CrossIndustryInvoice>\n"
    },
    "meta": {
        "generat_la": "2026-10-06T23: 59: 44+03: 00"
    }
}

Error codes

CodeSlugWhen it occurs
401neautentificatToken missing, invalid, expired or revoked.
403feature_indisponibilThe current plan does not include the feature the route depends on.
422xml_invalidThe body is not a valid PDF, or the PDF contains no embedded invoice XML (factura_x_fara_xml).
429cota_depasitaThe plan's monthly quota has been exceeded (see Retry-After).

Errors in the Anaf module use the same envelope as the rest of the platform, with two extra fields: {eroare: {cod, mesaj, camp, request_id}}. eroare.cod is stable and is what you branch on; on validation (422) the code is case-specific: xml_invalid, xml_nu_e_factura, unitate_necunoscuta, luna_invalida and so on. camp points at the offending field when one can be identified.

{
    "eroare": {
        "cod": "xml_invalid",
        "mesaj": "The body is not a valid PDF, or the PDF contains no embedded invoice XML (factura_x_fara_xml).",
        "camp": "format",
        "request_id": "0199c1f0-6e1a-7c3d-9b2f-4a8e5d1c7b04"
    }
}