Quickstart

This example reads a German XRechnung and pulls out the invoice data. All it takes is an API key and the file.

1

Base64 encode the document

The API takes documents Base64 encoded throughout — XML as well as PDF.

base64 -i invoice.xml | tr -d '\n' > invoice.b64
2

Call the parse endpoint

curl -X POST https://service.invoice-api.xhub.io/api/v1/invoice/de/xrechnung/parse \
-H "Authorization: Bearer sk_test_xxxxx" \
-H "Content-Type: application/json" \
-d "{\"data\":\"$(cat invoice.b64)\",\"filename\":\"invoice.xml\"}"
3

Read the response

{
"success": true,
"invoice": {
"invoiceNumber": "INV-2026-0042",
"type": "invoice",
"issueDate": "2026-03-20",
"dueDate": "2026-04-19"
}
}

Do you know the format already?

There are two ways in, and the choice has consequences:

/api/v1/invoice/{country}/{format}/parse checks the document against exactly that format and reports deviations clearly. The way to go when the source is fixed.

/api/v1/invoice/parse works out the format itself. Handy for inboxes with mixed sources — in exchange, the error message is less precise about what is wrong with a document.

Next