Skip to content

REST API for developers

Guide: check and import incoming invoices

Check an e-invoice from a supplier, read the result and file the invoice in your account.

Contents

Goal and prerequisites

At the end, you know whether the e-invoice of your supplier passes the checks, and the invoice is filed as an incoming invoice in your account.

  • The received file, here supplier-invoice.xml: XRechnung or ZUGFeRD/Factur-X as XML (CII or UBL) or a ZUGFeRD PDF with embedded XML.
  • An API key in the environment variable API_KEY; curl and jq, or Python 3 with requests.
  • Each check counts as one validation of your plan. Incoming invoices do not count towards the invoices per month.

1. Check the file

Send the file as form field invoice_file to POST /api/v1/validate/. The file name must end in .xml or .pdf. Without further fields, the API only checks; nothing is stored.

curl (Shell)
curl -sS -X POST "https://www.e-rechnungsfreund.de/api/v1/validate/" \
  -H "Authorization: Api-Key $API_KEY" \
  -F "invoice_file=@supplier-invoice.xml" \
  | jq '{is_valid, detected_format, invoice: .info.invoice_number, seller: .info.seller.name, total: .info.totals.due_amount}'
Python (requests)
import os

import requests

BASE_URL = "https://www.e-rechnungsfreund.de"
HEADERS = {"Authorization": f"Api-Key {os.environ['API_KEY']}"}

with open("supplier-invoice.xml", "rb") as f:
    check = requests.post(
        f"{BASE_URL}/api/v1/validate/",
        files={"invoice_file": f},
        headers=HEADERS,
        timeout=120,
    )
check.raise_for_status()  # 400 = no invoice in the file, 402 = validations used up
report = check.json()
Example response: POST /api/v1/validate/ → 200 OK

Excerpt: info contains all data of the invoice, e.g. items, tax breakdown and payment details.

JSON
{
  "is_valid": true,
  "errors": [],
  "detected_format": "XRECHNUNG_CII",
  "kosit": {
    "is_valid": true,
    "errors": [],
    "warnings": [],
    "method": "daemon",
    "applicable": true
  },
  "mustang": {
    "is_valid": true,
    "errors": []
  },
  "saxon": {
    "is_valid": null,
    "errors": [],
    "warnings": [],
    "method": "skipped",
    "skipped": true
  },
  "info": {
    "invoice_number": "RE-2026-002",
    "issue_date": "20261001",
    "currency": "EUR",
    "buyer_reference": "04011000-12345-03",
    "seller": {
      "name": "Muster GmbH",
      "vat_id": "DE123456789"
    },
    "buyer": {
      "name": "Stadtverwaltung Musterstadt"
    },
    "totals": {
      "tax_basis_total": "760.00",
      "tax_total": "144.40",
      "grand_total": "904.40",
      "due_amount": "904.40"
    }
  },
  "filename": "supplier-invoice.xml",
  "imported": false,
  "import_error": null,
  "managed_invoice_id": null,
  "quota": {
    "used": 1,
    "limit": 30,
    "remaining": 29,
    "period_end": "2026-11-01T00:00:00+00:00"
  }
}

2. Evaluate the report

  • is_valid is the overall result. The status is 200 even if the invoice is invalid.
  • kosit, mustang and saxon are the results of the individual validators, each with errors and, where available, warnings. For an XRechnung, saxon does not run (skipped).
  • info contains the data read from the file: seller, buyer, totals, items, payment details. Use it to compare the invoice with your order.
  • quota shows the remaining validations of the month.

With include_explanations=true, the response also contains rule_explanations: per reported rule the meaning, typical causes and how to fix it. Pass them on to your supplier; how to read rule IDs is shown in Guide: fix errors.

curl (Shell)
curl -sS -X POST "https://www.e-rechnungsfreund.de/api/v1/validate/?include_explanations=true&language=en" \
  -H "Authorization: Api-Key $API_KEY" \
  -F "invoice_file=@supplier-invoice.xml" \
  | jq '{is_valid, kosit: .kosit.errors, mustang: .mustang.errors, saxon: .saxon.errors, rules: [.rule_explanations[]? | {rule_id, title, rule_url}]}'
Python (requests)
info = report["info"]
print(info["invoice_number"], info["seller"]["name"], info["totals"]["due_amount"], info["currency"])

if report["is_valid"]:
    print("valid")
else:
    for validator in ("kosit", "mustang", "saxon"):
        for error in (report.get(validator) or {}).get("errors") or []:
            print(validator, error["message"] if isinstance(error, dict) else error)

