apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Parse E-Invoice XML to JSON API

What it does

This Parse E-Invoice XML to JSON API takes an electronic invoice and returns it as JSON. Send XRechnung, ZUGFeRD, Factur-X or UBL invoices. You get the parties, totals, VAT breakdown and every line item.

Send the XML text in xml. You can also send a Base64 file in fileContent, either XML or a PDF with the invoice XML inside. If you send both, the API reads fileContent. Use fileName to label the result with your file name. Files can be up to 10 MB.

The first item in the response is the invoice. The items after it are the lines. The invoice item also has checks for required fields, dates, codes, amounts and IBANs. allChecksOk is false when a check fails, so review those invoices before you pay them.

Teams use the e-invoice parser API to import supplier invoices into an ERP, convert XRechnung to JSON for accounting tools, and flag wrong totals before approval.

It does not read scanned or plain PDF invoices, and its checks are not a full EN 16931 validation. For those PDFs, try the Invoice Data Extraction API. To check a payee account on its own, use the IBAN Validation API.

POST
E-Invoice Reader - XRechnung, ZUGFeRD, Factur-X, UBL to JSON
https://api.eu.apyhub.com/martin10291/parse-e-invoice-xml/e-invoice-reader

QUICKSTART

GUIDE

Quickstart

Send a UBL invoice as XML text.

curl -X POST "https://api.eu.apyhub.com/martin10291/parse-e-invoice-xml/e-invoice-reader" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Invoice xmlns=\"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2\" xmlns:cac=\"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2\" xmlns:cbc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\"><cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID><cbc:ID>U-1</cbc:ID><cbc:IssueDate>2026-11-15</cbc:IssueDate><cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode><cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode><cac:AccountingSupplierParty><cac:Party><cac:PartyName><cbc:Name>Acme</cbc:Name></cac:PartyName><cac:PartyLegalEntity><cbc:RegistrationName>Acme</cbc:RegistrationName></cac:PartyLegalEntity></cac:Party></cac:AccountingSupplierParty><cac:AccountingCustomerParty><cac:Party><cac:PartyName><cbc:Name>Client</cbc:Name></cac:PartyName><cac:PartyLegalEntity><cbc:RegistrationName>Client</cbc:RegistrationName></cac:PartyLegalEntity></cac:Party></cac:AccountingCustomerParty><cac:TaxTotal><cbc:TaxAmount currencyID=\"EUR\">28.50</cbc:TaxAmount><cac:TaxSubtotal><cbc:TaxableAmount currencyID=\"EUR\">150.00</cbc:TaxableAmount><cbc:TaxAmount currencyID=\"EUR\">28.50</cbc:TaxAmount><cac:TaxCategory><cbc:ID>S</cbc:ID><cbc:Percent>19</cbc:Percent></cac:TaxCategory></cac:TaxSubtotal></cac:TaxTotal><cac:LegalMonetaryTotal><cbc:LineExtensionAmount currencyID=\"EUR\">150.00</cbc:LineExtensionAmount><cbc:TaxExclusiveAmount currencyID=\"EUR\">150.00</cbc:TaxExclusiveAmount><cbc:TaxInclusiveAmount currencyID=\"EUR\">178.50</cbc:TaxInclusiveAmount><cbc:PayableAmount currencyID=\"EUR\">178.50</cbc:PayableAmount></cac:LegalMonetaryTotal><cac:InvoiceLine><cbc:ID>1</cbc:ID><cbc:InvoicedQuantity unitCode=\"C62\">1.5</cbc:InvoicedQuantity><cbc:LineExtensionAmount currencyID=\"EUR\">150.00</cbc:LineExtensionAmount><cac:Item><cbc:Name>Work</cbc:Name><cac:ClassifiedTaxCategory><cbc:ID>S</cbc:ID><cbc:Percent>19</cbc:Percent></cac:ClassifiedTaxCategory></cac:Item><cac:Price><cbc:PriceAmount currencyID=\"EUR\">100.00</cbc:PriceAmount></cac:Price></cac:InvoiceLine></Invoice>"}'

What you'll get back

Returns a JSON object with count and items. The first item is the invoice and the second is its only line. The checks list below is shortened.

