Invoice to a public authority (XRechnung with Leitweg-ID)

You are invoicing a public body and need an XRechnung carrying the correct Leitweg-ID.

Steps

  1. 1

    Ask the recipient for the Leitweg-ID — it comes with the order or the procurement portal, not from your own master data.

  2. 2

    Pass it as countrySpecific.leitwegId and choose the xrechnung format.

  3. 3

    The response is the finished UBL XML, ready to hand to the invoice portal.

The call

POST /api/v1/invoice/DE/xrechnung/generate

bash
1curl -X POST https://api.invoice-api.xhub.io/api/v1/invoice/DE/xrechnung/generate \
2 -H "X-API-Key: $INVOICE_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "invoice": {
6 "invoiceNumber": "RE-2025-001",
7 "type": "invoice",
8 "issueDate": "2025-01-15",
9 "dueDate": "2025-02-15",
10 "currency": "EUR",
11 "seller": {
12 "name": "Muster GmbH",
13 "vatId": "DE811128135",
14 "street": "Musterstraße 1",
15 "postalCode": "10115",
16 "city": "Berlin",
17 "countryCode": "DE",
18 "email": "info@muster.de",
19 "phone": "+49 30 12345678"
20 },
21 "buyer": {
22 "name": "Beispiel AG",
23 "vatId": "DE136695976",
24 "street": "Beispielweg 42",
25 "postalCode": "80331",
26 "city": "München",
27 "countryCode": "DE"
28 },
29 "items": [
30 {
31 "position": 1,
32 "description": "Beratungsleistung",
33 "quantity": 10,
34 "unit": "HUR",
35 "unitPrice": 150,
36 "taxRate": 19,
37 "netAmount": 1500,
38 "taxAmount": 285,
39 "grossAmount": 1785
40 }
41 ],
42 "taxSummary": [
43 {
44 "taxRate": 19,
45 "netAmount": 1500,
46 "taxAmount": 285
47 }
48 ],
49 "subtotal": 1500,
50 "total": 1785,
51 "countrySpecific": {
52 "countryCode": "DE",
53 "leitwegId": "991-12345-67"
54 }
55 }
56}'

Where this goes wrong

Without the Leitweg-ID, BR-DE-01 fails. It is not a customer number and cannot be guessed — without it the authority will not accept the invoice.