3. Import the invoice

Send the same request with import_to_management=true and direction=incoming. If the check passes, the invoice is filed with the original file; managed_invoice_id is the ID of the managed invoice. An invalid invoice is not imported: imported is then false and import_error names the reason.

curl (Shell)
curl -sS -X POST "https://www.e-rechnungsfreund.de/api/v1/validate/" \
  -H "Authorization: Api-Key $API_KEY" \
  -F "invoice_file=@supplier-invoice.xml" \
  -F "import_to_management=true" \
  -F "direction=incoming" \
  | jq '{is_valid, imported, import_error, managed_invoice_id}'
Python (requests)
with open("supplier-invoice.xml", "rb") as f:
    result = requests.post(
        f"{BASE_URL}/api/v1/validate/",
        files={"invoice_file": f},
        data={"import_to_management": "true", "direction": "incoming"},
        headers=HEADERS,
        timeout=120,
    ).json()
if not result["imported"]:
    raise SystemExit(result["import_error"])
managed_id = result["managed_invoice_id"]
Example response: POST /api/v1/validate/ → 200 OK

Excerpt: the response also contains the complete report as in step 1.

JSON
{
  "is_valid": true,
  "filename": "supplier-invoice.xml",
  "imported": true,
  "import_error": null,
  "managed_invoice_id": 1235,
  "quota": {
    "used": 2,
    "limit": 30,
    "remaining": 28,
    "period_end": "2026-11-01T00:00:00+00:00"
  }
}

Import only once per file: each request with import_to_management=true files the invoice again and counts as a validation.

4. Review and approve

GET /api/v1/managed-invoices/{id}/ shows the incoming invoice with status received, the open amount and the audit log; GET /api/v1/managed-invoices/{id}/source-file/ downloads the original file.

Example response: GET /api/v1/managed-invoices/{id}/ → 200 OK

Excerpt: the response contains all fields of the managed invoice.

JSON
{
  "id": 1235,
  "invoice_number": "RE-2026-002",
  "seller_name": "Muster GmbH",
  "direction": "incoming",
  "status": "received",
  "due_payable_amount": "904.4000",
  "open_amount": "904.40",
  "payments": []
}

After your review, set the status with POST /api/v1/managed-invoices/{id}/set-status/, e.g. to approved, or to disputed if something is wrong. Allowed changes of an incoming invoice:

StatusPossible next status
receivedcancelled, in_review, approved, disputed
in_reviewcancelled, approved, disputed
disputedcancelled, in_review, approved
approvedpartially_paid, overdue, cancelled
curl (Shell)
curl -sS "https://www.e-rechnungsfreund.de/api/v1/managed-invoices/$MANAGED_ID/" \
  -H "Authorization: Api-Key $API_KEY" \
  | jq '{status, direction, seller_name, open_amount}'

curl -sS "https://www.e-rechnungsfreund.de/api/v1/managed-invoices/$MANAGED_ID/source-file/" \
  -H "Authorization: Api-Key $API_KEY" \
  -o original.xml

curl -sS -X POST "https://www.e-rechnungsfreund.de/api/v1/managed-invoices/$MANAGED_ID/set-status/" \
  -H "Authorization: Api-Key $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status": "approved"}' | jq .status
Python (requests)
managed = requests.get(
    f"{BASE_URL}/api/v1/managed-invoices/{managed_id}/",
    headers=HEADERS,
    timeout=30,
).json()
print(managed["status"], managed["seller_name"], managed["open_amount"])

approved = requests.post(
    f"{BASE_URL}/api/v1/managed-invoices/{managed_id}/set-status/",
    json={"status": "approved"},
    headers=HEADERS,
    timeout=30,
)
approved.raise_for_status()
Example response: POST /api/v1/managed-invoices/{id}/set-status/ → 200 OK

Excerpt: the response contains all fields of the managed invoice.

JSON
{
  "id": 1235,
  "status": "approved",
  "audit_logs": [
    {
      "id": 2,
      "action": "status_changed",
      "actor_display": "Max Mustermann",
      "old_value": {
        "status": "received"
      },
      "new_value": {
        "status": "approved"
      },
      "created_at": "2026-10-01T09:32:00.000000Z"
    }
  ]
}

When you have paid the invoice, record the payment as for an outgoing invoice: Guide: invoice lifecycle.

Complete script on GitHub: incoming_invoice.sh, incoming_invoice.py

Next steps