XRechnung creator (UBL or CII) API
Send the invoice as JSON, get back an XRechnung 3.0 file that passes KoSIT's official validator.
POST https://api.curatedapi.com/v1/create/einvoice/xrechnung
- Version 1
- MCP tool
create_einvoice_xrechnung - Overview
Builds an XRechnung 3.0 invoice or credit note in UBL 2.1 or UN/CEFACT CII from plain JSON, works out every total the way EN 16931 defines it, and runs KoSIT's validator configuration on the file before returning it. If any rule fails, no file is returned and the call is not billed.
- XRechnung needs a buyer reference (the Leitweg-ID for public buyers), the seller's contact name, phone and email, both parties' electronic addresses and payment instructions.
Inputs
Send numbers as strings to keep every digit. A file that would break an official rule is not returned: the call fails with INVOICE_NOT_VALID (see creating e-invoices).
| Input | Type | Description |
|---|---|---|
syntax |
ubl | cii default ubl |
UBL 2.1 (default) or UN/CEFACT CII. German public buyers accept both. |
invoice required |
object | The invoice. Field names follow EN 16931; the BT numbers in the descriptions are the standard's own. |
invoice.type |
invoice | credit_note | corrected_invoice | partial_invoice | invoice (380, default), credit_note (381), corrected_invoice (384) or partial_invoice (326). |
invoice.number required |
string | Invoice number (BT-1). |
invoice.issue_date required |
date (YYYY-MM-DD) | BT-2, YYYY-MM-DD. |
invoice.due_date |
date (YYYY-MM-DD) | BT-9. |
invoice.currency |
string | ISO 4217 code; EUR when left out (BT-5). |
invoice.buyer_reference |
string | The buyer's reference; for German public buyers the Leitweg-ID. Required by XRechnung (BT-10). |
invoice.order_reference |
string | Purchase order number (BT-13). |
invoice.contract_reference |
string | BT-12. |
invoice.project_reference |
string | BT-11. |
invoice.preceding_invoice |
object | The invoice a credit note or corrected invoice refers to (BG-3). |
invoice.preceding_invoice.number |
string | |
invoice.preceding_invoice.issue_date |
date (YYYY-MM-DD) | |
invoice.delivery_date |
date (YYYY-MM-DD) | BT-72. |
invoice.period |
object | Invoicing period (BG-14). |
invoice.period.start |
date (YYYY-MM-DD) | |
invoice.period.end |
date (YYYY-MM-DD) | |
invoice.notes |
list of string | Invoice notes (BT-22). |
invoice.seller required |
object | |
invoice.seller.name required |
string | Legal name (BT-27 / BT-44). |
invoice.seller.trading_name |
string | Trading name, if different (BT-28 / BT-45). |
invoice.seller.address required |
object | |
invoice.seller.address.line1 |
string | Street and number (BT-35). |
invoice.seller.address.line2 |
string | Additional line (BT-36). |
invoice.seller.address.line3 |
string | Third line (BT-162). |
invoice.seller.address.city |
string | City (BT-37). |
invoice.seller.address.postcode |
string | Post code (BT-38). |
invoice.seller.address.region |
string | Region or state (BT-39). |
invoice.seller.address.country required |
string | ISO 3166 two-letter code, e.g. DE (BT-40). |
invoice.seller.vat_id |
string | VAT number with country prefix (BT-31 / BT-48). |
invoice.seller.registration_id |
string or object | Legal registration, e.g. HRB 12345 (BT-30 / BT-47). |
invoice.seller.id |
string or object | Seller or buyer identifier (BT-29 / BT-46). |
invoice.seller.electronic_address |
string or object | Where e-invoices are delivered (BT-34 / BT-49): an email address, or {"id", "scheme"} with an EAS code such as 0204 (Leitweg-ID) or 9930 (German VAT number). Required by XRechnung and Peppol. |
invoice.seller.contact |
object | Contact person, phone and email (BG-6 / BG-9). XRechnung requires all three for the seller. |
invoice.seller.contact.name |
string | |
invoice.seller.contact.phone |
string | |
invoice.seller.contact.email |
string | |
invoice.seller.tax_number |
string | National tax number, e.g. Steuernummer (BT-32). |
invoice.seller.legal_info |
string | Additional legal information: managing directors, court of registration, share capital (BT-33). |
invoice.buyer required |
object | |
invoice.buyer.name required |
string | Legal name (BT-27 / BT-44). |
invoice.buyer.trading_name |
string | Trading name, if different (BT-28 / BT-45). |
invoice.buyer.address required |
object | |
invoice.buyer.address.line1 |
string | Street and number (BT-35). |
invoice.buyer.address.line2 |
string | Additional line (BT-36). |
invoice.buyer.address.line3 |
string | Third line (BT-162). |
invoice.buyer.address.city |
string | City (BT-37). |
invoice.buyer.address.postcode |
string | Post code (BT-38). |
invoice.buyer.address.region |
string | Region or state (BT-39). |
invoice.buyer.address.country required |
string | ISO 3166 two-letter code, e.g. DE (BT-40). |
invoice.buyer.vat_id |
string | VAT number with country prefix (BT-31 / BT-48). |
invoice.buyer.registration_id |
string or object | Legal registration, e.g. HRB 12345 (BT-30 / BT-47). |
invoice.buyer.id |
string or object | Seller or buyer identifier (BT-29 / BT-46). |
invoice.buyer.electronic_address |
string or object | Where e-invoices are delivered (BT-34 / BT-49): an email address, or {"id", "scheme"} with an EAS code such as 0204 (Leitweg-ID) or 9930 (German VAT number). Required by XRechnung and Peppol. |
invoice.buyer.contact |
object | Contact person, phone and email (BG-6 / BG-9). XRechnung requires all three for the seller. |
invoice.buyer.contact.name |
string | |
invoice.buyer.contact.phone |
string | |
invoice.buyer.contact.email |
string | |
invoice.delivery |
object | Deliver-to party and address (BG-13, BG-15). |
invoice.delivery.name |
string | |
invoice.delivery.address |
object | |
invoice.delivery.address.line1 |
string | Street and number (BT-35). |
invoice.delivery.address.line2 |
string | Additional line (BT-36). |
invoice.delivery.address.line3 |
string | Third line (BT-162). |
invoice.delivery.address.city |
string | City (BT-37). |
invoice.delivery.address.postcode |
string | Post code (BT-38). |
invoice.delivery.address.region |
string | Region or state (BT-39). |
invoice.delivery.address.country |
string | ISO 3166 two-letter code, e.g. DE (BT-40). |
invoice.delivery.location_id |
string or object | |
invoice.payment |
object | Payment instructions (BG-16). XRechnung requires them. |
invoice.payment.method |
sepa_credit_transfer | credit_transfer | sepa_direct_debit | sepa_credit_transfer (58), credit_transfer (30) or sepa_direct_debit (59). |
invoice.payment.iban |
string | The seller's account (BT-84). |
invoice.payment.bic |
string | BT-86. |
invoice.payment.account_name |
string | BT-85. |
invoice.payment.reference |
string | Remittance information (BT-83). |
invoice.payment.terms |
string | Payment terms as text (BT-20). |
invoice.payment.mandate_reference |
string | Direct debit mandate (BT-89). |
invoice.payment.creditor_id |
string | SEPA creditor ID (BT-90). |
invoice.payment.debtor_iban |
string | The account debited (BT-91). |
invoice.lines required |
list of objects | |
invoice.lines[].id |
string | Line number; 1, 2, 3 … when left out (BT-126). |
invoice.lines[].name required |
string | Item name (BT-153). |
invoice.lines[].description |
string | Item description (BT-154). |
invoice.lines[].note |
string | Line note (BT-127). |
invoice.lines[].quantity required |
['number', 'string'] | Up to 4 decimals; negative for a return. |
invoice.lines[].unit |
string | UN/ECE Recommendation 20 code: C62 piece (default), HUR hour, DAY day, MON month, KGM kilogram, LS lump sum … |
invoice.lines[].unit_price required |
['number', 'string'] | Net price per unit, up to 4 decimals (BT-146). |
invoice.lines[].price_base_quantity |
['number', 'string'] | The quantity the price is for, e.g. 100 for a price per 100 (BT-149). |
invoice.lines[].vat_category required |
S | Z | E | AE | K | G | O | S standard, Z zero, E exempt, AE reverse charge, K intra-EU supply, G export, O not subject to VAT (BT-151). |
invoice.lines[].vat_rate |
['number', 'string'] | Percent, e.g. 19; 0 for Z, E, AE, K, G; left out for O (BT-152). |
invoice.lines[].seller_item_id |
string | |
invoice.lines[].buyer_item_id |
string | |
invoice.lines[].standard_item_id |
string or object | E.g. {"id": "4012345001235", "scheme": "0160"} for a GTIN (BT-157). |
invoice.lines[].order_line_reference |
string | |
invoice.lines[].period |
object | |
invoice.lines[].period.start |
date (YYYY-MM-DD) | |
invoice.lines[].period.end |
date (YYYY-MM-DD) | |
invoice.lines[].allowances |
list of objects | |
invoice.lines[].allowances[].amount |
['number', 'string'] | A number, or a number as a string to keep every digit ("12.50"). |
invoice.lines[].allowances[].percent |
['number', 'string'] | Percentage of base_amount, instead of amount. |
invoice.lines[].allowances[].base_amount |
['number', 'string'] | Base for percent. On a line it defaults to quantity × price. |
invoice.lines[].allowances[].reason |
string | |
invoice.lines[].allowances[].reason_code |
string | UNTDID 5189 (allowances) or 7161 (charges). |
invoice.lines[].charges |
list of objects | |
invoice.lines[].charges[].amount |
['number', 'string'] | A number, or a number as a string to keep every digit ("12.50"). |
invoice.lines[].charges[].percent |
['number', 'string'] | Percentage of base_amount, instead of amount. |
invoice.lines[].charges[].base_amount |
['number', 'string'] | Base for percent. On a line it defaults to quantity × price. |
invoice.lines[].charges[].reason |
string | |
invoice.lines[].charges[].reason_code |
string | UNTDID 5189 (allowances) or 7161 (charges). |
invoice.allowances |
list of objects | Document allowances (BG-20). |
invoice.allowances[].amount |
['number', 'string'] | A number, or a number as a string to keep every digit ("12.50"). |
invoice.allowances[].percent |
['number', 'string'] | Percentage of base_amount, instead of amount. |
invoice.allowances[].base_amount |
['number', 'string'] | Base for percent. On a line it defaults to quantity × price. |
invoice.allowances[].reason |
string | |
invoice.allowances[].reason_code |
string | UNTDID 5189 (allowances) or 7161 (charges). |
invoice.allowances[].vat_category |
S | Z | E | AE | K | G | O | |
invoice.allowances[].vat_rate |
['number', 'string'] | A number, or a number as a string to keep every digit ("12.50"). |
invoice.charges |
list of objects | Document charges (BG-21). |
invoice.charges[].amount |
['number', 'string'] | A number, or a number as a string to keep every digit ("12.50"). |
invoice.charges[].percent |
['number', 'string'] | Percentage of base_amount, instead of amount. |
invoice.charges[].base_amount |
['number', 'string'] | Base for percent. On a line it defaults to quantity × price. |
invoice.charges[].reason |
string | |
invoice.charges[].reason_code |
string | UNTDID 5189 (allowances) or 7161 (charges). |
invoice.charges[].vat_category |
S | Z | E | AE | K | G | O | |
invoice.charges[].vat_rate |
['number', 'string'] | A number, or a number as a string to keep every digit ("12.50"). |
invoice.prepaid_amount |
['number', 'string'] | Already paid (BT-113). |
invoice.rounding_amount |
['number', 'string'] | BT-114. |
invoice.vat_exemption_reasons |
object | The reason for each VAT category other than S and Z, e.g. {"E": "Kleinunternehmer gemäß § 19 UStG"} or {"E": {"code": "VATEX-EU-132", "text": "…"}} (BT-120, BT-121). AE, K, G and O get the standard wording when left out; E must be given. |
Result
Under result in the answer, next to validator and rules (the official artefacts used, with their versions).
| Result | Type | Description |
|---|---|---|
valid | boolean | Always true: a file that breaks a rule is not returned. |
format | string | What was made, e.g. XRechnung 3.0 (UBL). |
specification_id | string | BT-24 as written in the file. |
filename | string | A file name made from the invoice number. |
xml | string | The invoice XML (UTF-8). |
totals | object | Every amount as EN 16931 calculates it, as strings with 2 decimals: line_total (BT-106), allowance_total, charge_total, total_without_vat (BT-109), vat_total (BT-110), total_with_vat (BT-112), prepaid_amount, rounding_amount, amount_due (BT-115), vat_breakdown (BG-23) and each line's net_amount (BT-131). |
check | object | The official rules' report on the file returned: the same answer the matching /v1/validate/einvoice/… endpoint gives. |
Examples
KoSIT test case 01.01a rebuilt from JSON
curl https://api.curatedapi.com/v1/create/einvoice/xrechnung \
-H "Authorization: Bearer $CURATEDAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"invoice": {"number": "123456XX", "issue_date": "2016-04-04", "currency": "EUR", "buyer_reference": "04011000-12345-03", "notes": ["#ADU#Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden."], "seller": {"name": "[Seller name]", "trading_name": "[Seller trading name]", "address": {"line1": "[Seller address line 1]", "city": "[Seller city]", "postcode": "12345", "country": "DE"}, "vat_id": "DE 123456789", "registration_id": "[HRA-Eintrag]", "legal_info": "123/456/7890, HRA-Eintrag in […]", "electronic_address": "[email protected]", "contact": {"name": "nicht vorhanden", "phone": "+49 1234-5678", "email": "[email protected]"}}, "buyer": {"name": "[Buyer name]", "id": "[Buyer identifier]", "address": {"line1": "[Buyer address line 1]", "city": "[Buyer city]", "postcode": "12345", "country": "DE"}, "electronic_address": "[email protected]"}, "payment": {"method": "sepa_credit_transfer", "iban": "DE79000000001234567890", "terms": "Zahlbar sofort ohne Abzug."}, "lines": [{"id": "Zeitschrift [...]", "name": "Zeitschrift [...]", "description": "Zeitschrift Inland", "note": "Die letzte Lieferung im Rahmen des abgerechneten Abonnements erfolgt in 12/2016 Lieferung erfolgt / erfolgte direkt vom Verlag", "quantity": 1, "unit": "XPP", "unit_price": "288.79", "vat_category": "S", "vat_rate": 7, "seller_item_id": "246", "order_line_reference": "6171175.1", "period": {"start": "2016-01-01", "end": "2016-12-31"}}, {"id": "Porto + Versandkosten", "name": "Porto + Versandkosten", "quantity": 1, "unit": "XPP", "unit_price": "26.07", "vat_category": "S", "vat_rate": 7}]}
}'
{
"creator": "einvoice/xrechnung@1",
"result": {
"valid": true,
"format": "XRechnung 3.0 (UBL 2.1)",
"specification_id": "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0",
"filename": "123456XX.xml",
"totals": {
"currency": "EUR",
"line_total": "314.86",
"allowance_total": "0.00",
"charge_total": "0.00",
"total_without_vat": "314.86",
"vat_total": "22.04",
"total_with_vat": "336.90",
"prepaid_amount": "0.00",
"rounding_amount": "0.00",
"amount_due": "336.90",
"vat_breakdown": [
{
"category": "S",
"rate": "7",
"taxable_amount": "314.86",
"vat_amount": "22.04"
}
],
"lines": [
{
"id": "Zeitschrift [...]",
"net_amount": "288.79"
},
{
"id": "Porto + Versandkosten",
"net_amount": "26.07"
}
]
},
"check": {
"scenario": "EN16931 XRechnung (UBL Invoice)",
"document_type": "UBL Invoice",
"specification_id": "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0",
"errors": 0,
"warnings": 0,
"notices": 1,
"error_rules": [],
"checks": [
{
"check": "XML syntax",
"passed": true
},
{
"check": "XML Schema for UBL 2.1 Invoice",
"passed": true
},
{
"check": "Schematron rules for EN16931 (UBL)",
"passed": true
},
{
"check": "Schematron rules for Invoice - CIUS XRechnung (UBL)",
"passed": true
}
],
"messages": [
{
"rule": "BR-DE-TMP-32",
"level": "information",
"message": "[BR-DE-TMP-32] Eine Rechnung sollte zur Angabe des Liefer-/Leistungsdatums entweder BT-72 \"Actual delivery date\", BG-14 \"Invoicing period\" oder in jeder Rechnungsposition BG-26 \"Invoice line period\" enthalten.",
"check": "Schematron rules for Invoice - CIUS XRechnung (UBL)",
"location": "/Q{urn:oasis:names:specification:ubl:schema:xsd:Invoice-2}Invoice[1]"
}
],
"messages_truncated": false
},
"xml": "<?xml version='1.0' encoding='UTF-8'?>\n<Invoice xmlns=\"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2\" xmlns:cac=\"urn:oasis:names:specification:ubl:sche… (5,717 characters in all)"
},
"rules": [
{
"name": "KoSIT validator configuration for XRechnung 3.0.2",
"version": "2026-08-31",
"url": "https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/v2026-08-31/xrechnung-3.0.2-validator-configuration-2026-08-31.zip"
}
]
}
Rules used
- KoSIT validator configuration for XRechnung 3.0.2, version 2026-08-31
A check shows whether the invoice passes the official rule sets listed, at the versions listed. It is not legal or tax advice, and passing does not promise that a tax authority or buyer will accept the invoice. See the terms.
Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.