Skip to content

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

NameWhat it is
Wachstumschancengesetz and § 14 UStGGerman 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 16931The European semantic standard for e-invoices. Both formats follow it.
XRechnungThe German EN 16931 profile (UBL XML), required for public-sector buyers.
ZUGFeRD / Factur-XA PDF invoice with embedded structured XML (CII).
Leitweg-IDThe routing ID of a public-sector buyer. It is the buyer reference on the invoice.

Before you start

You needWhere 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.

Enable German exportstypescript
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.

Complete the seller detailstypescript
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

FieldWhen
customer.address, customer.city, customer.post_codeAlways.
customer.emailXRechnung 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_referenceXRechnung: 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_serviceAlways. 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.

Issue an invoice that exports as XRechnung or ZUGFeRDtypescript
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

FieldWhen
customer.e_invoicing.buyer_referenceAlways for public-sector buyers. The Leitweg-ID.
Issue an invoice to a public-sector buyertypescript
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

FieldWhen
customer.country_codeThe 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[].classificationproduct 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_numberIntra-community supply and reverse charge: the buyer’s VAT ID. Reverse charge also accepts customer.company_number.
date_serviceIntra-community supply: the delivery date.
Issue a tax-free invoice for goods sold to an EU businesstypescript
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.

Download XRechnungtypescript
const _xml = await sdk.invoices.downloadInvoiceXRechnung(invoice.id);
Download ZUGFeRDtypescript
const _pdf = await sdk.invoices.downloadInvoiceZugferd(invoice.id);

Special cases

  • Block bad invoices up front. Send xrechnung: { validation_required: true } (or zugferd) when creating a final document to refuse it if validation fails. Without it, the failure appears when you export. An export that fails returns 422 listing 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 (code is Z, E, AE, K or G; exemption_reason_code and exemption_reason are optional). The reason code must be a VATEX code that fits the category. The text defaults to the document tax_clause, then to a standard text.
  • Delivery country. K needs the delivery to be in another EU country and G outside the EU. We use delivery_address.country_code, or the customer’s country when there is none.
  • Units. An unsupported items[].unit fails validation. Set items[].e_invoicing.unit_code to 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

ErrorFix
422 exports must be enabledTurn on XRechnung or ZUGFeRD in the entity settings. The entity must be German.
422 Cannot export draft documentsFinalize the document first.
issuer.email: Seller email is required for XRechnungSet the entity email.
issuer.phone: Seller contact phone is requiredSet the entity phone.
issuer.bank_account.iban: Seller IBAN is requiredAdd a default bank account with an IBAN to the entity.
issuer.tax_number: seller tax identifier is requiredSet the entity tax_number or tax_number_2. A company number alone fails.
customer.email: buyer electronic address is requiredSend the customer email, VAT ID or Peppol ID.
document.date_service: Service or delivery date is requiredSend date_service on the invoice.
Buyer VAT ID is required for a K or AE lineSend customer.tax_number.

Invoices · Credit notes · Entities · Peppol sending