{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/legivel-com/json-schema/legivel-com-template-update-schema.json",
  "title": "TemplateUpdate",
  "description": "A change. `base_revision` is the revision you read; what you leave out stays as it was. At most one of `body`, `markdown` or `html`.",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/legivel-com-openapi.json#/components/schemas/TemplateUpdate",
  "type": "object",
  "properties": {
    "base_revision": {
      "type": "integer",
      "minimum": 1,
      "description": "The revision you read. A newer saved revision answers 409 `template_version_conflict`."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "body": {
      "$ref": "#/$defs/TemplateDocument"
    },
    "markdown": {
      "type": "string",
      "description": "Markdown to import. `{{path}}` becomes a field; headings, paragraphs, lists, quotes, code and tables become blocks. Pictures and HTML forms are left out."
    },
    "html": {
      "type": "string",
      "description": "HTML to import, as for `markdown`. Inline colors, weights, sizes and alignment are kept; scripts and styles are dropped."
    }
  },
  "required": [
    "base_revision"
  ],
  "additionalProperties": false,
  "$defs": {
    "TemplateDocument": {
      "type": "object",
      "title": "TemplateDocument",
      "description": "The editor document, the JSON the template editor saves and reads: the page, the `blocks` of the Body, the `bands` repeated on every page (`header`, `footer`, `left`, `right`) and the `placed` items at a fixed place on the page. A span with `field` reads a data path. A table with `bind` takes one row per record of a CSV or a JSON list. A placed `image` with `field` takes its picture from the data. A placed image's `src` is `asset:<id>`, a picture of the account. Send a PNG or JPEG as a base64 data URL, and the save stores it as one. The format is described at https://legivel.com/docs/templates/format. Read one with GET, change it, and send it back with PUT.",
      "properties": {
        "version": {
          "type": "integer",
          "enum": [
            0
          ]
        },
        "page": {
          "type": "object",
          "description": "Width, height and margins in points (1/72 inch)."
        },
        "blocks": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "Paragraphs and tables, in order."
        }
      },
      "required": [
        "version",
        "page",
        "blocks"
      ]
    }
  }
}