<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dominik Schröter</title>
    <description>The latest articles on DEV Community by Dominik Schröter (@dominikschroeter).</description>
    <link>https://dev.to/dominikschroeter</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258060%2Fa58c4c7c-7929-4f24-b6c8-6ead1b0e5dbe.png</url>
      <title>DEV Community: Dominik Schröter</title>
      <link>https://dev.to/dominikschroeter</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dominikschroeter"/>
    <language>en</language>
    <item>
      <title>German e-invoicing for developers: XRechnung and ZUGFeRD via REST API and MCP</title>
      <dc:creator>Dominik Schröter</dc:creator>
      <pubDate>Sat, 21 Nov 2026 23:32:15 +0000</pubDate>
      <link>https://dev.to/dominikschroeter/german-e-invoicing-for-developers-xrechnung-and-zugferd-via-rest-api-and-mcp-16dl</link>
      <guid>https://dev.to/dominikschroeter/german-e-invoicing-for-developers-xrechnung-and-zugferd-via-rest-api-and-mcp-16dl</guid>
      <description>&lt;p&gt;From 2027, many German businesses have to &lt;strong&gt;send&lt;/strong&gt; structured e-invoices to other businesses, and from 2028 almost all of them. &lt;strong&gt;Receiving&lt;/strong&gt; them has been mandatory since 1 January 2025. If you build software that creates or processes invoices for German customers, this is now your problem too.&lt;/p&gt;

&lt;p&gt;This post covers what counts as an e-invoice, the two formats you will meet, how to validate them, and how we generate both formats from a single invoice object in our own API. Disclosure up front: we build &lt;a href="https://maxrechnung.de" rel="noopener noreferrer"&gt;MaxRechnung&lt;/a&gt;, a German invoicing app, and the examples in the second half use our API.&lt;/p&gt;

&lt;h2&gt;
  
  
  The timeline in one table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Who&lt;/th&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 Jan 2025&lt;/td&gt;
&lt;td&gt;All German businesses&lt;/td&gt;
&lt;td&gt;Must be able to &lt;strong&gt;receive&lt;/strong&gt; e-invoices (B2B)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 Jan 2027&lt;/td&gt;
&lt;td&gt;Businesses with prior-year revenue &amp;gt; €800,000&lt;/td&gt;
&lt;td&gt;Must &lt;strong&gt;send&lt;/strong&gt; e-invoices for domestic B2B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 Jan 2028&lt;/td&gt;
&lt;td&gt;All other businesses&lt;/td&gt;
&lt;td&gt;Must &lt;strong&gt;send&lt;/strong&gt; e-invoices for domestic B2B&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Small businesses under § 19 UStG ("Kleinunternehmer") are exempt from sending, but they still have to receive. Small-amount invoices up to €250 and travel tickets are exempt as well, and B2C invoices are not affected.&lt;/p&gt;

&lt;h2&gt;
  
  
  What counts as an e-invoice
&lt;/h2&gt;

&lt;p&gt;A PDF is &lt;strong&gt;not&lt;/strong&gt; an e-invoice under German law, even if it is generated by software. An e-invoice is a structured, machine-readable format that complies with the European standard &lt;strong&gt;EN 16931&lt;/strong&gt;. The law also allows other agreed formats such as EDI, as long as the data can be extracted in a way compatible with EN 16931. In practice, though, you will meet one of two formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;XRechnung&lt;/strong&gt;: pure XML (UBL or CII syntax). This is the German CIUS of EN 16931 and the standard for invoices to public authorities. There is no visual part; the recipient renders it with a viewer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ZUGFeRD&lt;/strong&gt; (Factur-X in France): a PDF/A-3 with the XML embedded. Humans read the PDF, machines read the XML. From version 2.0.1 it qualifies, &lt;strong&gt;except the profiles MINIMUM and BASIC WL&lt;/strong&gt;, which do not carry enough data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Legally, the XML is what counts. If the PDF and the embedded XML disagree, the XML wins. That also means you have to &lt;strong&gt;archive the original file&lt;/strong&gt;, not a printout or a re-rendered PDF. Strictly, the XML is what must be kept; the PDF part only matters if it carries additional relevant information, but keeping the original file covers both.&lt;/p&gt;

&lt;h2&gt;
  
  
  Validate before you send
&lt;/h2&gt;

