Germany (XRechnung and ZUGFeRD)
Germany requires structured e-invoices (EN 16931) between domestic businesses, and XRechnung for public-sector buyers. Space Invoices exports your finalized invoices and credit notes in both formats.
What Space Invoices handles
- We export XRechnung (UBL XML) and ZUGFeRD / Factur-X (PDF with embedded XML) for invoices and credit notes.
- We check each document against the EN 16931 rules and return the failing fields, so you can fix them before the invoice is issued.
- We choose the EN 16931 VAT category per line (standard, zero, exempt, reverse charge, intra-community supply, export).
- We derive the buyer’s electronic address from the Peppol ID, VAT ID or email, whichever is available first.
- We put the Leitweg-ID on the invoice as the buyer reference.
Not supported:
- Exporting drafts. The document must be finalized.
- Submitting the file to a public-sector portal. You download the file and deliver it yourself, or send over Peppol.
Laws and standards
| Name | What it is |
|---|---|
| Wachstumschancengesetz and § 14 UStG | German law that makes e-invoices mandatory between domestic businesses. Every business must be able to receive them since 2025. Issuing becomes mandatory in stages from 2027 and 2028. |
| EN 16931 | The European semantic standard for e-invoices. Both formats follow it. |
| XRechnung | The German EN 16931 profile (UBL XML), required for public-sector buyers. |
| ZUGFeRD / Factur-X | A PDF invoice with embedded structured XML (CII). |
| Leitweg-ID | The routing ID of a public-sector buyer. It is the buyer reference on the invoice. |
Before you start
| You need | Where you get it |
|---|---|
| Seller VAT ID (USt-IdNr.) or tax number (Steuernummer) | Your tax office. A commercial register number such as HRB 123456 is not a tax number. |
| Leitweg-ID (public-sector buyers only) | Your customer. |
Setup
Do this once per entity.
1. Enable the exports
Enable XRechnung, ZUGFeRD or both.
await sdk.entities.update(entity.id, {
settings: {
xrechnung: { enabled: true },
zugferd: { enabled: true },
},
});2. Complete the seller details
The seller needs a contact email, phone number, tax identifier and a default bank account. Intra-community supplies (K) and exports (G) need the VAT ID. Small businesses under § 19 UStG can use the Steuernummer (tax_number_2) alone.
await sdk.entities.update(entity.id, {
email: "rechnung@beispiel-gmbh.example", // Germany: required for XRechnung
phone: "+49 30 1234567", // Germany: seller contact phone
tax_number: "DE123456789", // Germany: VAT ID, or tax_number_2
settings: {
bank_accounts: [
{
iban: "DE89370400440532013000",
is_default: true,
},
], // Germany: IBAN for payment instructions
},
});Issue a compliant invoice
Create invoices as usual. On top of the standard invoice fields, add:
Any customer
| Field | When |
|---|---|
customer.address, customer.city, customer.post_code | Always. |
customer.email | XRechnung only, unless you send customer.tax_number (VAT ID) or customer.peppol_id. This is the buyer electronic address. ZUGFeRD does not need it. |
customer.e_invoicing.buyer_reference | XRechnung: always. The Leitweg-ID for public-sector buyers, otherwise the reference your buyer gives you (for example their order number). ZUGFeRD does not need it. |
date_service | Always. The service or delivery date. |
The VAT ID works as the electronic address only for these countries: AT, BE, BG, CY, CZ, DE, EE, ES, FR, GB, GR, HR, IE, LU, NL, PL, PT, SI, SK, US. For any other country, send an email or a Peppol ID.
const _invoice = await sdk.invoices.create({
customer: {
name: "Muster GmbH",
address: "Hauptstraße 1", // Germany: buyer address is required
city: "Berlin",
post_code: "10115",
email: "buchhaltung@muster-gmbh.example", // Germany: buyer e-address
e_invoicing: {
buyer_reference: "PO-2026-17", // Germany: XRechnung buyer ref (BT-10)
},
},
date_service: "2026-11-01", // Germany: service or delivery date
items: [
{
name: "Consulting",
quantity: 1,
price: 1000,
taxes: [{ rate: 19 }],
},
],
});Public-sector buyers
| Field | When |
|---|---|
customer.e_invoicing.buyer_reference | Always for public-sector buyers. The Leitweg-ID. |
const _invoice = await sdk.invoices.create({
customer: {
name: "Stadtwerke Beispiel",
address: "Rathausplatz 1",
city: "Berlin",
post_code: "10115",
email: "rechnung@stadtwerke-beispiel.example",
e_invoicing: {
buyer_reference: "04011000-12345-03", // Germany: the buyer's Leitweg-ID
},
},
date_service: "2026-11-01",
items: [
{
name: "Platform subscription",
quantity: 1,
price: 1200,
taxes: [{ rate: 19 }],
},
],
});Tax-free sales to the EU or abroad
| Field | When |
|---|---|
customer.country_code | The buyer’s country. We derive the sale type (transaction_type in the response: intra_eu_b2b, 3w_b2b, 3w_b2c) from it and the VAT ID. |
items[].classification | product on goods lines. Without it the line is exported as reverse charge (AE) or zero-rated (Z) instead of intra-community supply (K) or export (G). |
customer.tax_number | Intra-community supply and reverse charge: the buyer’s VAT ID. Reverse charge also accepts customer.company_number. |
date_service | Intra-community supply: the delivery date. |
const _invoice = await sdk.invoices.create({
customer: {
name: "Société Exemple SARL",
address: "12 rue de la Paix",
city: "Paris",
post_code: "75002",
country_code: "FR",
tax_number: "FR12345678901", // Germany: buyer VAT ID, no VAT charged
e_invoicing: {
buyer_reference: "PO-2026-18", // Germany: XRechnung buyer ref (BT-10)
},
},
date_service: "2026-11-01", // Germany: delivery date, required
items: [
{
name: "Industrial sensor",
quantity: 10,
price: 120,
classification: "product", // Germany: goods = intra-community supply
},
],
});Export the file
Use the document menu in the app, or call the API. Credit notes work the same way.
const _xml = await sdk.invoices.downloadInvoiceXRechnung(invoice.id);const _pdf = await sdk.invoices.downloadInvoiceZugferd(invoice.id);Special cases
- Block bad invoices up front. Send
xrechnung: { validation_required: true }(orzugferd) when creating a final document to refuse it if validation fails. Without it, the failure appears when you export. An export that fails returns422listing the fields. - XRechnung is stricter. The seller email and the buyer electronic address are required for XRechnung only. ZUGFeRD does not need them.
- Exemption text. Override the VAT category of a zero-tax line with
items[].e_invoicing.vat_category(codeisZ,E,AE,KorG;exemption_reason_codeandexemption_reasonare optional). The reason code must be a VATEX code that fits the category. The text defaults to the documenttax_clause, then to a standard text. - Delivery country.
Kneeds the delivery to be in another EU country andGoutside the EU. We usedelivery_address.country_code, or the customer’s country when there is none. - Units. An unsupported
items[].unitfails validation. Setitems[].e_invoicing.unit_codeto override it. - Currency. Crypto-denominated documents cannot be exported because EN 16931 needs an ISO 4217 currency. When a foreign-currency invoice has an exchange rate to EUR, the e-invoice also states the VAT total in EUR (BT-6 and BT-111).
Common errors
| Error | Fix |
|---|---|
422 exports must be enabled | Turn on XRechnung or ZUGFeRD in the entity settings. The entity must be German. |
422 Cannot export draft documents | Finalize the document first. |
issuer.email: Seller email is required for XRechnung | Set the entity email. |
issuer.phone: Seller contact phone is required | Set the entity phone. |
issuer.bank_account.iban: Seller IBAN is required | Add a default bank account with an IBAN to the entity. |
issuer.tax_number: seller tax identifier is required | Set the entity tax_number or tax_number_2. A company number alone fails. |
customer.email: buyer electronic address is required | Send the customer email, VAT ID or Peppol ID. |
document.date_service: Service or delivery date is required | Send date_service on the invoice. |
Buyer VAT ID is required for a K or AE line | Send customer.tax_number. |