fakturai blog

API & MCP

Create e-invoices per API & MCP: ZUGFeRD / Factur-X with fakturai

Creating German B2B e-invoices per API or MCP means: generate structured EN 16931-compliant ZUGFeRD/Factur-X (COMFORT or Extended) or XRechnung-XML via HTTP endpoint or the MCP server — with automatic KoSIT validation before return. fakturai only delivers files that pass the official German tax authority checks.

Important: A plain PDF is not an e-invoice. Structured hybrid or XML files have been mandatory for receipt since 1 Jan 2025 and are phasing in for issuance 2027/2028 by turnover.

Practical steps: create e-invoices per API & MCP with fakturai

  1. Validate existing invoices first (Validator CTA) — Upload outgoing or incoming PDFs to the free validator. Confirm master data, line items and processes are compatible before building API calls.
  2. Set up authentication — After signup you receive an API key. Pass it as X-API-Key header (or Bearer). For AI agents and tools: use the MCP server (stdio via uvx or remote endpoint).
  3. Prepare payload (general invoice model) — Collect required fields: invoice_number, invoice_date, due_date, seller (name, address, VAT ID), buyer, lines (description, quantity, unit_price net, vat_rate). Optional: notes, payment, profile.
    {
      "invoice_number": "RE-2026-042",
      "invoice_date": "2026-06-11",
      "due_date": "2026-06-25",
      "seller": { "name": "Muster GmbH", "street": "Musterstr. 1", "zip": "12345", "city": "Berlin", "country": "DE", "vat_id": "DE123456789" },
      "buyer": { "name": "Kunde AG", "street": "Kundenweg 2", "zip": "54321", "city": "München", "country": "DE", "vat_id": "DE987654321" },
      "lines": [
        { "description": "Consulting and implementation", "quantity": 5, "unit_price": "1200.00", "vat_rate": 19 },
        { "description": "Travel flat", "quantity": 1, "unit_price": "250.00", "vat_rate": 19 }
      ],
      "notes": "Net payment within 14 days."
    }
  4. HTTP API call (curl)
    curl -X POST https://fakturai.de/api/v1/invoices \
      -H "X-API-Key: YOUR_KEY" \
      -H "Content-Type: application/json" \
      -d @payload.json \
      -o invoice-RE-2026-042.zugferd.pdf
    The response is the KoSIT-accepted ZUGFeRD/Factur-X PDF/A-3b (with embedded CII-XML). Pure XML or XRechnung variant via params/profile also available.
  5. MCP for agents (Claude, Cursor, n8n, custom tools) — The MCP server (uvx --from erechnung erechnung-mcp or remote) exposes tools like generate_einvoice and validate_einvoice. Agents can directly generate and validate structured invoices without writing HTTP code.

    Example agent prompt: "Generate a ZUGFeRD COMFORT e-invoice for the data above via the fakturai MCP and return the file + KoSIT report."

  6. Receive, check and GoBD-archive — The file is only delivered on KoSIT "ACCEPT". Store PDF/A-3b + XML faithfully (unaltered) + your Verfahrensdokumentation (your responsibility).

What fakturai checks (KoSIT-Accept-Gate)

fakturai generates ZUGFeRD/Factur-X and validates before delivery in multiple layers:

Only when all layers pass is the file returned. This is the core quality and trust signal: the invoice is demonstrably accepted by the authority's reference engine on the format side. Hard failures block; certain notes are advisory.

What fakturai does not replace (GHOA-1671)

fakturai checks and generates format (EN 16931 / ZUGFeRD / Factur-X / XRechnung) and delivers a KoSIT-accepted file.

API/MCP integration checklist

Next steps

Free validator · Request API key · API docs · MCP in agents

Related: German e-invoicing mandate 2025/2027 · ZUGFeRD vs XRechnung vs EN 16931 · Technical validation (KoSIT) · PDF is not an e-invoice · Create e-invoices (general) · GoBD-compliant

Grounded in seo-content-map (API generation + AI/MCP wedge), engine samples + validate.py (4-layer gate), prior drafts for consistent phrasing, BMF facts (no new claims). GHOA-1671 boundaries observed.

Free validator · Create API key · API docs