&lt;p&gt;Two open validators cover almost everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;KoSIT validator&lt;/strong&gt; (the official one, maintained by the German coordination office for IT standards) for XRechnung, with the XRechnung scenario configuration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mustang&lt;/strong&gt; (open-source Java library and CLI) for ZUGFeRD/Factur-X, which combines veraPDF (PDF/A-3 check) with the profile schematron.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Typical findings in real data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;missing &lt;strong&gt;buyer reference&lt;/strong&gt; (BT-10, the "Leitweg-ID" for public-sector recipients)&lt;/li&gt;
&lt;li&gt;missing seller &lt;strong&gt;VAT ID or tax number&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;rounding differences&lt;/strong&gt; between line totals and document totals&lt;/li&gt;
&lt;li&gt;a missing &lt;strong&gt;payment due date&lt;/strong&gt; or payment terms&lt;/li&gt;
&lt;li&gt;unit codes that are not mapped to UN/ECE Rec. 20 (a free-text &lt;code&gt;Std.&lt;/code&gt; on the PDF has to become &lt;code&gt;HUR&lt;/code&gt; in the XML)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you build an invoicing feature yourself, run these validators in CI against a set of fixture invoices. The schematron rules change with every XRechnung release, and you want to notice before your customers' accounting software does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating both formats from one invoice
&lt;/h2&gt;

&lt;p&gt;In MaxRechnung, an invoice is created once as a structured object. XRechnung and ZUGFeRD are two renderings of the same data, and once an e-invoice is finalized, its XML is frozen. The flow over the REST API (&lt;code&gt;/api/v1&lt;/code&gt;) looks like this.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create a draft
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST &lt;span class="s2"&gt;"https://maxrechnung.de/api/v1/invoices"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $MXR_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Idempotency-Key: order-10023"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{
    "recipient": {
      "name": "Kunde AG",
      "address": "Kundenweg 5\n20095 Hamburg",
      "email": "rechnung@kunde-ag.example"
    },
    "e_invoice_formats": ["xrechnung", "zugferd"],
    "service_date": "2026-09-01",
    "payment_term_days": 14,
    "line_items": [
      {
        "description": "Beratung vor Ort",
        "quantity": 6.5,
        "unit": "Std.",
        "unit_price": 95,
        "vat_rate": 19
      }
    ]
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setting &lt;code&gt;e_invoice_formats&lt;/code&gt; makes finalizing enforce the full EN 16931/XRechnung rules and freezes the XML. Leave it out only for invoices that don't need to be e-invoices (B2C, for example). The sender (name, address, tax ID) is taken from your account settings; pass a &lt;code&gt;sender&lt;/code&gt; object to override it. Seller contact name and phone (BT-41/BT-42) always come from your account settings. A draft may be incomplete, so this call succeeds even if those settings are still empty.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Idempotency-Key&lt;/code&gt; makes retries safe: the same key with the same body within 24 hours returns the original response instead of creating a second invoice, while the same key with a different body returns &lt;code&gt;409 conflict&lt;/code&gt;. Use something stable like your order ID.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Finalize it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X PATCH &lt;span class="s2"&gt;"https://maxrechnung.de/api/v1/invoices/$INVOICE_ID/status"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $MXR_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{ "status": "sent" }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finalizing checks the mandatory invoice fields required by § 14 UStG. If something is missing, you get a &lt;code&gt;422 validation_failed&lt;/code&gt; with the affected fields in &lt;code&gt;details&lt;/code&gt; (on a fresh account without sender data, for example &lt;code&gt;sender.name&lt;/code&gt;, &lt;code&gt;sender.address&lt;/code&gt; and &lt;code&gt;sender.tax_id&lt;/code&gt;), and nothing is finalized. After that the invoice is immutable; corrections go through a separate corrections endpoint, which is what German bookkeeping rules (GoBD) expect.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Fetch XRechnung
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://maxrechnung.de/api/v1/invoices/$INVOICE_ID/xrechnung"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $MXR_API_KEY"&lt;/span&gt; \
  -o invoice.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns XRechnung 3.0.2 (CII). With &lt;code&gt;Accept: application/json&lt;/code&gt; you get a JSON wrapper with the result of our pre-check against the XRechnung rules: &lt;code&gt;valid&lt;/code&gt; (true/false), an &lt;code&gt;errors&lt;/code&gt; array for rule violations and a &lt;code&gt;warnings&lt;/code&gt; array for hints, e.g. a missing seller contact (BT-41/BT-42) or buyer e-mail address (BT-49). The raw XML download carries the same verdict in the &lt;code&gt;X-EInvoice-Valid&lt;/code&gt; header. The free-text unit &lt;code&gt;Std.&lt;/code&gt; from the example ends up as &lt;code&gt;unitCode="HUR"&lt;/code&gt; in the XML. If you set &lt;code&gt;e_invoice_formats&lt;/code&gt; in step 1, finalizing has already enforced these rules and you get the frozen file. For invoices created without it, check &lt;code&gt;valid&lt;/code&gt;/&lt;code&gt;errors&lt;/code&gt; or the &lt;code&gt;X-EInvoice-Valid&lt;/code&gt; header: the call still returns &lt;code&gt;200&lt;/code&gt; so that existing integrations don't break.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Fetch ZUGFeRD (asynchronous)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -i &lt;span class="s2"&gt;"https://maxrechnung.de/api/v1/invoices/$INVOICE_ID/zugferd?wait=30"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $MXR_API_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Building a PDF/A-3 takes a moment, so this runs through a queue. If the file is ready within &lt;code&gt;wait&lt;/code&gt; seconds you get it directly. Otherwise you get &lt;code&gt;202 Accepted&lt;/code&gt; with a &lt;code&gt;Location: /api/v1/jobs/{id}&lt;/code&gt; header that you can poll, or you subscribe to the &lt;code&gt;invoice.zugferd_ready&lt;/code&gt; webhook. The profile is set on the invoice, not as a parameter of this call: the default is EN 16931 (COMFORT), and &lt;code&gt;basic&lt;/code&gt; and &lt;code&gt;extended&lt;/code&gt; are available too. The output has been validated with Mustang (veraPDF + profile schematron) for all three profiles.&lt;/p&gt;