{
  "count": 2,
  "items": [
    {
      "type": "invoice",
      "number": "U-1",
      "documentType": "Invoice",
      "standard": "Peppol BIS",
      "syntax": "UBL 2.1",
      "profile": "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0",
      "source": "XML",
      "sourceFile": "invoice",
      "issueDate": "2026-11-15",
      "dueDate": "",
      "deliveryDate": "",
      "currency": "EUR",
      "buyerReference": "",
      "orderReference": "",
      "paymentReference": "",
      "paymentTerms": "",
      "iban": "",
      "bic": "",
      "accountName": "",
      "seller": {
        "city": "",
        "contact": "",
        "country": "",
        "email": "",
        "name": "Acme",
        "phone": "",
        "postcode": "",
        "street": "",
        "vatId": ""
      },
      "buyer": {
        "city": "",
        "contact": "",
        "country": "",
        "email": "",
        "name": "Client",
        "phone": "",
        "postcode": "",
        "street": "",
        "vatId": ""
      },
      "notes": [],
      "lineCount": 1,
      "totals": {
        "lines": 150,
        "net": 150,
        "vat": 28.5,
        "gross": 178.5,
        "payable": 178.5,
        "allowances": null,
        "charges": null,
        "prepaid": null
      },
      "vatBreakdown": [
        {
          "category": "S",
          "percent": 19,
          "base": 150,
          "amount": 28.5,
          "reason": ""
        }
      ],
      "checks": [
        {
          "check": "Mandatory invoice fields present",
          "ok": true,
          "detail": "all present"
        },
        {
          "check": "Dates are valid calendar dates",
          "ok": true,
          "detail": "valid"
        }
      ],
      "allChecksOk": true
    },
    {
      "type": "line",
      "invoice": "U-1",
      "lineId": "1",
      "name": "Work",
      "description": "",
      "sellerItemId": "",
      "buyerItemId": "",
      "quantity": 1.5,
      "unitCode": "C62",
      "unit": "piece",
      "unitPrice": 100,
      "netAmount": 150,
      "vatCategory": "S",
      "vatPercent": 19
    }
  ]
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
E-invoice XML as text. Required if fileContent is not sent.
File name returned in sourceFile. Default: invoice.
Base64 of the XML, or of a PDF with the invoice XML inside. Required if xml is not sent. Used instead of xml when both are sent. Max 10 MB file.

About this endpoint

What it does

Reads an XRechnung, ZUGFeRD, Factur-X or UBL e-invoice and returns the invoice and its lines as JSON, with consistency checks.

Request Body

ParameterTypeDescription
xmlStringThe e-invoice XML as text. Required if fileContent is not sent.
fileContentStringBase64 of the XML file, or of a PDF with the invoice XML inside. Required if xml is not sent. Used instead of xml when both are sent.
fileNameStringFile name returned in sourceFile. Default: invoice.

Response

Returns a JSON object with count and items. The first item is the invoice (type: invoice) and each following item is one line (type: line). count is therefore the number of lines plus one.

ParameterTypeDescription
countIntegerNumber of items.
items[].typeENUMAllowed values: invoice, line.

Invoice item

ParameterTypeDescription
items[].numberStringInvoice number.
items[].documentTypeStringFor example Invoice or Credit note.
items[].standardStringDetected standard, for example XRechnung, Peppol BIS or ZUGFeRD / Factur-X.
items[].syntaxStringXML syntax, for example CII (UN/CEFACT) or UBL 2.1.
items[].profileStringProfile identifier from the file.
items[].sourceStringXML or PDF with embedded XML.
items[].sourceFileStringYour fileName, or invoice.
items[].issueDate, dueDate, deliveryDateStringDates as YYYY-MM-DD. Empty when absent.
items[].currencyStringCurrency code.
items[].buyerReference, orderReference, paymentReferenceStringReferences. Empty when absent.
items[].paymentTermsStringPayment terms text.
items[].iban, bic, accountNameStringPayment account details.
items[].seller, buyerObjectname, street, postcode, city, country, vatId, contact, email, phone.
items[].notesString ArrayNotes from the invoice.
items[].lineCountIntegerNumber of invoice lines.
items[].totals.linesNumberSum of line amounts. Nullable.
items[].totals.net, vat, gross, payableNumberHeader amounts. Nullable.
items[].totals.allowances, charges, prepaidNumberNull when absent.
items[].vatBreakdown[]Object Arraycategory, percent, base, amount, reason. The three amounts are nullable.
items[].checks[]Object Arraycheck (name), ok (Boolean), detail (explanation).
items[].allChecksOkBooleanfalse when a check fails.

Line item

ParameterTypeDescription
items[].invoiceStringInvoice number the line belongs to.
items[].lineIdStringLine identifier from the file.
items[].name, descriptionStringProduct or service.
items[].sellerItemId, buyerItemIdStringItem identifiers.
items[].quantityNumberBilled quantity. Can be a decimal. Nullable.
items[].unitCode, unitStringUnit code and its readable name.
items[].unitPrice, netAmountNumberPrice and line amount. Nullable.
items[].vatCategoryStringVAT category code.
items[].vatPercentNumberVAT rate. Nullable.

Checks

The checks cover required fields, valid dates, currency and document type codes, line amounts, line totals, VAT sums and rates, gross amount, amount due and IBAN. Which checks run depends on the data in the file. They are not a full EN 16931 or XRechnung schema validation.

Errors

A 400 response has code, error and message. For example, code is invalid_input when:

  • neither xml nor fileContent is sent
  • a field has the wrong type
  • the input is not an e-invoice
  • a PDF has no invoice XML inside
  • the XML has a DOCTYPE or ENTITY declaration
  • the file is larger than 10 MB

Notes

  • Maximum file size: 10 MB.
  • UTF-8 and UTF-16 XML files are accepted.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.