{"openapi": "3.1.0", "info": {"title": "Magic Heidi AI Invoice API", "version": "1.0.0", "description": "Make a Swiss invoice PDF with a valid QR-bill. Free, no login, no API key. Read the guide first: `GET https://api.magicheidi.ch/v1/ai-invoice` (Markdown, written for AI models). Amounts use commercial rounding (half up)."}, "servers": [{"url": "https://api.magicheidi.ch/v1"}], "tags": [{"name": "AI Invoice API", "description": "Free and without an API key: AI assistants make a Swiss invoice PDF with a QR-bill for their user. The PDF has the invoice body (the default template, or the caller's own HTML), the banner \"Erstellt mit Magic Heidi · magicheidi.ch\" and the payment part (the QR-bill), which is always drawn from the JSON fields. The guide for AI models is `GET /ai-invoice`; these operations alone: `GET /ai-invoice/openapi.json`. Rendering (checks included) is limited to 20 requests per minute and 300 per day per IP address; the guide, the template and stored files to 300 requests per minute per IP address."}], "paths": {"/ai-invoice": {"get": {"tags": ["AI Invoice API"], "operationId": "ai_invoice_link", "summary": "Guide, or an invoice PDF from a link", "description": "Without `data` or `d`: the guide for AI models, as Markdown.\n\nWith `data` (the request JSON, URL-encoded) or `d` (the request JSON, base64url, padding optional): the invoice PDF, rendered on the spot and shown inline (`invoice-<number>.pdf`); with `check=1` the check (`AiInvoiceCheck`) instead. Nothing is stored. The link must carry `invoice.date`. Errors are indented JSON, readable in a browser. Links over 4000 characters get 414 `uri_too_long`: use POST.", "security": [], "parameters": [{"name": "data", "in": "query", "required": false, "schema": {"type": "string"}, "description": "The request (see `AiInvoiceRequest`) as URL-encoded JSON.", "example": "{\"creditor\":{\"name\":\"Muster GmbH\",\"street\":\"Bahnhofstrasse 1\",\"postal_code\":\"8001\",\"city\":\"Zürich\",\"iban\":\"CH9300762011623852957\"},\"invoice\":{\"number\":\"1\",\"date\":\"2026-11-30\"},\"items\":[{\"description\":\"Beratung\",\"unit_price\":100}]}"}, {"name": "d", "in": "query", "required": false, "schema": {"type": "string"}, "description": "The request as base64url-encoded JSON, instead of `data`."}, {"name": "check", "in": "query", "required": false, "schema": {"type": "string", "enum": ["1", "true", "yes"]}, "description": "`1` (or `true`, `yes`): check and render like the real request, but answer `AiInvoiceCheck` JSON (totals, VAT, lines, pages, warnings, the GET link) instead of the PDF. Nothing is stored. Counts against the same rate limits.", "example": "1"}], "responses": {"200": {"description": "The guide (no `data` or `d`), the PDF, or with `check=1` the check; the PDF and the check carry the X-RateLimit headers", "headers": {"X-RateLimit-Limit": {"description": "Renders allowed per minute for this IP address.", "schema": {"type": "integer"}}, "X-RateLimit-Remaining": {"description": "Renders left in the current minute.", "schema": {"type": "integer"}}, "X-RateLimit-Reset": {"description": "Seconds until the minute resets.", "schema": {"type": "integer"}}, "X-AI-Invoice-Warning": {"description": "On a PDF: `example_iban` when it is made out to an example IBAN of the guide (the PDF is then a specimen and its QR code pays nothing).", "schema": {"type": "string", "enum": ["example_iban"]}}}, "content": {"text/markdown": {"schema": {"type": "string"}}, "application/pdf": {"schema": {"type": "string", "format": "binary"}}, "application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "const": true}, "data": {"$ref": "#/components/schemas/AiInvoiceCheck"}}, "required": ["success", "data"]}, "examples": {"check": {"summary": "check=1", "value": {"success": true, "data": {"valid": true, "currency": "CHF", "total": "1297.20", "subtotal": "1200.00", "vat": [{"rate": "8.1", "base": "1200.00", "amount": "97.20"}], "lines": [{"index": 0, "amount": "1200.00", "vat_rate": "8.1"}], "pages": 1, "reference_type": "NON", "link": "https://api.magicheidi.ch/v1/ai-invoice?data=%7B%22creditor%22:...", "warnings": [{"code": "example_iban", "field": "creditor.iban", "message": "`creditor.iban` is one of the example IBANs in this guide (a regular IBAN). Never use it for a user's invoice: payments would go to a stranger. The PDF is marked as a specimen and its QR code pays nothing. Ask the user for their own IBAN."}]}}}}}}}, "400": {"description": "The invoice has problems; `error` lists each one with how to fix it, `details.errors` one per field", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"qrIban": {"summary": "QR-IBAN without a QR reference", "value": {"success": false, "error": "No invoice was made. Fix this problem and send the request again:\n1. `creditor.iban` is a QR-IBAN, so `reference` must be a 27-digit QR reference. Either add one or use the regular IBAN of the account.\nRead GET /v1/ai-invoice for the full guide.", "code": "validation_failed", "details": {"code": "validation_failed", "errors": [{"field": "reference", "code": "required", "message": "`creditor.iban` is a QR-IBAN, so `reference` must be a 27-digit QR reference. Either add one or use the regular IBAN of the account."}]}}}}}}}, "414": {"description": "The link is over 4000 characters; send the JSON with POST instead", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"tooLong": {"summary": "Too long", "value": {"success": false, "error": "This link is 5230 characters long; links over 4000 characters fail on the way to us. Send the same JSON with POST /v1/ai-invoice instead. Read GET /v1/ai-invoice for the full guide.", "code": "uri_too_long"}}}}}}, "422": {"description": "The body is too long (over 10 pages in total) or too slow, big or deep to render", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"tooManyPages": {"summary": "Too many pages", "value": {"success": false, "error": "The invoice body is 14 pages long; at most 10 pages are allowed in total, including an extra page for the payment part if one is needed. Shorten it: fewer or shorter items, smaller fonts or less spacing.", "code": "unprocessable", "details": {"reason": "too_many_pages"}}}}}}}, "429": {"description": "Too many requests from this IP address (at most 20 renders per minute and 300 per day (checks included)), or from all callers together", "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"limited": {"summary": "Limit reached", "value": {"success": false, "error": "Too many requests: at most 20 requests per minute on this endpoint. Retry in 12 seconds.", "code": "rate_limited", "details": {"limit": "20/minute", "scope": "endpoint", "retryAfter": 12}}}}}}}, "500": {"description": "Rendering failed on our side; try again", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"failed": {"summary": "Failed", "value": {"success": false, "error": "The invoice could not be rendered because of an error on our side. Try again.", "code": "internal_error", "details": {"reason": "render_failed"}}}}}}}, "503": {"description": "Busy rendering other invoices (after queuing up to 8 seconds); retry after `Retry-After` seconds", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"busy": {"summary": "Busy", "value": {"success": false, "error": "Too many invoices are being made right now. Try again in a few seconds.", "code": "upstream_unavailable", "details": {"reason": "busy"}}}}}}, "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}}}}, "post": {"tags": ["AI Invoice API"], "operationId": "ai_invoice_create", "summary": "Make an invoice PDF", "description": "Renders the invoice and stores the PDF for 24 hours: the answer is a link to it, which needs no login. With `Accept: application/pdf` (and not application/json) the answer is the PDF itself and nothing is stored. With `?check=1` the answer is the check (`AiInvoiceCheck`) and nothing is stored. At most 500 KB per request. Amounts use commercial rounding (half up).", "security": [], "parameters": [{"name": "check", "in": "query", "required": false, "schema": {"type": "string", "enum": ["1", "true", "yes"]}, "description": "`1` (or `true`, `yes`): check and render like the real request, but answer `AiInvoiceCheck` JSON (totals, VAT, lines, pages, warnings, the GET link) instead of the PDF. Nothing is stored. Counts against the same rate limits.", "example": "1"}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceRequest"}, "examples": {"example": {"summary": "Default template", "value": {"language": "de", "creditor": {"name": "Muster GmbH", "street": "Bahnhofstrasse", "building_number": "1", "postal_code": "8001", "city": "Zürich", "iban": "CH93 0076 2011 6238 5295 7"}, "debtor": {"name": "Beispiel AG", "street": "Seestrasse", "building_number": "5", "postal_code": "6003", "city": "Luzern"}, "invoice": {"number": "2026-001", "date": "2026-11-30", "due_date": "2026-12-30", "vat_number": "CHE-123.456.788 MWST"}, "items": [{"description": "Webdesign", "quantity": 10, "unit": "h", "unit_price": 120, "vat_rate": 8.1}]}}}}}}, "responses": {"200": {"description": "A link to the PDF, valid 24 hours; with `check=1` the check", "content": {"application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "const": true}, "data": {"oneOf": [{"$ref": "#/components/schemas/AiInvoiceLink"}, {"$ref": "#/components/schemas/AiInvoiceCheck"}]}}, "required": ["success", "data"]}, "examples": {"link": {"summary": "Link", "value": {"success": true, "data": {"url": "https://api.magicheidi.ch/v1/ai-invoice/files/q3Vb9xK2mN7pR4sT8wY1zA5cE6fH0jL3.pdf", "expires_at": "2026-12-01T14:03:00+01:00", "pages": 1, "warnings": []}}}, "check": {"summary": "check=1", "value": {"success": true, "data": {"valid": true, "currency": "CHF", "total": "1297.20", "subtotal": "1200.00", "vat": [{"rate": "8.1", "base": "1200.00", "amount": "97.20"}], "lines": [{"index": 0, "amount": "1200.00", "vat_rate": "8.1"}], "pages": 1, "reference_type": "NON", "link": "https://api.magicheidi.ch/v1/ai-invoice?data=%7B%22creditor%22:...", "warnings": [{"code": "example_iban", "field": "creditor.iban", "message": "`creditor.iban` is one of the example IBANs in this guide (a regular IBAN). Never use it for a user's invoice: payments would go to a stranger. The PDF is marked as a specimen and its QR code pays nothing. Ask the user for their own IBAN."}]}}}}}}, "headers": {"X-RateLimit-Limit": {"description": "Renders allowed per minute for this IP address.", "schema": {"type": "integer"}}, "X-RateLimit-Remaining": {"description": "Renders left in the current minute.", "schema": {"type": "integer"}}, "X-RateLimit-Reset": {"description": "Seconds until the minute resets.", "schema": {"type": "integer"}}, "X-AI-Invoice-Warning": {"description": "On a PDF: `example_iban` when it is made out to an example IBAN of the guide (the PDF is then a specimen and its QR code pays nothing).", "schema": {"type": "string", "enum": ["example_iban"]}}}}, "400": {"description": "The invoice has problems; `error` lists each one with how to fix it, `details.errors` one per field", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"qrIban": {"summary": "QR-IBAN without a QR reference", "value": {"success": false, "error": "No invoice was made. Fix this problem and send the request again:\n1. `creditor.iban` is a QR-IBAN, so `reference` must be a 27-digit QR reference. Either add one or use the regular IBAN of the account.\nRead GET /v1/ai-invoice for the full guide.", "code": "validation_failed", "details": {"code": "validation_failed", "errors": [{"field": "reference", "code": "required", "message": "`creditor.iban` is a QR-IBAN, so `reference` must be a 27-digit QR reference. Either add one or use the regular IBAN of the account."}]}}}}}}}, "413": {"description": "The request is over 500 KB", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"tooLarge": {"summary": "Too large", "value": {"success": false, "error": "The request is 812 KB, larger than 500 KB. Make it smaller: a smaller logo or images, less HTML.", "code": "payload_too_large"}}}}}}, "422": {"description": "The body is too long (over 10 pages in total) or too slow, big or deep to render", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"tooManyPages": {"summary": "Too many pages", "value": {"success": false, "error": "The invoice body is 14 pages long; at most 10 pages are allowed in total, including an extra page for the payment part if one is needed. Shorten it: fewer or shorter items, smaller fonts or less spacing.", "code": "unprocessable", "details": {"reason": "too_many_pages"}}}}}}}, "429": {"description": "Too many requests from this IP address (at most 20 renders per minute and 300 per day (checks included)), or from all callers together", "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"limited": {"summary": "Limit reached", "value": {"success": false, "error": "Too many requests: at most 20 requests per minute on this endpoint. Retry in 12 seconds.", "code": "rate_limited", "details": {"limit": "20/minute", "scope": "endpoint", "retryAfter": 12}}}}}}}, "500": {"description": "Rendering failed on our side; try again", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"failed": {"summary": "Failed", "value": {"success": false, "error": "The invoice could not be rendered because of an error on our side. Try again.", "code": "internal_error", "details": {"reason": "render_failed"}}}}}}}, "503": {"description": "Busy rendering other invoices (after queuing up to 8 seconds); retry after `Retry-After` seconds", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"busy": {"summary": "Busy", "value": {"success": false, "error": "Too many invoices are being made right now. Try again in a few seconds.", "code": "upstream_unavailable", "details": {"reason": "busy"}}}}}}, "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}}}}}, "/ai-invoice/template": {"get": {"tags": ["AI Invoice API"], "operationId": "ai_invoice_template", "summary": "Get the default invoice body", "description": "The default template's HTML and CSS, filled with sample data, to copy, change and send back as `html` (or to see the class names `css` can restyle). The banner and the payment part are not part of it.", "security": [], "parameters": [{"name": "language", "in": "query", "required": false, "schema": {"type": "string", "enum": ["de", "fr", "it", "en"], "default": "de"}, "description": "Language of the labels.", "example": "de"}], "responses": {"200": {"description": "The invoice body as an HTML document", "content": {"text/html": {"schema": {"type": "string"}}}}, "429": {"description": "Too many requests from this IP address (at most 300 requests per minute), or from all callers together", "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"limited": {"summary": "Limit reached", "value": {"success": false, "error": "Too many requests: at most 20 requests per minute on this endpoint. Retry in 12 seconds.", "code": "rate_limited", "details": {"limit": "20/minute", "scope": "endpoint", "retryAfter": 12}}}}}}}}}}, "/ai-invoice/openapi.json": {"get": {"tags": ["AI Invoice API"], "operationId": "ai_invoice_openapi", "summary": "Get the AI Invoice API's own specification", "description": "An OpenAPI 3.1 document with only the AI Invoice API's operations, for tools and models.", "security": [], "responses": {"200": {"description": "The OpenAPI document (not wrapped in `success`/`data`)", "content": {"application/json": {"schema": {"type": "object"}}}}, "429": {"description": "Too many requests from this IP address (at most 300 requests per minute), or from all callers together", "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"limited": {"summary": "Limit reached", "value": {"success": false, "error": "Too many requests: at most 20 requests per minute on this endpoint. Retry in 12 seconds.", "code": "rate_limited", "details": {"limit": "20/minute", "scope": "endpoint", "retryAfter": 12}}}}}}}}}}, "/ai-invoice/files/{fileId}.pdf": {"get": {"tags": ["AI Invoice API"], "operationId": "ai_invoice_file", "summary": "Download a stored invoice PDF", "description": "The PDF behind a `url` from `POST /ai-invoice`, for 24 hours after it was made. After that, or for an unknown link: 404, as JSON, or as a short page in four languages for a browser (Accept text/html).", "security": [], "parameters": [{"name": "fileId", "in": "path", "required": true, "schema": {"type": "string"}, "description": "The id in the `url` that `POST /ai-invoice` returned.", "example": "q3Vb9xK2mN7pR4sT8wY1zA5cE6fH0jL3"}], "responses": {"200": {"description": "The PDF, shown inline", "content": {"application/pdf": {"schema": {"type": "string", "format": "binary"}}}}, "404": {"description": "No PDF at this link, or it expired after 24 hours", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"expired": {"summary": "Expired", "value": {"success": false, "error": "This invoice link expired at 2026-12-01T14:03:00+01:00 (links work for 24 hours). Make the invoice again.", "code": "not_found"}}}}, "text/html": {"schema": {"type": "string"}}}}, "429": {"description": "Too many requests from this IP address (at most 300 requests per minute), or from all callers together", "headers": {"Retry-After": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer", "minimum": 1}}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AiInvoiceError"}, "examples": {"limited": {"summary": "Limit reached", "value": {"success": false, "error": "Too many requests: at most 20 requests per minute on this endpoint. Retry in 12 seconds.", "code": "rate_limited", "details": {"limit": "20/minute", "scope": "endpoint", "retryAfter": 12}}}}}}}}}}}, "components": {"schemas": {"AiInvoiceCheck": {"type": "object", "properties": {"valid": {"type": "boolean", "const": true}, "currency": {"type": "string", "enum": ["CHF", "EUR"]}, "total": {"type": "string", "description": "The amount the payment part asks for, 2 decimals, e.g. `1297.20`."}, "subtotal": {"type": ["string", "null"], "description": "Without VAT; null with `html` and no `items`."}, "vat": {"type": "array", "description": "Per VAT rate in the items, 0 % included; empty when no item has a VAT rate or without `items`.", "items": {"type": "object", "properties": {"rate": {"type": "string", "description": "Percent, e.g. `8.1` or `0`."}, "base": {"type": "string", "description": "The lines of this rate without VAT."}, "amount": {"type": "string"}}, "required": ["rate", "base", "amount"]}}, "lines": {"type": "array", "description": "Each item's amount as printed (quantity x unit price, rounded half up to the cent).", "items": {"type": "object", "properties": {"index": {"type": "integer", "minimum": 0}, "amount": {"type": "string"}, "vat_rate": {"type": ["string", "null"], "description": "Null when no item has a VAT rate."}}, "required": ["index", "amount", "vat_rate"]}}, "pages": {"type": "integer", "minimum": 1, "description": "Pages of the PDF, payment part included."}, "reference_type": {"type": "string", "enum": ["QRR", "SCOR", "NON"]}, "link": {"type": ["string", "null"], "description": "The GET link that renders this invoice (its date pinned); null when it would be over 4000 characters."}, "warnings": {"type": "array", "description": "Accepted, but probably not what you want. More codes may be added.", "items": {"$ref": "#/components/schemas/AiInvoiceWarning"}}}, "required": ["valid", "currency", "total", "subtotal", "vat", "lines", "pages", "reference_type", "link", "warnings"], "description": "What `check=1` answers instead of the PDF. Amounts are strings with 2 decimals."}, "AiInvoiceError": {"type": "object", "properties": {"success": {"type": "boolean", "const": false}, "error": {"type": "string", "description": "Every problem with how to fix it, for the model and for people."}, "code": {"type": "string", "enum": ["invalid_request", "invalid_query", "validation_failed", "not_found", "method_not_allowed", "payload_too_large", "uri_too_long", "unprocessable", "rate_limited", "upstream_unavailable", "internal_error"]}, "details": {"type": "object", "properties": {"code": {"type": "string"}, "errors": {"type": "array", "description": "With `validation_failed`: one entry per field.", "items": {"type": "object", "properties": {"field": {"type": "string", "description": "JSON path, e.g. `items[0].vat_rate`."}, "code": {"type": "string", "enum": ["required", "invalid_type", "invalid_format", "invalid_enum", "too_long", "out_of_range", "unknown_field", "ambiguous_number"]}, "message": {"type": "string", "description": "What is wrong and what to send instead."}}, "required": ["field", "code", "message"]}}, "reason": {"type": "string", "description": "With 422, 500 and 503: `too_many_pages`, `render_timeout`, `render_limit`, `too_deep`, `render_failed`, `busy`."}, "limit": {"type": "string"}, "scope": {"type": "string"}, "retryAfter": {"type": "integer"}}}}, "required": ["success", "error", "code"], "description": "The error envelope of these routes."}, "AiInvoiceLink": {"type": "object", "properties": {"url": {"type": "string", "format": "uri", "description": "The PDF, for 24 hours. No login needed."}, "expires_at": {"type": "string", "format": "date-time", "description": "Swiss time with offset, whole seconds."}, "pages": {"type": "integer", "minimum": 1}, "warnings": {"type": "array", "description": "The same warnings as `check=1`.", "items": {"$ref": "#/components/schemas/AiInvoiceWarning"}}}, "required": ["url", "expires_at", "pages", "warnings"]}, "AiInvoiceRequest": {"type": "object", "properties": {"language": {"type": "string", "enum": ["de", "fr", "it", "en"], "default": "de"}, "currency": {"type": "string", "enum": ["CHF", "EUR"], "default": "CHF"}, "creditor": {"type": "object", "properties": {"name": {"type": "string", "maxLength": 70}, "street": {"type": "string", "maxLength": 70, "description": "A house number at its end is split off into `building_number`."}, "building_number": {"type": "string", "maxLength": 16}, "postal_code": {"type": "string", "maxLength": 16, "description": "4 digits in Switzerland and Liechtenstein."}, "city": {"type": "string", "maxLength": 35}, "country": {"type": "string", "default": "CH", "description": "ISO 3166-1 alpha-2."}, "iban": {"type": "string", "description": "A CH or LI IBAN; spaces, dashes, dots and lowercase are fine. A QR-IBAN needs a QR `reference`."}}, "required": ["name", "street", "postal_code", "city", "iban"], "description": "Who gets paid.", "additionalProperties": false}, "debtor": {"type": "object", "properties": {"name": {"type": "string", "maxLength": 70}, "street": {"type": "string", "maxLength": 70, "description": "A house number at its end is split off into `building_number`."}, "building_number": {"type": "string", "maxLength": 16}, "postal_code": {"type": "string", "maxLength": 16, "description": "4 digits in Switzerland and Liechtenstein."}, "city": {"type": "string", "maxLength": 35}, "country": {"type": "string", "default": "CH", "description": "ISO 3166-1 alpha-2."}}, "required": ["name", "postal_code", "city"], "description": "Who pays. Without it the payment part has an empty box for name and address.", "additionalProperties": false}, "reference": {"type": "string", "maxLength": 40, "description": "A 27-digit QR reference (required with a QR-IBAN, only allowed with one) or an RF creditor reference (only with a regular IBAN). Spaces and lowercase `rf` are fine."}, "message": {"type": "string", "maxLength": 140, "description": "Message on the payment part, passed to the bank. Default: \"Rechnung/Facture/Fattura/Invoice <invoice.number>\"."}, "amount": {"type": "number", "minimum": 0.01, "maximum": 999999999.99, "description": "The amount to pay, at most 2 decimals. Computed from `items` when left out; required with `html`. When both are sent they must agree."}, "invoice": {"type": "object", "properties": {"number": {"type": "string", "maxLength": 40, "description": "The user's next invoice number. Required with the default template."}, "date": {"type": "string", "format": "date", "description": "YYYY-MM-DD. Required in a GET link; POST defaults to today."}, "due_date": {"type": "string", "format": "date"}, "title": {"type": "string", "maxLength": 80, "description": "Default: Rechnung, Facture, Fattura or Invoice."}, "intro": {"type": "string", "maxLength": 3000}, "notes": {"type": "string", "maxLength": 3000}, "logo": {"type": "string", "maxLength": 400000, "description": "Default template only: a data: URI of a PNG, JPEG, GIF, WebP or SVG image. URLs are not fetched."}, "vat_number": {"type": "string", "maxLength": 40, "description": "The seller's VAT number: a Swiss UID with a valid check digit, e.g. `CHE-123.456.788 MWST` (separators optional; MWST, TVA or IVA optional), or a Liechtenstein one (5 digits). Required when an item has a `vat_rate` above 0."}}, "additionalProperties": false}, "items": {"type": "array", "minItems": 1, "maxItems": 200, "items": {"type": "object", "properties": {"description": {"type": "string", "maxLength": 1000, "description": "Text after a line break is shown smaller."}, "quantity": {"type": "number", "default": 1, "minimum": -1000000, "maximum": 1000000, "description": "At most 3 decimals."}, "unit": {"type": "string", "maxLength": 20}, "unit_price": {"type": "number", "minimum": -10000000, "maximum": 10000000, "description": "At most 2 decimals."}, "vat_rate": {"type": "number", "enum": [0, 2.5, 2.6, 3.7, 3.8, 7.7, 8.1], "description": "Percent. Send it on every item or on none (none: no VAT is charged); 0 for VAT-exempt lines. 8.1, 2.6 and 3.8 from 2024; the old 7.7, 2.5 and 3.7 only for an `invoice.date` before 2024."}}, "required": ["description", "unit_price"], "additionalProperties": false}}, "prices_include_vat": {"type": "boolean", "default": false, "description": "For the whole invoice."}, "css": {"type": "string", "maxLength": 100000, "description": "Added after the default template's stylesheet (and after your `html`)."}, "html": {"type": "string", "maxLength": 450000, "description": "The whole invoice body as HTML, replacing the default template. No placeholders. Nothing is fetched (images as data: URIs); the bottom 115 mm of the last page must stay free."}}, "required": ["creditor"], "description": "An invoice for the AI Invoice API. Unknown fields are refused, with the field to use instead.", "additionalProperties": false, "allOf": [{"if": {"required": ["html"]}, "then": {"required": ["amount"]}, "else": {"required": ["invoice", "items"], "properties": {"invoice": {"required": ["number"]}}}}, {"if": {"required": ["items"], "properties": {"items": {"contains": {"required": ["vat_rate"], "properties": {"vat_rate": {"exclusiveMinimum": 0}}}}}}, "then": {"required": ["invoice"], "properties": {"invoice": {"required": ["vat_number"]}}}}, {"if": {"required": ["items"], "properties": {"items": {"contains": {"required": ["vat_rate"]}}}}, "then": {"properties": {"items": {"items": {"required": ["vat_rate"]}}}}}]}, "AiInvoiceWarning": {"type": "object", "properties": {"code": {"type": "string", "enum": ["example_iban", "example_vat_number", "ignored_with_html", "missing_glyphs", "unusual_date", "vat_rate_not_in_force", "payment_part_on_extra_page", "message_left_out"]}, "field": {"type": "string"}, "message": {"type": "string"}}, "required": ["code", "field", "message"]}}}}