&lt;p&gt;The full reference, including a cURL import for each endpoint, is at &lt;a href="https://maxrechnung.de/developers/api" rel="noopener noreferrer"&gt;maxrechnung.de/developers/api&lt;/a&gt;, and the OpenAPI 3.1 spec is at &lt;code&gt;https://maxrechnung.de/api/openapi.json&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing the same from an AI assistant via MCP
&lt;/h2&gt;

&lt;p&gt;The same API is exposed as an MCP server, so Claude Code, Cursor or any MCP client that speaks Streamable HTTP can create drafts, look up customers or download e-invoices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"maxrechnung"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://maxrechnung.de/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer mxr_live_…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;"X-MCP-Read-Only"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server stores nothing and passes your key through to the REST API, so scopes and rate limits are identical. Two details we found important in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start read-only.&lt;/strong&gt; &lt;code&gt;X-MCP-Read-Only: 1&lt;/code&gt; limits the assistant to the 28 reading tools. Add write access only when you trust the workflow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separate drafting from finalizing.&lt;/strong&gt; A key with the &lt;code&gt;invoices:draft&lt;/code&gt; scope can create and edit drafts but cannot finalize, correct, cancel or record payments; those need &lt;code&gt;invoices:write&lt;/code&gt;. Letting the model draft and a human finalize is a sensible default for anything that ends up in the books.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tool overview: &lt;a href="https://maxrechnung.de/developers/mcp" rel="noopener noreferrer"&gt;maxrechnung.de/developers/mcp&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  No-code: n8n
&lt;/h2&gt;

&lt;p&gt;If you'd rather not write code, the API works with n8n's standard HTTP Request node: a "Header Auth" credential with &lt;code&gt;Authorization: Bearer &amp;lt;key&amp;gt;&lt;/code&gt;, base URL &lt;code&gt;https://maxrechnung.de/api/v1&lt;/code&gt;. We documented four building blocks (create customer, create and finalize invoice, sum payments, list overdue invoices for a daily dunning list) in the &lt;a href="https://maxrechnung.de/anleitungen/n8n-integration" rel="noopener noreferrer"&gt;n8n guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Treat the XML as the invoice. The PDF is a courtesy.&lt;/li&gt;
&lt;li&gt;Use ZUGFeRD BASIC or higher; EN 16931 (COMFORT) is the safe default. MINIMUM and BASIC WL don't count in Germany.&lt;/li&gt;
&lt;li&gt;Validate with KoSIT and Mustang in CI, not just once.&lt;/li&gt;
&lt;li&gt;Make invoice creation idempotent; webhooks and retries will hit you otherwise.&lt;/li&gt;
&lt;li&gt;Keep finalizing as an explicit step, whether a human, a script or an AI triggers it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;API access in MaxRechnung requires the Business plan. If you're building your own implementation instead, the validators and the format notes above apply just the same. Questions about edge cases (Leitweg-ID, reverse charge, partial invoices) are welcome in the comments.&lt;/p&gt;

</description>
      <category>einvoicing</category>
      <category>api</category>
      <category>mcp</category>
      <category>germany</category>
    </item>
  </channel>
</rss>
