REST API for developers
Quickstart: your first e-invoice via the API
From the API key to the ZUGFeRD PDF in a few steps, with examples you can copy.
Contents
How it works
-
Create an API key
Create a key in your account and send it with every request in the headerAuthorization: Api-Key <key>. When creating it, you choose how long the key is valid: unlimited, 30 days, 90 days, 1 year or until a date of your choice. Requests with an expired key are rejected with HTTP 401. API Keys -
Send the invoice as JSON
POST /api/v1/invoices/creates the invoice; the response contains itsid. Intax_breakdowns, specify one entry per tax category and rate; totals and tax amounts are recalculated from the line items. For a follow-up invoice,POST /api/v1/invoices/{invoice_id}/copy/creates a new draft from an existing outgoing invoice, without invoice number and dates. -
Retrieve PDF/A-3 or XRechnung XML
POST /api/v1/invoices/{invoice_id}/generate_zugferd_pdf/returns the ZUGFeRD PDF/A-3 with embedded XML. For invoices with the profileXRECHNUNG(public authorities, with Leitweg-ID inbuyer_reference),POST /api/v1/invoices/{invoice_id}/generate_xrechnung/returns the XRechnung XML. Created files can be downloaded again viaGET /api/v1/invoices/{invoice_id}/download/. In the Pro and Business plans, the optional fielddesignof an invoice selects one of your own invoice designs for the PDF (the ID is shown in the invoice design editor); without it, your default design applies. Without this plan feature, the request answers with HTTP 403; an unknown or inactive design with HTTP 400. The XML is not affected. From the Starter plan, the optional fielddocument_language(deoren) sets the language of the PDF for one invoice; empty means the language of the invoice design. The PDF language follows this field, then the invoice design, then theAccept-Languageheader of the request (only without a saved invoice design), otherwise German. Without this plan feature, setting a language answers with HTTP 403 andcodeinvoice_document_language_locked, and the PDF stays German. -
Check the result
If the validation fails, you receive HTTP 400 with the validator messages instead of a file. You can also check existing XML files:POST /api/v1/validate/with the file in the form fieldinvoice_filereturns errors and warnings. Withinclude_explanations=true, the response also explains each reported rule (meaning, causes, how to fix it);GET /api/v1/validation-rules/{rule_id}/explains a single rule without counting towards the validations.
Authentication, error responses, rate limits, quotas and data formats in detail: Implementation details.
Step-by-step guides with code and the expected responses:
Examples
Invoice data (invoice.json)
{
"invoice_number": "RE-2026-001",
"issue_date": "2026-10-01",
"delivery_date": "2026-10-01",
"type_code": "380",
"currency_code": "EUR",
"payment_terms": "Zahlbar innerhalb von 14 Tagen ohne Abzug",
"seller": {
"name": "Muster GmbH",
"street": "Musterstraße 1",
"postal_code": "10115",
"city": "Berlin",
"country_code": "DE",
"vat_id": "DE123456789",
"contact_name": "Max Mustermann",
"contact_phone": "+49 30 12345678",
"contact_email": "rechnung@muster.example"
},
"buyer": {
"name": "Käufer AG",
"street": "Käuferstraße 5",
"postal_code": "80331",
"city": "München",
"country_code": "DE",
"vat_id": "DE987654321"
},
"items": [
{
"line_id": "1",
"name": "Beratungsleistung",
"quantity": "8",
"unit_code": "HUR",
"net_price": "95.00",
"tax_category": "S",
"tax_rate": "19.00"
}
],
"tax_breakdowns": [
{
"tax_category": "S",
"tax_rate": "19.00",
"basis_amount": "760.00",
"tax_amount": "144.40"
}
]
}
Create an invoice and the ZUGFeRD PDF
The same steps in four languages: POST /api/v1/invoices/ with invoice.json, then POST /api/v1/invoices/{invoice_id}/generate_zugferd_pdf/ with the returned id. The response is the PDF file (application/pdf); if the invoice does not pass the check, you receive HTTP 400 with the validator messages.
curl -X POST "https://www.e-rechnungsfreund.de/api/v1/invoices/" \
-H "Authorization: Api-Key $API_KEY" \
-H "Content-Type: application/json" \
-d @invoice.json
curl -X POST "https://www.e-rechnungsfreund.de/api/v1/invoices/$INVOICE_ID/generate_zugferd_pdf/" \
-H "Authorization: Api-Key $API_KEY" \
-o invoice.pdf
import json
import requests
BASE_URL = "https://www.e-rechnungsfreund.de"
HEADERS = {"Authorization": "Api-Key YOUR_API_KEY"}
with open("invoice.json", encoding="utf-8") as f:
invoice = json.load(f)
response = requests.post(f"{BASE_URL}/api/v1/invoices/", json=invoice, headers=HEADERS, timeout=30)
response.raise_for_status()
invoice_id = response.json()["id"]
pdf = requests.post(
f"{BASE_URL}/api/v1/invoices/{invoice_id}/generate_zugferd_pdf/",
headers=HEADERS,
timeout=120,
)
if pdf.status_code == 400:
print(pdf.json())
else:
pdf.raise_for_status()
with open("invoice.pdf", "wb") as f:
f.write(pdf.content)
import { readFile, writeFile } from "node:fs/promises";
const BASE_URL = "https://www.e-rechnungsfreund.de";
const HEADERS = { Authorization: "Api-Key YOUR_API_KEY" };
const invoice = await readFile("invoice.json", "utf8");
const response = await fetch(`${BASE_URL}/api/v1/invoices/`, {
method: "POST",
headers: { ...HEADERS, "Content-Type": "application/json" },
body: invoice,
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const { id: invoiceId } = await response.json();
const pdf = await fetch(`${BASE_URL}/api/v1/invoices/${invoiceId}/generate_zugferd_pdf/`, {
method: "POST",
headers: HEADERS,
});
if (pdf.status === 400) {
console.log(await pdf.json());
} else if (!pdf.ok) {
throw new Error(`HTTP ${pdf.status}: ${await pdf.text()}`);
} else {
await writeFile("invoice.pdf", Buffer.from(await pdf.arrayBuffer()));
}
<?php
$baseUrl = 'https://www.e-rechnungsfreund.de';
$apiKey = 'YOUR_API_KEY';
function post(string $url, string $apiKey, $body, array $headers = []): array
{
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => array_merge(["Authorization: Api-Key $apiKey"], $headers),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
return [curl_getinfo($ch, CURLINFO_RESPONSE_CODE), $response];
}
[$status, $body] = post("$baseUrl/api/v1/invoices/", $apiKey, file_get_contents('invoice.json'), ['Content-Type: application/json']);
if ($status !== 201) {
exit("HTTP $status: $body\n");
}
$invoiceId = json_decode($body, true)['id'];
[$status, $pdf] = post("$baseUrl/api/v1/invoices/$invoiceId/generate_zugferd_pdf/", $apiKey, '');
if ($status === 400) {
print_r(json_decode($pdf, true));
} elseif ($status !== 200) {
exit("HTTP $status: $pdf\n");
} else {
file_put_contents('invoice.pdf', $pdf);
}
Example response: POST /api/v1/invoices/ → 201 Created
Excerpt: the response contains all fields of the invoice, including the calculated totals.
{
"id": "3ff6fce7-0c0f-4726-8288-92947decc8aa",
"is_xrechnung": false,
"profile": "EN16931",
"invoice_number": "RE-2026-001",
"issue_date": "2026-10-01",
"type_code": "380",
"currency_code": "EUR",
"line_total_amount": "760.0000",
"tax_basis_total_amount": "760.0000",
"tax_total_amount": "144.4000",
"grand_total_amount": "904.4000",
"due_payable_amount": "904.4000",
"is_paid": false,
"export_status": "not_generated",
"created_at": "2026-10-01T09:30:00.000000Z",
"items": [
{
"id": "8be0e456-ae96-4a52-9139-f5359580fec3",
"line_id": "1",
"name": "Beratungsleistung",
"quantity": "8.0000",
"unit_code": "HUR",
"net_price": "95.0000",
"line_total_amount": "760.0000",
"tax_rate": "19.00",
"tax_category": "S"
}
]
}
All fields, optional information (e.g. payment means, allowances and charges, notes) and the response formats are described in the API documentation. Open API documentation
Examples on GitHub: curl, Python, PHP, Node.js
Claude Code and scripts
Agents with a shell (such as Claude Code) and scripts can send an invoice file directly to POST /api/v1/validate/ with the API key, without Base64 in a tool call:
curl -X POST "https://www.e-rechnungsfreund.de/api/v1/validate/" \
-H "Authorization: Api-Key $API_KEY" \
-F "invoice_file=@invoice.pdf"
Example response: POST /api/v1/validate/ → 200 OK
Excerpt: the response also contains the extracted invoice data (info), the duration and further details per validator.
{
"is_valid": true,
"errors": [],
"detected_format": "ZUGFERD_CII",
"kosit": {
"is_valid": true,
"errors": [],
"warnings": [],
"method": "daemon",
"applicable": true
},
"mustang": {
"is_valid": true,
"errors": []
},
"saxon": {
"is_valid": true,
"errors": [],
"warnings": [],
"method": "saxon (xslt 2.0)"
},
"filename": "invoice.pdf",
"quota": {
"used": 1,
"limit": 30,
"remaining": 29,
"period_end": "2026-11-01T00:00:00+00:00"
}
}
Read e-invoices
Received e-invoices (XRechnung in CII or UBL syntax, ZUGFeRD or Factur-X as PDF or XML) can be read as JSON, for example to transfer them into your own system. Both ways take the file in the form field invoice_file and return the invoice data in the same structure in the field info, together with the recognised format (detected_format):
-
Fast, without validation:
POST /api/v1/extract/only reads the file. No validator runs, so the response is faster and always contains"validated": false. Reading does not count towards the monthly validations of your plan. -
With validation:
POST /api/v1/validate/checks the invoice against the official KoSIT rules and returns the same data ininfo. Each request counts as one validation.
Data read without validation may come from an invoice with errors. Validate an invoice before you rely on its content.
curl -X POST "https://www.e-rechnungsfreund.de/api/v1/extract/" \
-H "Authorization: Api-Key $API_KEY" \
-F "invoice_file=@invoice.pdf"
import requests
BASE_URL = "https://www.e-rechnungsfreund.de"
HEADERS = {"Authorization": "Api-Key YOUR_API_KEY"}
with open("invoice.pdf", "rb") as f:
response = requests.post(
f"{BASE_URL}/api/v1/extract/",
files={"invoice_file": ("invoice.pdf", f)},
headers=HEADERS,
timeout=30,
)
response.raise_for_status()
data = response.json()
info = data["info"] # not validated: data["validated"] is False
print(data["detected_format"], info["invoice_number"], info["totals"]["due_amount"])
Example response: POST /api/v1/extract/ → 200 OK
Excerpt: info contains all fields of the invoice, the same as in the response of the validation.
{
"validated": false,
"detected_format": "ZUGFERD_CII",
"profile": "urn:cen.eu:en16931:2017",
"info": {
"invoice_number": "RE-2026-001",
"issue_date": "20261001",
"currency": "EUR",
"seller": {
"name": "Muster GmbH",
"vat_id": "DE123456789"
},
"buyer": {
"name": "Käufer AG"
},
"totals": {
"tax_basis_total": "760.00",
"tax_total": "144.40",
"grand_total": "904.40",
"due_amount": "904.40"
},
"items": [
{
"line_id": "1",
"name": "Beratungsleistung",
"quantity": "8.0000",
"unit_code": "HUR"
}
]
},
"filename": "invoice.pdf",
"validate_url": "https://www.e-rechnungsfreund.de/api/v1/validate/",
"notice": "The file was only read, not validated: no KoSIT, Mustang or EN 16931 rule check was run. To check whether the e-invoice is valid, send the same file to POST /api/v1/validate/ (validate_url).",
"duration_ms": 45
}