{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lumabill-ch/json-schema/lumabill-ch-recurring-invoice-write-schema.json",
  "title": "RecurringInvoiceWrite",
  "description": "On create, `client_id`, `items`, `frequency` and `startDate` are required; sender, payment details and meta defaults come from the profile, as for POST /invoices. On update every field is optional: `items`, `client_id` and `meta` patch the stored template (the rest of it stays), `invoiceTemplate` replaces it whole. `notes`, `language`, `swissQr` and `paymentInstructions` set single template settings (merged with the stored ones on update; explicit `meta` keys win).\n",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lumabill-ch-openapi.yaml#/components/schemas/RecurringInvoiceWrite",
  "type": "object",
  "properties": {
    "client_id": {
      "type": "string",
      "format": "uuid",
      "description": "UUID of an existing client of the profile. `404` if not found."
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InvoiceLine"
      }
    },
    "frequency": {
      "type": "string",
      "enum": [
        "monthly",
        "quarterly",
        "yearly",
        "custom"
      ],
      "description": "`custom` repeats every `intervalMonths` months (e.g. 6 = half-yearly)"
    },
    "intervalMonths": {
      "type": "integer",
      "minimum": 1,
      "maximum": 36,
      "description": "Months between invoices. Required with `custom` (400 otherwise)."
    },
    "startDate": {
      "type": "string",
      "format": "date",
      "description": "Date of the first invoice."
    },
    "endDate": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "Last date an invoice may be generated on (400 if before the start / next run). Send null on update to remove it."
    },
    "currency": {
      "allOf": [
        {
          "$ref": "#/$defs/Currency"
        }
      ],
      "description": "Create only. Defaults to the profile default currency."
    },
    "meta": {
      "type": "object",
      "additionalProperties": true,
      "description": "Invoice settings (e.g. `currency`, `footer`); merged with the stored meta on update."
    },
    "notes": {
      "type": "string",
      "description": "Closing text of the generated invoices (`meta.footer`). Defaults to the profile closing text on create."
    },
    "language": {
      "type": "string",
      "enum": [
        "de-CH",
        "fr-CH",
        "it-CH",
        "en-US",
        "es-ES"
      ],
      "description": "Document language (`meta.locale`). Defaults to the profile language on create."
    },
    "swissQr": {
      "type": "boolean",
      "description": "Swiss QR bill on the generated invoices (`meta.isSwissQrEnabled`, CHF/EUR with an IBAN)."
    },
    "paymentInstructions": {
      "type": "string",
      "description": "Payment text printed when no QR bill is used (`payment.bankDetails`). Placeholders like `{{invoice_number}}` and `{{iban}}` resolve per invoice.\n"
    },
    "label": {
      "type": "string",
      "description": "Name in the list. Defaults to \"Recurring - <client>\"."
    },
    "autoSend": {
      "type": "boolean",
      "default": false
    },
    "active": {
      "type": "boolean",
      "default": true
    },
    "invoiceTemplate": {
      "type": "object",
      "additionalProperties": true,
      "description": "Update only. Replaces the whole template."
    }
  },
  "$defs": {
    "Currency": {
      "type": "string",
      "description": "ISO 4217 code of a currency the API converts (ESTV/BAZG rates). The same list applies to every currency field of the API.\n",
      "enum": [
        "CHF",
        "EUR",
        "USD",
        "GBP",
        "JPY",
        "CAD",
        "AUD",
        "SEK",
        "NOK",
        "DKK",
        "HUF"
      ]
    },
    "InvoiceLine": {
      "type": "object",
      "required": [
        "description",
        "quantity",
        "price"
      ],
      "properties": {
        "catalog_item_id": {
          "type": "string",
          "format": "uuid",
          "description": "Takes the line from a catalog item of the profile: title, description (as `details`), price and unit, plus tax rate, discount and VAT code where the document shows those columns. Fields sent with it win; `description` and `price` may then be omitted. `404 CATALOG_ITEM_NOT_FOUND` if unknown.\n"
        },
        "description": {
          "type": "string"
        },
        "details": {
          "type": [
            "string",
            "null"
          ],
          "description": "Detail text printed under the description."
        },
        "quantity": {
          "type": "number",
          "format": "double"
        },
        "price": {
          "type": "number",
          "format": "double"
        },
        "vat_rate": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "VAT rate as a percentage (e.g. 8.1 for 8.1 %). If omitted, the profile's default tax rate is used.\n"
        }
      }
    }
  }
}