einvoice.generate
Generate a KoSIT-validated XRechnung UBL or CII invoice, or a ZUGFeRD PDF/A-3.
https://api.kanagu.dev/v1/einvoice/generate- Price
- $0.02 per successful call
- Without a key
- 10 free calls per IP per UTC day, shared by REST and MCP.
- MCP tool
einvoice.generateathttps://api.kanagu.dev/mcp- Markdown
- /docs/einvoice.generate.md
curl https://api.kanagu.dev/v1/einvoice/generate \
-H "Content-Type: application/json" \
-d '{"format":"ubl","invoiceNumber":"2026-0417","issueDate":"2026-11-23","deliveryDate":"2026-11-20","dueDate":"2026-12-23","buyerReference":"90000000-03083-72","seller":{"name":"Linden Consulting GmbH","vatId":"DE123456789","email":"billing@example.com","street":"Lindenstraße 12","city":"Berlin","postalCode":"10117","country":"DE","contact":{"name":"Kai Weber","phone":"+49 30 5550100","email":"kai@example.com"}},"buyer":{"name":"Nordhafen Verwaltungs GmbH","email":"invoices@example.org","street":"Hafenstraße 8","city":"Hamburg","postalCode":"20457","country":"DE"},"iban":"DE79000000001234567890","lines":[{"description":"Software integration workshop","quantity":"2","unitPrice":"475.00","vatRate":"19"}]}'curl https://api.kanagu.dev/v1/einvoice/generate \
-H "Authorization: Bearer $KANAGU_KEY" \
-H "Content-Type: application/json" \
-d '{"format":"ubl","invoiceNumber":"2026-0417","issueDate":"2026-11-23","deliveryDate":"2026-11-20","dueDate":"2026-12-23","buyerReference":"90000000-03083-72","seller":{"name":"Linden Consulting GmbH","vatId":"DE123456789","email":"billing@example.com","street":"Lindenstraße 12","city":"Berlin","postalCode":"10117","country":"DE","contact":{"name":"Kai Weber","phone":"+49 30 5550100","email":"kai@example.com"}},"buyer":{"name":"Nordhafen Verwaltungs GmbH","email":"invoices@example.org","street":"Hafenstraße 8","city":"Hamburg","postalCode":"20457","country":"DE"},"iban":"DE79000000001234567890","lines":[{"description":"Software integration workshop","quantity":"2","unitPrice":"475.00","vatRate":"19"}]}'const res = await fetch("https://api.kanagu.dev/v1/einvoice/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KANAGU_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"format": "ubl",
"invoiceNumber": "2026-0417",
"issueDate": "2026-11-23",
"deliveryDate": "2026-11-20",
"dueDate": "2026-12-23",
"buyerReference": "90000000-03083-72",
"seller": {
"name": "Linden Consulting GmbH",
"vatId": "DE123456789",
"email": "billing@example.com",
"street": "Lindenstraße 12",
"city": "Berlin",
"postalCode": "10117",
"country": "DE",
"contact": {
"name": "Kai Weber",
"phone": "+49 30 5550100",
"email": "kai@example.com"
}
},
"buyer": {
"name": "Nordhafen Verwaltungs GmbH",
"email": "invoices@example.org",
"street": "Hafenstraße 8",
"city": "Hamburg",
"postalCode": "20457",
"country": "DE"
},
"iban": "DE79000000001234567890",
"lines": [
{
"description": "Software integration workshop",
"quantity": "2",
"unitPrice": "475.00",
"vatRate": "19"
}
]
}),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "einvoice.generate",
"arguments": {
"format": "ubl",
"invoiceNumber": "2026-0417",
"issueDate": "2026-11-23",
"deliveryDate": "2026-11-20",
"dueDate": "2026-12-23",
"buyerReference": "90000000-03083-72",
"seller": {
"name": "Linden Consulting GmbH",
"vatId": "DE123456789",
"email": "billing@example.com",
"street": "Lindenstraße 12",
"city": "Berlin",
"postalCode": "10117",
"country": "DE",
"contact": {
"name": "Kai Weber",
"phone": "+49 30 5550100",
"email": "kai@example.com"
}
},
"buyer": {
"name": "Nordhafen Verwaltungs GmbH",
"email": "invoices@example.org",
"street": "Hafenstraße 8",
"city": "Hamburg",
"postalCode": "20457",
"country": "DE"
},
"iban": "DE79000000001234567890",
"lines": [
{
"description": "Software integration workshop",
"quantity": "2",
"unitPrice": "475.00",
"vatRate": "19"
}
]
}
}
}{
"format": "ubl",
"invoiceNumber": "2026-0417",
"issueDate": "2026-11-23",
"deliveryDate": "2026-11-20",
"dueDate": "2026-12-23",
"buyerReference": "90000000-03083-72",
"seller": {
"name": "Linden Consulting GmbH",
"vatId": "DE123456789",
"email": "billing@example.com",
"street": "Lindenstraße 12",
"city": "Berlin",
"postalCode": "10117",
"country": "DE",
"contact": {
"name": "Kai Weber",
"phone": "+49 30 5550100",
"email": "kai@example.com"
}
},
"buyer": {
"name": "Nordhafen Verwaltungs GmbH",
"email": "invoices@example.org",
"street": "Hafenstraße 8",
"city": "Hamburg",
"postalCode": "20457",
"country": "DE"
},
"iban": "DE79000000001234567890",
"lines": [
{
"description": "Software integration workshop",
"quantity": "2",
"unitPrice": "475.00",
"vatRate": "19"
}
]
}Request body
application/json
format"ubl" | "cii" | "zugferd"requiredinvoiceNumberstring (max 50 chars)requiredissueDatestring (date)requireddueDatestring (date)requireddeliveryDatestring (date)currencystringbuyerReferencestring (max 120 chars)requiredsellerobjectrequiredseller.namestring (max 160 chars)requiredseller.emailstring (email, max 160 chars)requiredseller.streetstring (max 160 chars)requiredseller.citystring (max 100 chars)requiredseller.postalCodestring (max 20 chars)requiredseller.countrystringrequiredseller.vatIdstringrequiredseller.contactobjectrequiredseller.contact.namestring (max 120 chars)requiredseller.contact.phonestring (max 60 chars)requiredseller.contact.emailstring (email, max 160 chars)requiredbuyerobjectrequiredbuyer.namestring (max 160 chars)requiredbuyer.emailstring (email, max 160 chars)requiredbuyer.streetstring (max 160 chars)requiredbuyer.citystring (max 100 chars)requiredbuyer.postalCodestring (max 20 chars)requiredbuyer.countrystringrequiredbuyer.vatIdstringibanstringrequiredlinesarray of objectrequiredlines[].descriptionstring (max 300 chars)requiredlines[].quantitystringrequiredlines[].unitPricestringrequired- Net item price per base quantity.
lines[].baseQuantitystring- Quantity covered by the item price. Defaults to one.
lines[].baseQuantityUnitstring- Unit of the base quantity. Defaults to the line unit.
lines[].grossUnitPricestring- Item price before the item price discount.
lines[].unitPriceDiscountstring- Discount on the item price per base quantity.
lines[].unitstringlines[].vatRatestringrequired
Response
200 · application/json
format"ubl" | "cii" | "zugferd"requiredxmlstringrequiredvalidationobjectrequiredvalidation.validbooleanrequiredvalidation.validator"KoSIT 1.6.3 / XRechnung 3.0.2 (2026-08-31)"requiredvalidation.issuesarray of objectrequiredvalidation.issues[].ruleIdstringrequiredvalidation.issues[].severitystringrequiredvalidation.issues[].xpathstringrequiredvalidation.issues[].fieldstringrequiredvalidation.issues[].messagestringrequiredvalidation.issues[].fixHintstringrequiredpdfBase64string (base64)- PDF/A-3 for format zugferd
Try it
Errors
Errors are JSON {"error":{"code","message"}}. An operation may add its own 400 codes; the message says what to fix.
| Status | Code and meaning |
|---|---|
| 400 | invalid_inputThe body does not match the request schema. The message names each field. |
| 400 | invalid_jsonThe body is missing or is not valid JSON. |
| 400 | invalid_idempotency_keyIdempotency-Key must be 1–128 visible ASCII characters. |
| 401 | invalid_api_keyThe Bearer key is missing, malformed, invalid or inactive. |
| 402 | free_allowance_exhaustedThis month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left. |
| 404 | not_foundNo operation at this path. |
| 409 | idempotency_conflictThe Idempotency-Key was already used with a different body. |
| 413 | payload_too_largeJSON bodies may be at most 64 KiB. |
| 429 | trial_limitThe anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left. |
| 500 | internal_errorThe call failed on our side. It is not billed; retry with the same Idempotency-Key. |
JSON Schema
Request schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"format": {
"type": "string",
"enum": [
"ubl",
"cii",
"zugferd"
]
},
"invoiceNumber": {
"type": "string",
"minLength": 1,
"maxLength": 50
},
"issueDate": {
"type": "string",
"format": "date",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
},
"dueDate": {
"type": "string",
"format": "date",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
},
"deliveryDate": {
"type": "string",
"format": "date",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
},
"currency": {
"default": "EUR",
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"buyerReference": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"seller": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 160
},
"email": {
"type": "string",
"maxLength": 160,
"format": "email",
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
},
"street": {
"type": "string",
"minLength": 1,
"maxLength": 160
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"postalCode": {
"type": "string",
"minLength": 1,
"maxLength": 20
},
"country": {
"type": "string",
"pattern": "^[A-Z]{2}$"
},
"vatId": {
"type": "string",
"pattern": "^[A-Z]{2}[A-Z0-9]{3,16}$"
},
"contact": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"phone": {
"type": "string",
"minLength": 1,
"maxLength": 60
},
"email": {
"type": "string",
"maxLength": 160,
"format": "email",
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
}
},
"required": [
"name",
"phone",
"email"
],
"additionalProperties": false
}
},
"required": [
"name",
"email",
"street",
"city",
"postalCode",
"country",
"vatId",
"contact"
],
"additionalProperties": false
},
"buyer": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 160
},
"email": {
"type": "string",
"maxLength": 160,
"format": "email",
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
},
"street": {
"type": "string",
"minLength": 1,
"maxLength": 160
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"postalCode": {
"type": "string",
"minLength": 1,
"maxLength": 20
},
"country": {
"type": "string",
"pattern": "^[A-Z]{2}$"
},
"vatId": {
"type": "string",
"pattern": "^[A-Z]{2}[A-Z0-9]{3,16}$"
}
},
"required": [
"name",
"email",
"street",
"city",
"postalCode",
"country"
],
"additionalProperties": false
},
"iban": {
"type": "string",
"pattern": "^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$"
},
"lines": {
"minItems": 1,
"maxItems": 500,
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {
"type": "string",
"minLength": 1,
"maxLength": 300
},
"quantity": {
"type": "string",
"pattern": "^\\d{1,8}(?:\\.\\d{1,4})?$"
},
"unitPrice": {
"type": "string",
"pattern": "^\\d{1,8}(?:\\.\\d{1,18})?$",
"description": "Net item price per base quantity."
},
"baseQuantity": {
"description": "Quantity covered by the item price. Defaults to one.",
"type": "string",
"pattern": "^\\d{1,8}(?:\\.\\d{1,4})?$"
},
"baseQuantityUnit": {
"description": "Unit of the base quantity. Defaults to the line unit.",
"type": "string",
"pattern": "^[A-Z0-9]{2,3}$"
},
"grossUnitPrice": {
"description": "Item price before the item price discount.",
"type": "string",
"pattern": "^\\d{1,8}(?:\\.\\d{1,18})?$"
},
"unitPriceDiscount": {
"description": "Discount on the item price per base quantity.",
"type": "string",
"pattern": "^\\d{1,8}(?:\\.\\d{1,18})?$"
},
"unit": {
"default": "C62",
"type": "string",
"pattern": "^[A-Z0-9]{2,3}$"
},
"vatRate": {
"type": "string",
"pattern": "^\\d{1,3}(?:\\.\\d{1,2})?$"
}
},
"required": [
"description",
"quantity",
"unitPrice",
"vatRate"
],
"additionalProperties": false
}
}
},
"required": [
"format",
"invoiceNumber",
"issueDate",
"dueDate",
"buyerReference",
"seller",
"buyer",
"iban",
"lines"
],
"additionalProperties": false,
"examples": [
{
"format": "ubl",
"invoiceNumber": "2026-0417",
"issueDate": "2026-11-23",
"deliveryDate": "2026-11-20",
"dueDate": "2026-12-23",
"buyerReference": "90000000-03083-72",
"seller": {
"name": "Linden Consulting GmbH",
"vatId": "DE123456789",
"email": "billing@example.com",
"street": "Lindenstraße 12",
"city": "Berlin",
"postalCode": "10117",
"country": "DE",
"contact": {
"name": "Kai Weber",
"phone": "+49 30 5550100",
"email": "kai@example.com"
}
},
"buyer": {
"name": "Nordhafen Verwaltungs GmbH",
"email": "invoices@example.org",
"street": "Hafenstraße 8",
"city": "Hamburg",
"postalCode": "20457",
"country": "DE"
},
"iban": "DE79000000001234567890",
"lines": [
{
"description": "Software integration workshop",
"quantity": "2",
"unitPrice": "475.00",
"vatRate": "19"
}
]
}
]
}Response schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"format": {
"type": "string",
"enum": [
"ubl",
"cii",
"zugferd"
]
},
"xml": {
"type": "string"
},
"validation": {
"type": "object",
"properties": {
"valid": {
"type": "boolean"
},
"validator": {
"type": "string",
"const": "KoSIT 1.6.3 / XRechnung 3.0.2 (2026-08-31)"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"ruleId": {
"type": "string"
},
"severity": {
"type": "string"
},
"xpath": {
"type": "string"
},
"field": {
"type": "string"
},
"message": {
"type": "string"
},
"fixHint": {
"type": "string"
}
},
"required": [
"ruleId",
"severity",
"xpath",
"field",
"message",
"fixHint"
],
"additionalProperties": false
}
}
},
"required": [
"valid",
"validator",
"issues"
],
"additionalProperties": false
},
"pdfBase64": {
"description": "PDF/A-3 for format zugferd",
"type": "string",
"format": "base64",
"contentEncoding": "base64",
"pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$"
}
},
"required": [
"format",
"xml",
"validation"
],
"additionalProperties": false
}