- Home
- API docs
API documentation
One API key, both directions: POST /invoices turns invoice JSON into a branded PDF/A-3 with the compliant EN 16931 XML embedded (Factur-X, ZUGFeRD) or the standalone XML (XRechnung, Peppol BIS), validated against the official rules before you get it. POST /validate checks any e-invoice and returns every rule ID, message and location. POST /parse reads an e-invoice you received into the same invoice JSON.
Quick start
- Get a free API key: enter your email, click the link we send, copy the key. 25 documents a month, no credit card.
- POST an invoice:
curl https://validate.invoir.dev/api/v1/validate \
-H "Authorization: Bearer inv_YOUR_KEY" \
-F file=@invoice.pdf
Base URL: https://validate.invoir.dev/api/v1. /validate, /extract and /parse take multipart/form-data with one field named file (up to 10 MB); /invoices takes JSON. Everything answers JSON. To generate your first invoice, jump to POST /invoices. Runnable examples in curl, Node.js, Python, PHP and Go, with sample Factur-X, XRechnung and Peppol BIS invoices, are on GitHub: github.com/invoir-dev/invoir-examples (MIT).
Authentication
Every request carries your key in the Authorization header:
Authorization: Bearer inv_AbCdEfGhIjKlMnOpQrStUvWxYz012345
Keys start with inv_ (test keys with inv_test_). We store only a hash, so a key can't be shown again: create a new one and revoke the old one in the dashboard (log in with your email, no password). A revoked key stops working at once. Keep keys out of client-side code and repositories.
Without a valid key the API answers 401 with missing_api_key or invalid_api_key.
POST /invoices: generate an e-invoice
Send the invoice as JSON, get back a branded PDF/A-3 with the compliant EN 16931 XML embedded (or the XML on its own for the UBL profiles), plus the validation report. Every document is checked with the same official rules as /validate before it is returned; a document that would fail is never returned.
curl https://validate.invoir.dev/api/v1/invoices \
-H "Authorization: Bearer $INVOIR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"profile": "factur-x",
"number": "RE-2026-0042",
"issueDate": "2026-10-19",
"dueDate": "2026-11-18",
"language": "de",
"seller": {
"name": "Musterbau GmbH", "vatId": "DE123456789",
"address": {"street": "Industriestraße 12", "postalCode": "80331", "city": "München", "country": "DE"},
"contact": {"name": "Erika Mustermann", "email": "rechnung@musterbau.example", "phone": "+49 89 1234560"}
},
"buyer": {
"name": "Beispiel AG", "vatId": "DE987654321",
"address": {"street": "Hauptstraße 1", "postalCode": "10115", "city": "Berlin", "country": "DE"}
},
"lines": [
{"description": "Beratung Softwarearchitektur", "quantity": 12.5, "unit": "HUR", "unitPrice": 140.00, "vatRate": 19},
{"description": "Fachbuch", "quantity": 3, "unitPrice": 39.90, "vatRate": 7}
],
"payment": {"iban": "DE89370400440532013000", "bic": "COBADEFFXXX", "reference": "RE-2026-0042",
"terms": "Zahlbar innerhalb von 30 Tagen ohne Abzug."}
}'
Response: 201 with the document
{
"id": "doc_h3Kq9mZtR2vXb8NpL4wYs1Ac",
"test": false,
"status": "valid",
"profile": "factur-x",
"conformance": "en16931",
"number": "RE-2026-0042",
"createdAt": "2026-10-19T15:04:11Z",
"expiresAt": "2027-01-17T15:04:11Z",
"pdf": { "url": "https://validate.invoir.dev/api/v1/invoices/doc_h3Kq…/pdf", "filename": "RE-2026-0042.pdf", "bytes": 61208, "contentType": "application/pdf", "embeddedAs": null },
"xml": { "url": "https://validate.invoir.dev/api/v1/invoices/doc_h3Kq…/xml", "filename": "RE-2026-0042.xml", "bytes": 7310, "contentType": "application/xml", "embeddedAs": "factur-x.xml" },
"totals": { "currency": "EUR", "lineTotal": 1869.70, "allowanceTotal": 0.00, "chargeTotal": 0.00, "taxExclusive": 1869.70,
"vat": 340.88, "taxInclusive": 2210.58, "prepaid": 0.00, "rounding": 0.00, "due": 2210.58,
"vatBreakdown": [ { "category": "S", "rate": 19, "basis": 1750.00, "amount": 332.50, "exemptionReason": null },
{ "category": "S", "rate": 7, "basis": 119.70, "amount": 8.38, "exemptionReason": null } ] },
"validation": { "status": "valid", "fileType": "pdf", "format": "PDF · Factur-X / ZUGFeRD EN 16931 (COMFORT)", "errors": 0, "warnings": 0, "checks": [ … ] },
"metadata": null
}
Download the files with the same key: GET {pdf.url} and GET {xml.url}. GET /api/v1/invoices/{id} returns this JSON again, GET /api/v1/invoices lists your documents (newest first, ?before=<id>&limit=50 to page). Documents are kept for 90 days (test documents 24 hours), then deleted; store the files in your own system, we are not your archive.
To delete a document sooner, for example when someone named on the invoice asks for erasure, call DELETE /api/v1/invoices/{id}: it answers 204 and the PDF, the XML and the stored JSON are gone at once (404 if the id isn't yours or has already expired). A deleted document still counts in the month's usage. The dashboard's document list has the same Delete button.
curl -X DELETE https://validate.invoir.dev/api/v1/invoices/doc_h3Kq9mZtR2vXb8NpL4wYs1Ac \
-H "Authorization: Bearer inv_YOUR_KEY"
Totals and the VAT breakdown are always computed on our side from the lines (EN 16931 rules, rounded to cents), so the PDF, the XML and the numbers in the response never disagree. One successful generation counts as one document against your quota; errors don't count.
Profiles
profile | You get | Notes |
|---|---|---|
factur-x | PDF/A-3 with factur-x.xml embedded (CII), plus the XML | conformance: minimum, basicwl, basic, en16931 (default), extended. The standard for France and the usual choice for Germany. |
zugferd | The same file as factur-x: PDF/A-3 with factur-x.xml embedded | Since ZUGFeRD 2.1, ZUGFeRD and Factur-X are one standard (current release: ZUGFeRD 2.5.2 = Factur-X 1.09.2), so both names give the same file. Use the name your customers know; conformance works the same. |
xrechnung-ubl | XRechnung 3.0 XML in UBL syntax | German public-sector buyers. Add "pdf": true to get a readable PDF/A-3 as well (not embedded). Requires buyer reference (Leitweg-ID), seller contact with email and phone, an electronicAddress for seller and buyer (e.g. EM email, 0204 Leitweg-ID), and payment details. |
xrechnung-cii | XRechnung 3.0 XML in CII syntax | Same rules. With "pdf": true you get the hybrid PDF with xrechnung.xml embedded. |
peppol-bis | Peppol BIS Billing 3.0 XML (UBL) | For the Peppol network (Belgium 2026, Netherlands, Nordics, international). Requires electronicAddress on seller and buyer. Sending through Peppol is not part of Invoir; hand the XML to your access point. |
plain | A branded PDF/A-3 without XML | For customers who don't need an e-invoice yet. Only name, number, date and lines are required. |
The invoice JSON
Required everywhere: profile, number, issueDate, seller.name, buyer.name, at least one line. The e-invoice profiles also need both addresses with a country, the seller's vatId (or taxId / registrationId), a dueDate or payment.terms when an amount is due (EN 16931 rule BR-CO-25; not for Factur-X minimum), and whatever the profile's national rules ask for; the 400 answer lists every missing field at once. Unknown fields are rejected, so a typo can't silently drop data. An empty string counts as not given. Amounts are numbers (or numeric strings), dates are yyyy-MM-dd. Give delivery.date (the date of supply, which a German invoice must state anyway): without any delivery details a Factur-X carries one warning, PEPPOL-EN16931-R008, because the CII schema requires the delivery element even when it is empty.
profile,conformance,number,issueDate,dueDate,currency(defaultEUR),language(de,fr,en,nl; the PDF's labels and number format)- Header fields.
typeis alwaysinvoicefor now (credit notes come later). seller,buyername,tradingName,vatId,taxId,registrationId(+registrationScheme, e.g.0002SIRENE,0106KvK),legalForm,address{street,street2,postalCode,city,region,country},contact{name,email,phone},email,phone,electronicAddress{scheme,id} (EAS code, e.g.EMemail,0088GLN,0204Leitweg-ID,9930German VAT ID),identifier{scheme,id} (your customer number or a GLN). On the buyer:reference(BT-10; the Leitweg-ID for German authorities, or any reference your customer gave you).lines[]description(required),details,quantity(required),unit(UN/ECE Rec. 20:C62piece (default),HURhour,DAY,MON,KGM,MTR,LSlump sum …),unitPrice(net, required),priceBasisQuantity,vatRate(percent; required for category S),vatCategory(Sstandard (default),Zzero rated,Eexempt,AEreverse charge,Kintra-community supply,Gexport,Onot subject to VAT),vatExemptionReason,allowances[]/charges[]({amountorpercent,reason}),periodStart,periodEnd,orderLineId,sellerItemId,buyerItemId,accountingReference.allowances[],charges[](document level)- {
amountorpercent+baseAmount,reasonorreasonCode,vatRate,vatCategory}. The VAT rate defaults to the invoice's only rate when there is just one. paymentmeans(credit_transfer(default with an IBAN),direct_debit,card,cash,other) ormeansCode(UNTDID 4461),iban,bic,accountName,reference(what the payer should quote),terms(free text),mandateId,creditorId,debtorIban(direct debit). IBANs are checksum-validated.deliverydate,periodStart,periodEnd,name,address,locationId.referencesorder,sellerOrder,contract,despatchAdvice,receivingAdvice,tender,project{id,name},precedingInvoice{number,date},buyerAccountingReference,businessProcess.notes[],prepaidAmount,roundingAmount,metadata- Up to 10 notes (printed and in the XML).
metadata: up to 20 string pairs of your own, returned unchanged, never read by us. attachments[]- {
filename,mimeType,description,data(base64)}: supporting documents such as a timesheet, embedded in the PDF and referenced in the XML. Up to 5 files, 5 MB together; PDF, PNG, JPEG, CSV, XLSX or ODS. template,templateHtml,branding,pdf- See templates and branding.
pdf: trueadds a PDF to the XML profiles.
When it fails
400 invalid_request: the JSON can't become an invoice. errors[] names every field and what is wrong, so you can fix them in one go:
{ "error": "invalid_request", "message": "3 problems with the request; see errors[].",
"errors": [ { "field": "buyer.reference", "message": "XRechnung requires the buyer reference (BR-DE-15): …" },
{ "field": "seller.contact.phone", "message": "XRechnung requires a seller contact phone (BR-DE-6); seller.phone also works." },
{ "field": "lines[1].vatRate", "message": "Required and greater than 0 for category S (BR-S-05). Use vatCategory Z for a 0 % line." } ] }
422 invoice_invalid: the document was generated but the official rules rejected it. validation holds the full report with rule IDs and messages, nothing was stored or counted. This is rare after a 400-clean request, but national rules change twice a year and we would rather tell you than hand out an invoice a tax office refuses.
400 invalid_json for malformed JSON, wrong types or unknown fields; 409 idempotency_conflict when an Idempotency-Key is reused with a different body; 404 not_found for a document that doesn't exist, belongs to another account or has expired.
Retries: Idempotency-Key
Send a header Idempotency-Key: <your own id, e.g. the invoice number>. If the request is repeated with the same key and body while the document exists, you get the first answer again (200 with Idempotent-Replayed: true) and nothing is generated or counted. The same key with a different body is a 409. Use it from queues, retries and automation tools, so a timeout can never create two invoices.
Test mode
Create a test key on your dashboard, or from code with your live key: POST /api/v1/keys/test returns an inv_test_… key (shown once; calling it again replaces the previous one). Everything works the same with a test key, except that generated documents carry a TEST watermark on the PDF and the note "Test document – not a valid invoice" in the XML, carry "test": true and are deleted after 24 hours. Test calls never count against your plan. Instead, a test key has 25 calls a day per account that generate, validate, extract or parse (reads such as GET /invoices are free); after that it answers 429 test_limit_exceeded until midnight UTC. That is plenty to build and test an integration; for real documents use the live key. Responses to a test key carry X-Test-Mode: true, X-Test-Limit and X-Test-Used.
Templates and branding
Five built-in templates: modern (default), classic, compact, minimal, bold. Pick one per request with "template": "classic". All five print in the invoice's language with the right number and date formats, use embedded fonts (every PDF is PDF/A-3), and take your branding:
"branding": { "logo": "<base64 PNG or JPEG, up to 512 KB>", "accentColor": "#1f6f4a", "footer": "Musterbau GmbH · Geschäftsführer …" }
Store it once instead of sending it every time: PUT /api/v1/branding with the same fields plus template and language as account defaults (GET shows it, DELETE removes it). Fields in a request override the stored ones. The same defaults can be set on the dashboard's Branding page, which shows a live preview of a sample invoice as you change them.
Your own template. Templates are HTML with Mustache placeholders: {{seller.name}} inserts a value, {{#lines}}…{{/lines}} repeats a block, {{#payment.iban}}…{{/payment.iban}} shows a block only when there is a value, {{^branding.hasLogo}}…{{/branding.hasLogo}} when there isn't. Values are HTML-escaped and already formatted for the language. Start from a built-in one: GET /api/v1/templates/modern returns its source. Save yours with PUT /api/v1/templates/my-layout (body: the HTML, Content-Type: text/html, up to 200 KB), then use "template": "my-layout"; or send it inline as "templateHtml".
What a template can print:
| Placeholder | Contents |
|---|---|
invoice.* | number, typeLabel, issueDate, dueDate, deliveryDate, periodStart, periodEnd, hasPeriod, currency, language, notes[], hasNotes, buyerReference, customerNumber, orderReference, contractReference, projectReference, precedingInvoice |
seller.*, buyer.* | name, tradingName, street, street2, postalCode, city, country, countryName, addressLines[], vatId, taxId, registrationId, legalForm, email, phone, contactName, contactEmail, contactPhone, reference, customerNumber |
delivery.* | name, date, addressLines[], hasAddress |
lines[] | position, description, details, quantity, unit, unitPrice, net, vatRate, vatCategory, periodStart, periodEnd, allowances[] / charges[] (reason, amount, percent) |
totals.* | lineTotal, allowanceTotal, chargeTotal, taxExclusive, vat, taxInclusive, prepaid, rounding, due, hasAdjustments, hasPrepaid, hasRounding, allowances[], charges[] (reason, amountWithCurrency), vatBreakdown[] (label, category, rate, basis, amount), exemptionNotes[], hasExemptionNotes |
payment.* | present, meansLabel, iban (grouped), bic, accountName, reference, terms, mandateId, creditorId, debtorIban, dueDate, isCreditTransfer, isDirectDebit, hasBankAccount |
branding.* | logo (a data: URI for <img src="{{{branding.logo}}}">), hasLogo, accentColor, footer, footerLines[], hasFooter |
labels.* | Every label in the invoice language: invoice, invoiceNumber, invoiceDate, dueDate, billTo, description, quantity, unitPrice, vat, amount, netTotal, grossTotal, amountDue, payment, iban, page, of … |
test | true for test documents (the watermark is added by us in any case) |
Templates render with openhtmltopdf (CSS 2.1 plus paged media: @page, running headers and footers, page counters; no flexbox or grid, use tables). Images must be data: URIs; nothing is fetched from the internet. Fonts: Source Sans Pro, Source Serif Pro, Liberation Sans, Liberation Serif, Liberation Mono; Arial, Helvetica, Times New Roman and Courier New map to the Liberation equivalents. Up to 50 pages.
Examples: generate and download
Each example reads invoice.json (the request body from above), creates the document and saves the PDF and XML next to it. The same examples as files you can run, plus XRechnung and Peppol BIS sample invoices: github.com/invoir-dev/invoir-examples.
curl
doc=$(curl -s https://validate.invoir.dev/api/v1/invoices \
-H "Authorization: Bearer $INVOIR_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: RE-2026-0042" --data-binary @invoice.json)
echo "$doc" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("status") or d.get("error"), d.get("id") or d.get("message"))'
pdf=$(echo "$doc" | python3 -c 'import json,sys; print(json.load(sys.stdin)["pdf"]["url"])')
curl -s -H "Authorization: Bearer $INVOIR_API_KEY" -o invoice.pdf "$pdf"
curl -s -H "Authorization: Bearer $INVOIR_API_KEY" -o invoice.xml "${pdf%/pdf}/xml"
Node.js (18 or newer)
import { readFile, writeFile } from 'node:fs/promises';
const headers = { Authorization: `Bearer ${process.env.INVOIR_API_KEY}` };
const res = await fetch('https://validate.invoir.dev/api/v1/invoices', {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json', 'Idempotency-Key': 'RE-2026-0042' },
body: await readFile('invoice.json', 'utf8'),
});
const doc = await res.json();
if (!res.ok) {
for (const e of doc.errors ?? []) console.error(e.field, e.message); // 400: the request
for (const c of doc.validation?.checks ?? []) { // 422: what the official rules rejected
for (const f of c.findings) console.error(f.rule, f.message, f.location ?? '');
}
throw new Error(`${doc.error}: ${doc.message}`);
}
console.log(doc.id, doc.status, doc.totals.due, doc.totals.currency);
for (const file of [doc.pdf, doc.xml].filter(Boolean)) {
const r = await fetch(file.url, { headers });
await writeFile(file.filename, Buffer.from(await r.arrayBuffer()));
}
Python (requests)
import json, os, requests
headers = {"Authorization": f"Bearer {os.environ['INVOIR_API_KEY']}"}
with open("invoice.json") as f:
invoice = json.load(f)
res = requests.post("https://validate.invoir.dev/api/v1/invoices", json=invoice,
headers={**headers, "Idempotency-Key": invoice["number"]}, timeout=120)
doc = res.json()
if not res.ok:
for e in doc.get("errors", []): # 400: the request
print(e["field"], e["message"])
for check in (doc.get("validation") or {}).get("checks", []): # 422: what the rules rejected
for f in check["findings"]:
print(f["rule"], f["message"], f.get("location") or "")
raise SystemExit(f"{doc['error']}: {doc['message']}")
print(doc["id"], doc["status"], doc["totals"]["due"], doc["totals"]["currency"])
for file in filter(None, [doc["pdf"], doc["xml"]]):
with open(file["filename"], "wb") as out:
out.write(requests.get(file["url"], headers=headers, timeout=60).content)
PHP (curl extension)
<?php
$key = getenv('INVOIR_API_KEY');
$invoice = file_get_contents('invoice.json');
$ch = curl_init('https://validate.invoir.dev/api/v1/invoices');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $key", 'Content-Type: application/json', 'Idempotency-Key: RE-2026-0042'],
CURLOPT_POSTFIELDS => $invoice,
]);
$doc = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
foreach ($doc['errors'] ?? [] as $e) echo "{$e['field']}: {$e['message']}\n"; // 400: the request
foreach ($doc['validation']['checks'] ?? [] as $check) { // 422: what the official rules rejected
foreach ($check['findings'] as $f) echo "{$f['rule']} {$f['message']} " . ($f['location'] ?? '') . "\n";
}
throw new RuntimeException("{$doc['error']}: {$doc['message']}");
}
echo "{$doc['id']} {$doc['status']} {$doc['totals']['due']} {$doc['totals']['currency']}\n";
foreach (array_filter([$doc['pdf'], $doc['xml']]) as $file) {
$dl = curl_init($file['url']);
curl_setopt_array($dl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["Authorization: Bearer $key"]]);
file_put_contents($file['filename'], curl_exec($dl));
}
Go (standard library)
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
type file struct{ URL, Filename string }
type document struct {
ID, Status, Error, Message string
PDF, XML *file
Totals struct{ Due float64; Currency string }
Errors []struct{ Field, Message string }
Validation *struct {
Checks []struct {
Findings []struct{ Rule, Message, Location string }
}
}
}
func main() {
key := os.Getenv("INVOIR_API_KEY")
body, _ := os.ReadFile("invoice.json")
req, _ := http.NewRequest("POST", "https://validate.invoir.dev/api/v1/invoices", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", "RE-2026-0042")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var doc document
json.NewDecoder(res.Body).Decode(&doc)
if res.StatusCode >= 400 {
for _, e := range doc.Errors { // 400: the request
fmt.Println(e.Field, e.Message)
}
if doc.Validation != nil { // 422: what the official rules rejected
for _, c := range doc.Validation.Checks {
for _, f := range c.Findings {
fmt.Println(f.Rule, f.Message, f.Location)
}
}
}
panic(doc.Error + ": " + doc.Message)
}
fmt.Println(doc.ID, doc.Status, doc.Totals.Due, doc.Totals.Currency)
for _, f := range []*file{doc.PDF, doc.XML} {
if f == nil {
continue
}
r, _ := http.NewRequest("GET", f.URL, nil)
r.Header.Set("Authorization", "Bearer "+key)
dl, err := http.DefaultClient.Do(r)
if err != nil {
panic(err)
}
out, _ := os.Create(f.Filename)
io.Copy(out, dl.Body)
out.Close()
dl.Body.Close()
}
}
The complete request and response shapes are in the OpenAPI document: validate.invoir.dev/openapi.json (import it into Postman, Insomnia or your code generator).
POST /validate
Checks a PDF or XML invoice and returns the report.
Request
file- The invoice, as a multipart file field. A Factur-X / ZUGFeRD PDF, or XML in UBL 2.1 or UN/CEFACT CII syntax (XRechnung, Peppol BIS, EN 16931, Factur-X profiles). The format is detected from the content; the file name and declared content type are ignored.
Response: 200 with the report
{
"status": "invalid",
"fileType": "xml",
"format": "EN 16931 XRechnung (UBL Invoice)",
"specificationId": "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0",
"message": null,
"errors": 1,
"warnings": 0,
"checks": [
{
"name": "EN 16931 XRechnung (UBL Invoice)",
"engine": "KoSIT validator 1.6.3 · XRechnung 3.0.2 configuration 2026-08-31",
"passed": false,
"findings": [
{
"severity": "error",
"rule": "BR-CO-15",
"message": "Invoice total amount with VAT (BT-112) = Invoice total amount without VAT (BT-109) + Invoice total VAT amount (BT-110).",
"location": "/ubl:Invoice/cac:LegalMonetaryTotal",
"line": 142
}
]
}
],
"embeddedXml": null,
"durationMs": 340
}
statusvalid(no errors; warnings allowed),invalid(at least one error), orunsupported(not an e-invoice we can check; seemessage). Note that an unsupported file is still a200: the request worked, the file just isn't an invoice.fileTypepdf,xmlorunknown.format- What was detected, for people: for example
EN 16931 XRechnung (UBL Invoice),Peppol BIS Billing 3.0 (UBL Invoice)orPDF · Factur-X / ZUGFeRD EN 16931 (COMFORT). Null when nothing was recognised. specificationId- The CustomizationID (UBL) or GuidelineSpecifiedDocumentContextParameter (CII) found in the XML, which decides the rule set.
errors,warnings- Totals over all checks.
checks[]- One entry per validation step, in the order they ran. For a PDF: the PDF/A-3 and metadata check, then the embedded XML's rules.
enginenames the engine and rule-set versions that produced it.passedis false when the step has errors. checks[].findings[]severityiserror,warningorinfo;ruleis the ID as published by the rule set (BR-CO-15,PEPPOL-EN16931-R003,BR-DE-15, …);messagethe rule's own text;locationa simplified XPath into the XML, or a PDF object path for PDF/A findings;linethe line in the XML when the engine reports one. Both may be null.embeddedXml- For PDFs: the invoice XML that was extracted and checked, as a string. Null for XML uploads.
durationMs- Processing time on our side.
POST /extract
Returns the XML embedded in a Factur-X / ZUGFeRD PDF without validating it. Same request shape as /validate.
{
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rsm:CrossIndustryInvoice …",
"format": "Factur-X / ZUGFeRD EN 16931 (COMFORT)",
"specificationId": "urn:cen.eu:en16931:2017"
}
A PDF without an invoice attachment answers 422 no_embedded_xml. Each successful extraction counts as one document, like a validation.
POST /parse: read a received e-invoice
The receiving side: upload an e-invoice you received and get it back as the same invoice JSON that POST /invoices takes, plus the amounts as the document states them, every value that JSON has no field for, and the full validation report. One call; nothing is stored. What arrives in which format, and what goes wrong when you parse it yourself: read received e-invoices into JSON.
curl https://validate.invoir.dev/api/v1/parse \
-H "Authorization: Bearer $INVOIR_API_KEY" \
-F file=@received-invoice.xml
Request
file- The invoice, as a multipart file field (up to 10 MB): XRechnung (UBL or CII), Peppol BIS Billing 3.0, plain EN 16931 UBL or CII, Factur-X / ZUGFeRD 2.x XML, or a hybrid PDF with that XML attached. The format is detected from the content. A PDF without an invoice XML has nothing to read: there is no OCR.
Response: 200 with the invoice
{
"status": "valid",
"format": "EN 16931 XRechnung (UBL Invoice)",
"typeCode": "380",
"invoice": {
"profile": "xrechnung-ubl",
"type": "invoice",
"number": "RE-2026-0042",
"issueDate": "2026-10-19",
"dueDate": "2026-11-18",
"currency": "EUR",
"seller": {
"name": "Musterbau GmbH",
"vatId": "DE123456789",
"address": { "street": "Industriestraße 12", "postalCode": "80331", "city": "München", "country": "DE" },
"contact": { "name": "Erika Mustermann", "email": "rechnung@musterbau.example" },
"electronicAddress": { "scheme": "EM", "id": "rechnung@musterbau.example" }
},
"buyer": { "name": "Beispiel AG", "reference": "PO-4711", "…": "…" },
"lines": [
{ "id": "1", "description": "Beratung Softwarearchitektur", "quantity": 12.5, "unit": "HUR",
"unitPrice": 140, "vatRate": 19, "vatCategory": "S" }
],
"payment": { "means": "credit_transfer", "iban": "DE89370400440532013000", "reference": "RE-2026-0042",
"terms": "Zahlbar innerhalb von 30 Tagen ohne Abzug." },
"references": { "order": "PO-4711" }
},
"totals": {
"currency": "EUR", "lineTotal": 1750.00, "allowanceTotal": null, "chargeTotal": null,
"taxExclusive": 1750.00, "vat": 332.50, "taxInclusive": 2082.50, "prepaid": null, "rounding": null, "due": 2082.50,
"vatBreakdown": [ { "category": "S", "rate": 19, "basis": 1750.00, "amount": 332.50, "exemptionReason": null } ]
},
"unmapped": [
{ "path": "InvoiceLine/Item/CommodityClassification/ItemClassificationCode", "value": "86101500" }
],
"warnings": [],
"validation": { "status": "valid", "…": "the same report as POST /validate" }
}
status- The validation's verdict, as in
/validate:valid,invalidorunsupported. An invalid document is still read, so you can store it and send the findings back to whoever issued it. format,typeCode- What was detected.
typeCodeis BT-3 as found:380invoice,381credit note,384corrected invoice,389self-billed invoice … invoice- The invoice in the
POST /invoicesJSON, with empty fields left out.profile(andconformancefor Factur-X) say which profile the document is; plain EN 16931 UBL has none.typeisinvoiceorcredit_note. VAT exemption reasons, which the XML states once per VAT category, are on the lines, where the JSON keeps them. Sent back toPOST /invoices, the JSON gives a document with the same content (not yet for credit notes, and Factur-X MINIMUM and BASIC WL carry no lines). totals- The amounts as the document states them (BG-22 and the VAT breakdown), in the same shape as the
totalsofPOST /invoices. Book these:POST /invoicesalways calculates its own. unmapped[]- Every value in the XML that the invoice JSON has no field for: a second identifier, line notes, item attributes and classifications, the payee, a tax representative …
pathis the element names from below the root ([2]for the second of a kind),valueits text, cut at 200 characters. Nothing is dropped without being listed here. warnings[]- What reading noticed, as sentences: stated totals that differ from a recalculation from the lines, a value that is not a number or date (it is then in
unmapped), a credit note, a document without lines. validation- The full report, the same as
POST /validatereturns.
A file with nothing to read answers 422: not_an_invoice (no UBL or CII invoice, or a PDF without one), invalid_xml (not well-formed, or it declares a DOCTYPE) or unsupported_syntax (ZUGFeRD 1.0, retired in 2019). Each successful parse counts as one document; errors don't count, and test keys use their daily test calls instead.
Examples: parse
Node.js (18 or newer, no dependencies):
import { readFile } from 'node:fs/promises';
const body = new FormData();
body.append('file', new Blob([await readFile('received-invoice.pdf')]), 'received-invoice.pdf');
const res = await fetch('https://validate.invoir.dev/api/v1/parse', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.INVOIR_API_KEY}` },
body,
});
const parsed = await res.json();
if (!res.ok) throw new Error(`${parsed.error}: ${parsed.message}`);
const { invoice, totals } = parsed;
console.log(parsed.status, invoice.number, invoice.seller.name, totals.due, totals.currency);
for (const line of invoice.lines ?? []) console.log(line.quantity, line.unit, line.description, line.unitPrice);
for (const w of parsed.warnings) console.warn(w);
Python (requests):
import os
import requests
with open("received-invoice.pdf", "rb") as f:
res = requests.post(
"https://validate.invoir.dev/api/v1/parse",
headers={"Authorization": f"Bearer {os.environ['INVOIR_API_KEY']}"},
files={"file": ("received-invoice.pdf", f)},
timeout=60,
)
parsed = res.json()
if not res.ok:
raise SystemExit(f"{parsed['error']}: {parsed['message']}")
invoice, totals = parsed["invoice"], parsed["totals"]
print(parsed["status"], invoice["number"], invoice["seller"]["name"], totals["due"], totals["currency"])
for line in invoice.get("lines", []):
print(line.get("quantity"), line.get("unit"), line.get("description"), line.get("unitPrice"))
for warning in parsed["warnings"]:
print("warning:", warning)
Errors
Every error is JSON with a stable error code and a message for people:
{ "error": "quota_exceeded", "message": "The free plan includes 25 documents per month …" }
| HTTP | error | When |
|---|---|---|
| 400 | no_file | The request is not multipart/form-data or has no file field. |
| 400 | empty_file | The file has zero bytes. |
| 400 | invalid_request | /invoices: the JSON can't become an invoice; errors[] names each field. |
| 400 | invalid_json | Malformed JSON, a wrong type, or an unknown field. |
| 409 | idempotency_conflict | An Idempotency-Key reused with a different body. |
| 415 | unsupported_media_type | Wrong Content-Type for the endpoint. |
| 422 | invoice_invalid | /invoices: the generated document failed the official rules; see validation. Nothing stored or counted. |
| 401 | missing_api_key | No Authorization: Bearer header. |
| 401 | invalid_api_key | Unknown key, or one that was revoked. |
| 404 | not_found | No such endpoint, or no such document / template for this account. |
| 405 | method_not_allowed | Use POST. |
| 413 | file_too_large | Over 10 MB. |
| 422 | no_embedded_xml | /extract on a PDF without an invoice attachment. |
| 422 | not_an_invoice | /parse: no UBL or CII invoice in the file, or a PDF without one. Not counted. |
| 422 | invalid_xml | /parse: the XML is not well-formed or declares a DOCTYPE. Not counted. |
| 422 | unsupported_syntax | /parse: ZUGFeRD 1.0, which can be validated but not read. Not counted. |
| 429 | test_limit_exceeded | A test key's 25 calls for the day are used up; they start again at midnight UTC. Use the live key for real documents. |
| 429 | quota_exceeded | The free plan's 25 documents for the month are used up; see the X-Quota-Reset header, or upgrade. Paid plans never answer this. |
| 503 | busy | All validation slots were busy for 30 s. Retry after the seconds in Retry-After. |
| 500 | internal_error | Our fault. Email hello@invoir.dev if it repeats. |
Plans, quota and limits
Usage is counted in documents per calendar month (UTC), per account. A document is one successful call to /invoices (one generated invoice, PDF and XML together), /validate, /extract or /parse; error responses and Idempotency-Key replays don't count, and test keys never count against the plan (they have 25 calls a day of their own). Every response to a key carries where the account stands:
X-Quota-Limit: 300
X-Quota-Used: 7
X-Quota-Reset: 2026-11-01
X-Plan: starter
The free plan includes 25 documents a month; beyond that the API answers 429 quota_exceeded until the reset date. Paid plans include 300, 2,000 or 10,000 documents a month (pricing) and are never stopped: documents beyond the allowance are charged per document at the start of the following month. Upgrade, switch or cancel in the dashboard; a change applies to the quota immediately.
Other limits: files up to 10 MB; invoice JSON up to 12 MB including attachments (5 files, 5 MB together) and a logo (512 KB); templates up to 200 KB and 50 pages; 500 lines per invoice. A few validations or generations run at the same time and the rest wait up to 30 seconds, after which you get 503 busy with a Retry-After header. A validation typically takes between 50 ms (XML) and 2 s (large PDF); a generation 1 to 4 s. Set a client timeout of 120 seconds.
Validation examples
Each example posts invoice.pdf to /validate, reads the key from the INVOIR_API_KEY environment variable and prints the findings. Replace the file name with any PDF or XML invoice. (Generation examples are above; all of them as runnable files: github.com/invoir-dev/invoir-examples.)
curl
curl https://validate.invoir.dev/api/v1/validate \
-H "Authorization: Bearer $INVOIR_API_KEY" \
-F file=@invoice.pdf
Node.js (18 or newer, no dependencies)
import { readFile } from 'node:fs/promises';
const body = new FormData();
body.append('file', new Blob([await readFile('invoice.pdf')]), 'invoice.pdf');
const res = await fetch('https://validate.invoir.dev/api/v1/validate', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.INVOIR_API_KEY}` },
body,
});
const report = await res.json();
if (!res.ok) throw new Error(`${report.error}: ${report.message}`);
console.log(report.status, report.format, `${report.errors} errors`);
for (const check of report.checks) {
for (const f of check.findings) console.log(f.severity, f.rule, f.message, f.location ?? '');
}
Python (requests)
import os
import requests
with open("invoice.pdf", "rb") as f:
res = requests.post(
"https://validate.invoir.dev/api/v1/validate",
headers={"Authorization": f"Bearer {os.environ['INVOIR_API_KEY']}"},
files={"file": ("invoice.pdf", f)},
timeout=60,
)
report = res.json()
if not res.ok:
raise SystemExit(f"{report['error']}: {report['message']}")
print(report["status"], report["format"], report["errors"], "errors")
for check in report["checks"]:
for finding in check["findings"]:
print(finding["severity"], finding["rule"], finding["message"], finding.get("location") or "")
PHP (curl extension)
<?php
$ch = curl_init('https://validate.invoir.dev/api/v1/validate');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('INVOIR_API_KEY')],
CURLOPT_POSTFIELDS => ['file' => new CURLFile('invoice.pdf', 'application/pdf', 'invoice.pdf')],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$report = json_decode($body, true);
if ($status >= 400) {
throw new RuntimeException("{$report['error']}: {$report['message']}");
}
echo "{$report['status']} {$report['format']} {$report['errors']} errors\n";
foreach ($report['checks'] as $check) {
foreach ($check['findings'] as $f) {
echo "{$f['severity']} {$f['rule']} {$f['message']} " . ($f['location'] ?? '') . "\n";
}
}
Go (standard library)
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
"time"
)
type report struct {
Status string `json:"status"`
Format string `json:"format"`
Errors int `json:"errors"`
Error string `json:"error"`
Message string `json:"message"`
Checks []struct {
Findings []struct {
Severity, Rule, Message, Location string
} `json:"findings"`
} `json:"checks"`
}
func main() {
var body bytes.Buffer
w := multipart.NewWriter(&body)
part, _ := w.CreateFormFile("file", "invoice.pdf")
f, err := os.Open("invoice.pdf")
if err != nil {
panic(err)
}
io.Copy(part, f)
f.Close()
w.Close()
req, _ := http.NewRequest("POST", "https://validate.invoir.dev/api/v1/validate", &body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INVOIR_API_KEY"))
req.Header.Set("Content-Type", w.FormDataContentType())
client := &http.Client{Timeout: 60 * time.Second}
res, err := client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var r report
json.NewDecoder(res.Body).Decode(&r)
if res.StatusCode >= 400 {
panic(r.Error + ": " + r.Message)
}
fmt.Println(r.Status, r.Format, r.Errors, "errors")
for _, c := range r.Checks {
for _, f := range c.Findings {
fmt.Println(f.Severity, f.Rule, f.Message, f.Location)
}
}
}
What is checked
| Input | Engine | Rules |
|---|---|---|
| PDF (Factur-X, ZUGFeRD, ZUGFeRD-XRechnung) | Mustang + veraPDF | PDF/A-3 conformance and the Factur-X XMP metadata; then the embedded XML as below |
| XRechnung UBL or CII | KoSIT validator | The official KoSIT XRechnung configuration, including its accept/reject decision |
| Peppol BIS Billing 3.0 | KoSIT validator | UBL 2.1 schema, CEN EN 16931 rules and the OpenPeppol BIS Schematron with its country rules |
| Plain EN 16931 UBL or CII | KoSIT validator | The CEN rules |
| Factur-X / ZUGFeRD CII XML | Mustang | XSD and Schematron of the declared profile (MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED, XRECHNUNG) |
No rule is hand-written: everything comes from the published rule sets, and every report names the engine and rule-set versions in checks[].engine. The versions currently in use are listed on the validator page. When a rule set is updated (KoSIT publishes XRechnung releases twice a year, OpenPeppol three times), the API follows within days; the API shape stays the same.
Generated documents go through exactly these checks before they are returned, and the validation field of a POST /invoices answer is this same report. Something missing for your market? Email hello@invoir.dev.