All articles
Use Case6 min read

How to Create an XRechnung Invoice as a Spanish Freelancer

A step-by-step guide for Spanish freelancers and agencies billing German government clients.

Share this article

You are a freelancer or agency based in Spain, and you have just landed a contract with a German federal ministry, a state authority, or a municipality. Congratulations — but before you send your first invoice, you need to know about XRechnung. German public sector entities will reject any invoice that is not delivered in this format. Here is exactly how to get it right.

The typical scenario

A Spanish design studio, development agency, or independent consultant wins a contract with a German government client. The work is done, the project is delivered, and now it is time to get paid. The client replies: 'Please send your invoice as XRechnung via our portal.'

This is not optional. Since November 2020, all federal government entities in Germany require incoming invoices in XRechnung format. Most German states (Bundesländer) have adopted the same rule. If you send a PDF, it will be rejected — no matter how well-formatted it is.

What you need before you start

Gathering the right information upfront prevents rejected invoices and delays. Here is the checklist:

Your information (as the supplier)

  • Your Spanish VAT number (NIF) or intra-community VAT ID (ES + NIF, e.g., ESB12345678)
  • Full legal business name and address as registered with the AEAT
  • Your IBAN for payment — German government entities typically pay by bank transfer
  • A contact email in case the receiving authority has questions about your invoice

Your German client's information

  • The Leitweg-ID — a routing number that identifies the specific government department receiving the invoice
  • The official name and address of the government entity
  • The purchase order number (Bestellnummer) or contract reference if provided
About the Leitweg-ID: This is the single most important piece of information. Without a valid Leitweg-ID, your invoice will not reach the right department and will be rejected by the submission portal. Always ask your German client for it before you create the invoice. It looks like a numeric code with hyphens, for example 991-12345-67.

Step by step: creating your XRechnung

Step 1 — Enter your business details

In NormaForm, fill in your company name, address, and Spanish VAT ID. The tool will format your supplier information according to XRechnung requirements — including the correct country code (ES) and VAT scheme identifiers.

Step 2 — Add your German client

Enter the government entity's name, address (with country code DE), and paste the Leitweg-ID into the buyer reference field. Add the purchase order or contract number if your client provided one.

Step 3 — Enter line items and VAT

Add your line items with descriptions, quantities, unit prices, and the applicable VAT rate. For cross-border B2G services to a German government entity, the reverse charge mechanism usually applies — you invoice with 0% VAT and note the reverse charge on the invoice.

NormaForm handles the correct VAT category codes (e.g., 'AE' for reverse charge) so the XML validates properly against the XRechnung specification.

Step 4 — Generate and download

Select XRechnung as the output format. NormaForm generates a UBL 2.1 XML file that conforms to the XRechnung 3.0 specification and passes validation against the German KoSIT rules. Download the .xml file.

Step 5 — Submit via the portal

Upload the XRechnung XML to the ZRE (Zentraler Rechnungseingang des Bundes) for federal invoices or the OZG-RE portal for state-level invoices. Your German client should tell you which portal to use. Some clients also accept submission via Peppol — in that case you can send the XRechnung file through a Peppol access point.

VAT considerations for cross-border invoices

Cross-border invoicing between Spain and Germany involves intra-community VAT rules. The key points:

  • For B2G services: the reverse charge mechanism usually applies. You invoice without Spanish IVA, and the German entity accounts for the VAT on their side.
  • Your invoice must include your intra-community VAT ID (starting with ES) and the German entity's VAT ID (starting with DE).
  • Include a reference to the reverse charge provision — in XRechnung this is handled via the VAT category code 'AE' (VAT Reverse Charge) and the exemption reason.

If you are unsure about the VAT treatment for your specific situation, consult a tax advisor familiar with intra-EU transactions. Getting the VAT wrong will cause the invoice to be rejected or create compliance problems.

Common mistakes to avoid

  1. Missing or wrong Leitweg-ID. This causes immediate rejection. Double-check the number with your German client before submitting.
  2. Sending a PDF instead of XML. German government portals require the structured XML file. A PDF attachment is not accepted as the invoice — it can only be included as a supplementary document.
  3. Incorrect VAT category code. Using the standard rate code instead of the reverse charge code will cause validation errors. Make sure the VAT category matches your cross-border scenario.
  4. Missing buyer reference. XRechnung requires a buyer reference (BT-10). For German government invoices, this is typically the Leitweg-ID. Leaving this field empty will fail validation.

Summary

Invoicing a German government client from Spain is straightforward once you have the right information — particularly the Leitweg-ID and the correct VAT treatment. XRechnung is a well-defined format, and tools like NormaForm generate fully compliant XML so you do not need to understand the technical specification yourself.

For a deeper dive into the format itself, see our complete XRechnung guide

Ready to create compliant e-invoices?

NormaForm generates ZUGFeRD, XRechnung, Factur-X, and Peppol BIS invoices that meet every legal requirement — no accounting suite required.

Start free — 10 invoices/month

No credit card required. Free tier is free forever.