{
  "openapi": "3.0.3",
  "info": {
    "title": "Oomplo API",
    "version": "0.1.0",
    "description": "Oomplo runs on your own server (Docker). Every address below is relative to it, e.g. `https://oomplo.your-company.example`.\n\nRequests and answers are JSON unless a file is returned. Errors are `{\"error\": \"…\"}` with a status code: 400 wrong request, 401 missing or wrong key, 403 outside the key's scope, 404 unknown, 409 conflict, 422 the document cannot be made, 429 too many requests at a time (retry after `Retry-After` seconds), 503 the server is busy.\n\nAuthenticate with an API key: `Authorization: Bearer oomplo_…`. An administrator creates keys in the page: account menu → API keys.",
    "contact": {
      "name": "Oomplo",
      "url": "https://oomplo.com"
    }
  },
  "servers": [
    {
      "url": "{baseUrl}",
      "description": "Your Oomplo server",
      "variables": {
        "baseUrl": {
          "default": "http://127.0.0.1:3001",
          "description": "Where Oomplo runs, without a trailing slash"
        }
      }
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Documents",
      "description": "A PDF or a filled Word document from a published template, the data a template needs and a check of your data before you generate."
    },
    {
      "name": "Series jobs",
      "description": "Many documents at once from rows of a spreadsheet, a CSV or a JSON array: one PDF per row in a ZIP, or one PDF for all rows."
    },
    {
      "name": "Templates in the request",
      "description": "Work with a DOCX sent in the request instead of a stored template: render it, check it, or build a template from filled documents."
    },
    {
      "name": "History",
      "description": "Who made which document when. The history never contains your data or the documents."
    },
    {
      "name": "Embedded editor",
      "description": "A short-lived token that opens the template editor in an iframe of your application."
    },
    {
      "name": "Server",
      "description": "Whether the server runs."
    }
  ],
  "paths": {
    "/api/templates/{id}/render": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The template of the library",
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "tags": [
          "Documents"
        ],
        "operationId": "renderTemplate",
        "summary": "PDF of a template of the library by its id",
        "description": "The PDF of the template's published version (or of `version`) with the data given; the pipeline, the limits and the answers are those of POST /api/render with the version's document, so the PDF has the same bytes. POST /api/render with a DOCX file stays the way to render without keeping the template on the server.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "data": {
                    "type": "object",
                    "description": "Data replacing the template's own (as in POST /api/render)"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "A kept version instead of the published one"
                  },
                  "draft": {
                    "type": "boolean",
                    "description": "The working copy instead of a version (X-Oomplo-Template-Version 0); a test key or a signed-in user, not a production key (403)"
                  },
                  "strict": {
                    "type": "boolean",
                    "description": "Refuse a template whose PDF would be simplified"
                  },
                  "missing": {
                    "type": "string",
                    "enum": [
                      "error",
                      "empty"
                    ],
                    "default": "error",
                    "description": "Error (422 naming every missing value) or empty (an empty text)"
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "pdf",
                      "docx"
                    ],
                    "default": "pdf",
                    "description": "Docx returns the filled Word document instead of the PDF"
                  },
                  "fields": {
                    "type": "string",
                    "enum": [
                      "text",
                      "keep"
                    ],
                    "default": "text",
                    "description": "With docx: keep leaves the data fields as Word content controls showing their values (the file stays a template)"
                  },
                  "response": {
                    "type": "string",
                    "enum": [
                      "file",
                      "json"
                    ],
                    "default": "file",
                    "description": "Json answers { file (base64), contentType, fileName, pages, warnings } instead of the file"
                  },
                  "seal": {
                    "type": "boolean",
                    "description": "The company seal over the PDF (OOMPLO_SEAL_KEY and OOMPLO_SEAL_CERT; 422 when the server has only the test seal)"
                  },
                  "pdfa": {
                    "type": "string",
                    "enum": [
                      "2b",
                      "2u",
                      "2a",
                      "3b",
                      "3u",
                      "3a"
                    ],
                    "description": "Archival PDF/A, as in POST /api/render"
                  },
                  "pdfua": {
                    "type": "boolean",
                    "description": "Accessible PDF/UA-1, as in POST /api/render"
                  },
                  "attachData": {
                    "type": "boolean",
                    "description": "The data attached as data.json (PDF/A-3 or no PDF/A), as in POST /api/render"
                  },
                  "dataXml": {
                    "type": "string",
                    "format": "byte",
                    "description": "The data as an XML file in base64 (a KSeF invoice gets $ksef), as in POST /api/render"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The PDF",
            "headers": {
              "X-Oomplo-Template-Version": {
                "schema": {
                  "type": "integer"
                },
                "description": "The version rendered"
              },
              "X-Oomplo-Signature-Fields": {
                "schema": {
                  "type": "string"
                },
                "description": "Percent-encoded JSON array, one item per signature field of the PDF, for a signing service: `name` (the PDF field, `Podpis-<GUID>`), `label`, `page` (from 1), `rect` (points from the page's bottom-left corner: left, bottom, right, top, as the field's /Rect), `pageSize` (points), and who signs there after the data is filled in: `role`, `signer`, `email` (null when the workflow cannot be resolved)."
              },
              "X-Oomplo-Warnings": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Oomplo-Warnings-List": {
                "schema": {
                  "type": "string"
                },
                "description": "Percent-encoded JSON array"
              },
              "X-Oomplo-Fonts-Substituted": {
                "schema": {
                  "type": "string"
                },
                "description": "Percent-encoded JSON array"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such template or version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The template has no published version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The template cannot be filled or laid out, or strict refused it (with `warnings`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The render queue is full or the library is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/templates/{id}/validate": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The template of the library",
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "tags": [
          "Documents"
        ],
        "operationId": "validateTemplateData",
        "summary": "What is wrong with data for a template, all at once, without a PDF",
        "description": "Fills the published version (or `version`) with `data` without a layout and lists every value the template reads that the data does not have (each path once, with the first item of an array without it and the count), every value of the wrong kind for its field (a date, a number, an e-mail address, a picture) with its path and the index of its item, and the error filling stops at otherwise.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "data": {
                    "type": "object",
                    "description": "Data as for render (a plain object is json.dane1)"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "valid",
                    "missing",
                    "problems",
                    "version"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "path",
                          "count"
                        ],
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "row": {
                            "type": "integer",
                            "description": "First item (from 1) of an array without the value"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "problems": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "path",
                          "message"
                        ],
                        "properties": {
                          "path": {
                            "type": "string",
                            "description": "With the index of its item, e.g. json.dane1.items[2].price"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "error": {
                      "type": "string",
                      "nullable": true
                    },
                    "version": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such template or version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The template has no published version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/templates/{id}/schema": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The template of the library",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "version",
          "in": "query",
          "required": false,
          "description": "A kept version instead of the published one",
          "schema": {
            "type": "integer",
            "minimum": 1
          }
        }
      ],
      "get": {
        "tags": [
          "Documents"
        ],
        "operationId": "templateSchema",
        "summary": "What data a template needs",
        "description": "The fields of the template's published version (or of `version`): data fields and `{{path}}` markers with their full path, kind and number of uses; the arrays of repeated rows and paragraphs with the fields of an item; who signs; and an example data file (a source registry) that fills every field, so POST /api/templates/{id}/render with `data` set to it gives a PDF. The same list as `oomplo schema` and the editor's `Editor.schema()`.",
        "responses": {
          "200": {
            "description": "The schema",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "version",
                    "fields",
                    "arrays",
                    "signers",
                    "example"
                  ],
                  "properties": {
                    "version": {
                      "type": "integer"
                    },
                    "fields": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SchemaField"
                      }
                    },
                    "arrays": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "path",
                          "fields"
                        ],
                        "properties": {
                          "path": {
                            "type": "string",
                            "description": "The array: a JSON array, an Excel sheet or the rows of a CSV"
                          },
                          "fields": {
                            "type": "array",
                            "items": {
                              "$ref": "#/components/schemas/SchemaField"
                            },
                            "description": "Fields of an item (`<array>[]…`)"
                          }
                        }
                      }
                    },
                    "signers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "role",
                          "name",
                          "email"
                        ],
                        "properties": {
                          "role": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "description": "As the template gives it, with {{path}} markers for values of the data"
                          },
                          "email": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "example": {
                      "type": "object",
                      "description": "A source registry ($oomploSources) with a value for every field; for a template whose fields read tables of its data model (table.…), the template's own sources with the model ($oomploModel)"
                    },
                    "jsonSchema": {
                      "type": "object",
                      "description": "A JSON Schema (draft 2020-12) of the data: the plain object (json.dane1) when the template reads only it, else the source registry; types from the kinds of the fields, required unless every use of a field has a text without data"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such template or version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The template has no published version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The library is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/library": {
      "get": {
        "tags": [
          "Documents"
        ],
        "operationId": "library",
        "summary": "The control panel's library — templates with their use, flows with a summary, the newest runs",
        "description": "Templates (format-3 documents) and flow definitions (packages) kept on the server and shared by every browser. A flow links templates by id (`package.documents[].id`); a run records the templates it was made from and its flow (`flow` of `POST /api/runs`). `flows` and `runs` of a template say what uses it; such a template cannot be removed. Templates and data files belong to stores: named groups, a folder `magazyny/<name> [<id>]/` each (`main`, the main store, by default); a flow links data files by id (`package.inputs[].source`). Runs: the 300 newest, with their owner links. No accounts yet: internal network or an authenticating proxy only.",
        "responses": {
          "200": {
            "description": "The library",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "projects": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "updated": {
                            "type": "integer"
                          },
                          "layout": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "array",
                              "items": {
                                "type": "number"
                              },
                              "minItems": 2,
                              "maxItems": 2
                            },
                            "description": "Where the elements of its Project canvas are: element id → [x, y]"
                          }
                        }
                      },
                      "description": "Projects (a DocumentFlow from before projects is one of its own)"
                    },
                    "stores": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "updated": {
                            "type": "integer"
                          },
                          "templates": {
                            "type": "integer"
                          },
                          "data": {
                            "type": "integer"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "",
                              "templates",
                              "data",
                              "pdf",
                              "runs"
                            ],
                            "description": "A project's store holds one kind (pdf: documents saved by store steps; runs: every file of its project's runs); empty: templates and data (the main store)"
                          },
                          "project": {
                            "type": "string",
                            "description": "The project (flow id) it belongs to"
                          },
                          "key": {
                            "type": "string",
                            "description": "Its folder in the storage"
                          },
                          "runs": {
                            "type": "integer",
                            "description": "Runs in a runs store"
                          },
                          "linked": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Projects it is linked to (besides its owner)"
                          },
                          "main": {
                            "type": "boolean",
                            "description": "The project's own store of its kind (folder `projekty/<projekt> [id]/<szablony|dane|pdf|uruchomienia>`, renamed with the project); false: a further store of the project (`projekty/<projekt> [id]/magazyny/<nazwa> [id]`) or one outside projects"
                          }
                        }
                      },
                      "description": "The main store first"
                    },
                    "templates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "origin": {
                            "type": "string"
                          },
                          "store": {
                            "type": "string"
                          },
                          "updated": {
                            "type": "integer",
                            "description": "Unix milliseconds"
                          },
                          "size": {
                            "type": "integer"
                          },
                          "flows": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "runs": {
                            "type": "integer"
                          },
                          "running": {
                            "type": "integer"
                          },
                          "published": {
                            "type": "integer",
                            "nullable": true,
                            "description": "The published version, which POST /api/templates/{id}/render uses; null: not published"
                          },
                          "draft": {
                            "type": "boolean",
                            "description": "The template as last saved differs from the published version (or nothing is published)"
                          },
                          "versions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "version": {
                                  "type": "integer"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "created": {
                                  "type": "integer",
                                  "description": "Unix milliseconds"
                                },
                                "author": {
                                  "type": "string",
                                  "description": "The user who made it"
                                }
                              }
                            },
                            "description": "Kept versions, oldest first"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "json",
                              "xlsx",
                              "csv"
                            ]
                          },
                          "store": {
                            "type": "string"
                          },
                          "updated": {
                            "type": "integer"
                          },
                          "size": {
                            "type": "integer"
                          },
                          "flows": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Flows that link it"
                          }
                        }
                      }
                    },
                    "flows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "updated": {
                            "type": "integer"
                          },
                          "templates": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                },
                                "stored": {
                                  "type": "boolean"
                                },
                                "inputs": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  },
                                  "description": "The data (input names) the template is filled with"
                                },
                                "version": {
                                  "type": "integer",
                                  "description": "The version its runs take (0: @latest)"
                                }
                              }
                            }
                          },
                          "inputs": {
                            "type": "array",
                            "items": {
                              "type": "object"
                            }
                          },
                          "steps": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string"
                                },
                                "store": {
                                  "type": "string",
                                  "description": "A store step: its PDF store"
                                },
                                "label": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "runs": {
                            "type": "object",
                            "properties": {
                              "total": {
                                "type": "integer"
                              },
                              "states": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "integer"
                                }
                              },
                              "last": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "runs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string"
                          },
                          "row": {
                            "type": "integer",
                            "nullable": true
                          },
                          "batch": {
                            "type": "string"
                          },
                          "package": {
                            "type": "string"
                          },
                          "created": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "finished": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          },
                          "documents": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "done": {
                            "type": "integer"
                          },
                          "total": {
                            "type": "integer"
                          },
                          "active": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "owner": {
                            "type": "string"
                          },
                          "ownerPath": {
                            "type": "string"
                          },
                          "store": {
                            "type": "string",
                            "description": "The runs store holding the run (empty: none)"
                          }
                        }
                      }
                    },
                    "runCount": {
                      "type": "integer"
                    },
                    "testSeal": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The store is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/templates/{id}/jobs": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The template of the library",
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "tags": [
          "Series jobs"
        ],
        "operationId": "createSeriesJob",
        "summary": "A series as a job on the server",
        "description": "One copy of the template's published version (or of `version`) per row of a series file, as `oomplo pdf --series`: each row replaces the JSON source `series.name` of the template's data. Every chosen row is filled before the job starts; an error in any row refuses the whole job (422 with the rows), so no PDF is made. The job renders in the background (202); follow it with GET /api/jobs/{id}. At most 1000 rows. Jobs and results are deleted after `OOMPLO_JOB_HOURS` (24 by default); a restart fails running jobs.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A request repeated with the same key (per user, while the job is kept) answers the job it started instead of a new one",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "series"
                ],
                "additionalProperties": false,
                "properties": {
                  "series": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "The JSON source a row replaces (`json.<name>…`)"
                      },
                      "kind": {
                        "type": "string",
                        "enum": [
                          "xlsx",
                          "csv",
                          "json"
                        ],
                        "description": "Xlsx also reads an OpenDocument spreadsheet (.ods); csv reads UTF-8, UTF-16 with BOM, Windows-1250 or ISO-8859-2 with a tab, ; or , between columns; json also reads XML (a KSeF invoice: its lists are arrays)"
                      },
                      "file": {
                        "type": "string",
                        "format": "byte",
                        "description": "The series file in base64 (with kind); or rows"
                      },
                      "rows": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        },
                        "description": "The rows as JSON objects instead of kind and file"
                      },
                      "sheet": {
                        "type": "string",
                        "description": "Excel: the sheet (empty: the first)"
                      },
                      "headerRow": {
                        "type": "integer",
                        "minimum": 1,
                        "description": "Excel: the row of column names (1)"
                      },
                      "path": {
                        "type": "string",
                        "description": "JSON: the array of rows inside the file (empty: the file itself or its only list)"
                      },
                      "mapping": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        },
                        "maxProperties": 500,
                        "description": "The template field (key of a row) each column fills when their names differ, e.g. { \"nazwisko\": \"Last name\" }; the column stays under its own name too. Without mapping and join the job takes those the template remembers for the same name („Generuj z pliku”, `$oomploSeries` in the template data)"
                      },
                      "join": {
                        "type": "object",
                        "required": [
                          "sheet",
                          "key",
                          "as"
                        ],
                        "additionalProperties": false,
                        "description": "Excel only: the rows of another sheet (items) become an array of each row whose key equals the item's key (invoices and their lines)",
                        "properties": {
                          "sheet": {
                            "type": "string",
                            "description": "The sheet of the items"
                          },
                          "key": {
                            "type": "string",
                            "description": "The column of a row with its key"
                          },
                          "detailKey": {
                            "type": "string",
                            "description": "The column of an item with its row's key (empty: the same name as key)"
                          },
                          "as": {
                            "type": "string",
                            "description": "The array of a row the items are, e.g. pozycje"
                          },
                          "mapping": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string"
                            },
                            "maxProperties": 500,
                            "description": "The field of an item each column of the items sheet fills"
                          }
                        }
                      }
                    }
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "rows": {
                    "type": "string",
                    "description": "Rows such as `1-3, 7` (empty: all)"
                  },
                  "label": {
                    "type": "string",
                    "description": "Pattern of the labels and file names, with `{{path}}` (default `Wiersz {{$wiersz}}`)"
                  },
                  "zip": {
                    "type": "boolean",
                    "description": "A ZIP with a PDF per row instead of one PDF with an outline entry per copy"
                  },
                  "duplex": {
                    "type": "boolean",
                    "description": "One PDF: every copy starts on an odd page"
                  },
                  "strict": {
                    "type": "boolean",
                    "description": "The job fails when the template has simplifications"
                  },
                  "missing": {
                    "type": "string",
                    "enum": [
                      "error",
                      "empty"
                    ],
                    "default": "error",
                    "description": "A value a row does not have is an error of the row (the job does not start) or an empty text"
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "pdf",
                      "docx"
                    ],
                    "default": "pdf",
                    "description": "Docx makes a ZIP of filled Word documents, one per row (zip implied; not with seal or duplex)"
                  },
                  "fields": {
                    "type": "string",
                    "enum": [
                      "text",
                      "keep"
                    ],
                    "default": "text",
                    "description": "With docx: keep leaves the data fields as Word content controls showing their values"
                  },
                  "webhook": {
                    "type": "string",
                    "description": "An https:// or http:// address (public) told with a POST { event: job, job: <state as GET /api/jobs/{id}> } signed X-Oomplo-Signature: sha256=<HMAC of the body> when the job ends; three tries, no redirects"
                  },
                  "output": {
                    "type": "string",
                    "description": "A path in the client's store (OOMPLO_S3_ENDPOINT, http:// or https://; else the server's storage directory) the result is also saved to when the job ends, ending with .zip (zip or docx) or .pdf; the job fails when the store refuses it"
                  },
                  "seal": {
                    "type": "boolean",
                    "description": "The company seal over every PDF (422 when the server has only the test seal)"
                  },
                  "pdfa": {
                    "type": "string",
                    "enum": [
                      "2b",
                      "2u",
                      "2a",
                      "3b",
                      "3u",
                      "3a"
                    ],
                    "description": "Every PDF in archival PDF/A (as in POST /api/render); not with docx"
                  },
                  "pdfua": {
                    "type": "boolean",
                    "description": "Every PDF accessible (PDF/UA-1); not with docx"
                  },
                  "attachData": {
                    "type": "boolean",
                    "description": "Each PDF of a ZIP carries its row's data, one PDF all rows as a JSON array (data.json; PDF/A-3 or no PDF/A)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The job started",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "state",
                    "total"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "running"
                      ]
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request is not a job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such template or version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The template has no published version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The series cannot be read, or rows cannot be filled (`rows`, at most 100 listed); no job was started",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "row",
                          "error"
                        ],
                        "properties": {
                          "row": {
                            "type": "integer"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/jobs/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Series jobs"
        ],
        "operationId": "seriesJob",
        "summary": "The state of a series job",
        "description": "Only the user or API key that started the job, and administrators, see it (404 for others).",
        "responses": {
          "200": {
            "description": "The job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "template",
                    "version",
                    "created",
                    "expires",
                    "state",
                    "total",
                    "done",
                    "format"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "template": {
                      "type": "string"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "created": {
                      "type": "integer",
                      "description": "Unix time"
                    },
                    "expires": {
                      "type": "integer",
                      "description": "Unix time when the job and its result are deleted"
                    },
                    "finished": {
                      "type": "integer",
                      "nullable": true
                    },
                    "output": {
                      "type": "string",
                      "nullable": true,
                      "description": "The path in the client's store the result was saved to"
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "running",
                        "done",
                        "failed"
                      ]
                    },
                    "total": {
                      "type": "integer"
                    },
                    "done": {
                      "type": "integer",
                      "description": "Copies rendered so far"
                    },
                    "format": {
                      "type": "string",
                      "enum": [
                        "pdf",
                        "zip"
                      ]
                    },
                    "result": {
                      "type": "string",
                      "nullable": true,
                      "description": "The address of the result when done"
                    },
                    "error": {
                      "type": "string",
                      "nullable": true,
                      "description": "Why the job failed (with the row)"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such job, it expired, or another user started it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/jobs/{id}/result": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Series jobs"
        ],
        "operationId": "seriesJobResult",
        "summary": "The result of a finished series job",
        "description": "Only the user or API key that started the job, and administrators, get it (404 for others).",
        "responses": {
          "200": {
            "description": "One PDF or a ZIP of PDFs",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "No such job",
            "or it expired": null,
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The job is running or failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/render": {
      "post": {
        "tags": [
          "Templates in the request"
        ],
        "operationId": "renderPdf",
        "summary": "PDF from a template and data, without a browser",
        "description": "Runs the engine crates (DOCX import, fill, layout, PDF) on the server: the same code as oomplo-cli and the WASM build, so the PDF has the same bytes as `oomplo pdf` for the same template. The template is either a DOCX (`docx`, base64; fields and repeated rows are Word content controls, saved data in the Oomplo custom XML part) or a DocumentSource in format 3 (`document`). `data` replaces the template's saved data (JSON object or a source registry). The PDF has no attachments: it contains neither the template nor the source data. Renders run one per CPU core; further requests wait in a queue of 256 and get 503 only when it is full. Warnings of the import and the layout (what the PDF shows simplified, e.g. a font with other widths than Word's or an element drawn without its effect) come back in the `X-Oomplo-Warnings` headers; information without effect on the result (a font replaced by one with the same widths) is not a warning. With `strict: true` a template with warnings is refused with 422 and the list. A picture field takes a PNG or JPEG in `data:` or base64, or an address (`https://…`, `http://…`) the server fetches from the hosts listed in `OOMPLO_IMAGE_HOSTS` (public addresses only unless `OOMPLO_IMAGE_PRIVATE=1`; at most 5 MB a picture, 50 MB and 200 addresses a request, 15 s each and 30 s together, no redirects); a host not listed is refused with 422. Limits: 16 MiB transferred, 160 MiB after gzip, DOCX 20 MB, data 10 MB, the document limits (source, nodes, characters; no limit on table rows), 1000 pages and `OOMPLO_RENDER_SECONDS` (60 s) of layout (422 past it). Requests wait for a render slot in a queue of 256 requests and 512 MiB of bodies (503 past it).",
        "parameters": [
          {
            "in": "header",
            "name": "Content-Encoding",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "identity",
                "gzip"
              ],
              "default": "identity"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The PDF",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string",
                  "example": "attachment; filename=\"Umowa-7-2026.pdf\""
                }
              },
              "X-Oomplo-Warnings": {
                "description": "Number of warnings (0 when the PDF has no simplifications)",
                "schema": {
                  "type": "integer",
                  "example": 1
                }
              },
              "X-Oomplo-Warnings-List": {
                "description": "The warnings as a JSON array of Polish messages, UTF-8 percent-encoded (decodeURIComponent, then JSON.parse)",
                "schema": {
                  "type": "string",
                  "example": "%5B%22Obrazy%20p%C5%82ywaj%C4%85ce%20wstawiono%20w%20linii%20tekstu%20%28op%C5%82ywanie%20to%20Z2%29.%22%5D"
                }
              },
              "X-Oomplo-Fonts-Substituted": {
                "description": "Fonts of the document drawn with a bundled substitute, as a JSON array of { name, family, status, alternate? } (status sameWidths: line and page breaks as in Word; sameLetterWidths: letters and digits have Word's widths, a few other characters differ; otherWidths: text may break differently; alternate: the font table's w:altName drawn in place of a missing font, as Word draws it), UTF-8 percent-encoded like X-Oomplo-Warnings-List. Fonts embedded in the DOCX and bundled fonts are not listed.",
                "schema": {
                  "type": "string",
                  "example": "%5B%7B%22name%22%3A%22Tahoma%22%2C%22family%22%3A%22Wine%20Tahoma%22%2C%22status%22%3A%22sameLetterWidths%22%7D%5D"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request (not exactly one of docx and document, invalid base64) or invalid document (Polish message with the place of the error)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "More than 16 MiB transferred, 160 MiB after gzip decompression or a DOCX above 20 MB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported Content-Encoding",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The DOCX cannot be read, the template cannot be filled or laid out (missing data, missing glyph, too many pages), or `strict` is set and the template has warnings (then `warnings` lists them)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The render queue is full; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/check": {
      "post": {
        "tags": [
          "Templates in the request"
        ],
        "operationId": "checkTemplate",
        "summary": "Qualification report of a template",
        "description": "The same request as /api/render (import, data, fill and layout on the same queue and limits), but instead of the PDF a JSON report: the fonts of the document and how they are drawn, Word elements kept in the document but not shown, the warnings (what the PDF shows simplified), the notes (without effect on the result) and the page count. `qualified` is true when there are no warnings, i.e. when /api/render with `strict: true` accepts the template.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateReport"
                }
              }
            }
          },
          "400": {
            "description": "As for /api/render",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "As for /api/render",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The DOCX cannot be read, or the template cannot be filled or laid out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The render queue is full; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/infer": {
      "post": {
        "tags": [
          "Templates in the request"
        ],
        "operationId": "inferTemplate",
        "summary": "A template from filled documents",
        "description": "2 to 20 filled DOCX documents of one kind (the same contract for different clients) are compared: text that differs becomes data fields (json.dane1.<name>, named after the text before the value), a table whose rows differ in number a repeated row (header and total rows stay fixed, their values become fields), and paragraphs or tables only some documents have conditional blocks (a true/false value per document). The first document gives the look. The answer has the template as DOCX, the data set of each document and a report that says whether the template filled with each data set gives that document's text again. Same as `oomplo infer`. API keys: scope render.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "documents"
                ],
                "properties": {
                  "documents": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "name",
                        "docx"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "The document's name (its data set's name), at most 100 characters"
                        },
                        "docx": {
                          "type": "string",
                          "format": "byte",
                          "description": "The filled document in base64"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The template, the data sets and the report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "template",
                    "title",
                    "datasets",
                    "report"
                  ],
                  "properties": {
                    "template": {
                      "type": "string",
                      "format": "byte",
                      "description": "The template as DOCX in base64 (fields as Word content controls",
                      "the first document's data as its data)": null
                    },
                    "title": {
                      "type": "string"
                    },
                    "datasets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "data": {
                            "type": "object",
                            "description": "The document's data for the template (fields, arrays of repeated rows, true/false of conditional blocks)"
                          }
                        }
                      }
                    },
                    "report": {
                      "type": "object",
                      "properties": {
                        "documents": {
                          "type": "integer"
                        },
                        "fields": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "path": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "values": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        },
                        "tables": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "path": {
                                "type": "string"
                              },
                              "columns": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "rows": {
                                "type": "array",
                                "items": {
                                  "type": "integer"
                                }
                              }
                            }
                          }
                        },
                        "conditions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "path": {
                                "type": "string"
                              },
                              "text": {
                                "type": "string"
                              },
                              "present": {
                                "type": "array",
                                "items": {
                                  "type": "boolean"
                                }
                              }
                            }
                          }
                        },
                        "reproduced": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "same": {
                                "type": "boolean"
                              },
                              "difference": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not JSON, not base64, or more than 20 documents",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "A document cannot be read, or fewer than two documents",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/history": {
      "get": {
        "tags": [
          "History"
        ],
        "operationId": "renderHistory",
        "summary": "The history of generating",
        "description": "One entry per call of POST /api/templates/{id}/render and per series job (also refused ones), newest first: time, user, template, version, pages, rows, duration, number of warnings and the error. The data and the PDFs are never stored; quoted parts of error messages are cut out (`„…”`). Entries are deleted after `OOMPLO_HISTORY_DAYS` (90 by default).",
        "parameters": [
          {
            "name": "template",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "user",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "render",
                "job"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "ok",
                "error"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Unix time from (inclusive)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Unix time to (exclusive)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The entries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "days",
                    "entries"
                  ],
                  "properties": {
                    "days": {
                      "type": "integer",
                      "description": "How long entries are kept"
                    },
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "time",
                          "user",
                          "kind",
                          "template",
                          "pages",
                          "rows",
                          "durationMs",
                          "warnings"
                        ],
                        "properties": {
                          "time": {
                            "type": "integer",
                            "description": "Unix time"
                          },
                          "user": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "render",
                              "job"
                            ]
                          },
                          "template": {
                            "type": "string"
                          },
                          "version": {
                            "type": "integer",
                            "nullable": true
                          },
                          "pages": {
                            "type": "integer"
                          },
                          "rows": {
                            "type": "integer"
                          },
                          "durationMs": {
                            "type": "integer"
                          },
                          "warnings": {
                            "type": "integer"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "An unknown filter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/history.csv": {
      "get": {
        "tags": [
          "History"
        ],
        "operationId": "renderHistoryCsv",
        "summary": "The history of generating as CSV",
        "description": "The entries of GET /api/history with the same filters, `;`-separated, UTF-8 with a byte order mark, times in UTC.",
        "responses": {
          "200": {
            "description": "The CSV file",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/embed": {
      "post": {
        "tags": [
          "Embedded editor"
        ],
        "operationId": "embedToken",
        "summary": "A token for the template editor embedded in a page of the client (an iframe of /?embed=<token>)",
        "description": "For an API key (scope render) or a session. The origin must be listed in OOMPLO_EMBED_ORIGINS (only those pages may frame Oomplo). The token is the editor of its one template until it expires: that template (not removing it), the flows that hold it, fonts and the library overview limited to that template; every other path (storage, runs, workflows, other templates, data files, projects, rendering, accounts, keys) is 403. A token without a template is bound to the new template it saves first. Revoking the API key (or disabling the account) that asked for it ends the token. The page and talks with postMessage only to the window of that origin.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "origin"
                ],
                "additionalProperties": false,
                "properties": {
                  "origin": {
                    "type": "string",
                    "description": "The host page's origin, e.g. https://crm.firma.pl"
                  },
                  "template": {
                    "type": "string",
                    "description": "The template to open: its id or API name; none: a new template"
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "The title of a new template"
                  },
                  "ttl": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 28800,
                    "default": 3600,
                    "description": "Seconds the token lasts"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The token and the address of the editor's page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "token",
                    "url",
                    "origin",
                    "expires"
                  ],
                  "properties": {
                    "token": {
                      "type": "string",
                      "description": "oomplo_embed_…"
                    },
                    "url": {
                      "type": "string",
                      "description": "The iframe's src: <OOMPLO_PUBLIC_URL>/?embed=<token>"
                    },
                    "template": {
                      "type": "string"
                    },
                    "origin": {
                      "type": "string"
                    },
                    "expires": {
                      "type": "integer",
                      "description": "Unix time"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Embedding is off or the origin is not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "tags": [
          "Server"
        ],
        "summary": "Whether the server can serve templates",
        "description": "For monitoring and the container's health check. 200 when the library (its database and files) is open, 503 otherwise.",
        "responses": {
          "200": {
            "description": "The server is ready",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "503": {
            "description": "The library could not be opened (the reason is in the server's log)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key: `Authorization: Bearer oomplo_…`"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "In strict mode, the warnings that refused the template"
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "version",
          "library",
          "storage",
          "flow"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "unavailable"
            ]
          },
          "version": {
            "type": "string",
            "description": "Version of the server"
          },
          "library": {
            "type": "boolean",
            "description": "The library of templates is open"
          },
          "storage": {
            "type": "string",
            "description": "Where the files are: a directory or s3://bucket"
          },
          "flow": {
            "type": "boolean",
            "description": "DocumentFlow",
            "runs and signing are on (OOMPLO_FLOW=on)": null
          }
        }
      },
      "RenderRequest": {
        "description": "Exactly one template, `docx` (with an optional `title`) or `document`.",
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "docx"
            ],
            "properties": {
              "docx": {
                "type": "string",
                "format": "byte",
                "description": "The DOCX template in base64 (at most 20 MB decoded)"
              },
              "title": {
                "type": "string",
                "description": "Document title (PDF metadata and file name); default \"dokument\""
              },
              "data": {
                "description": "Template data replacing the data saved in the DOCX: a source registry (`$oomploSources`) or a plain JSON object, which is the main source `json.dane1` (fields `json.dane1.client.name` and `client.name` both read the plain object's `client.name`)"
              },
              "strict": {
                "type": "boolean",
                "default": false,
                "description": "Refuse a template whose PDF would have simplifications (422 with the warnings)"
              },
              "missing": {
                "type": "string",
                "enum": [
                  "error",
                  "empty"
                ],
                "default": "error",
                "description": "A value the template reads that the data does not have: error (422 naming every missing value, each path once with the first item without it) or empty (an empty text, an unchecked box, no rows of a missing array). A field's default text is used either way"
              },
              "format": {
                "type": "string",
                "enum": [
                  "pdf",
                  "docx"
                ],
                "default": "pdf",
                "description": "Docx returns the filled Word document (application/vnd.openxmlformats-officedocument.wordprocessingml.document) instead of the PDF"
              },
              "fields": {
                "type": "string",
                "enum": [
                  "text",
                  "keep"
                ],
                "default": "text",
                "description": "With docx: keep leaves the data fields as Word content controls showing their values (paths of array items get the item's index, e.g. items[1].price) and the data in the template part, so the file is still a template; text makes them plain text"
              },
              "response": {
                "type": "string",
                "enum": [
                  "file",
                  "json"
                ],
                "default": "file",
                "description": "Json answers { file (base64), contentType, fileName, pages, warnings, fontsSubstituted } instead of the file (low-code tools); the headers stay"
              },
              "pdfa": {
                "type": "string",
                "enum": [
                  "2b",
                  "2u",
                  "2a",
                  "3b",
                  "3u",
                  "3a"
                ],
                "description": "Archival PDF/A (ISO 19005): part 2 or 3, level b (appearance), u (also Unicode text) or a (also the structure); the PDF is refused (422 naming the rule) when it cannot meet it, e.g. a font that forbids embedding or a CMYK picture. Pictures are not smoothed when scaled (PDF/A forbids it)"
              },
              "pdfua": {
                "type": "boolean",
                "default": false,
                "description": "Accessible PDF/UA-1 (ISO 14289-1): the title from the document's properties, the language, an outline, headings, lists, tables (header rows as TH), notes, pictures with their Word description as figures, links; headers, footers and repeated header rows as artifacts; without the empty signature fields (a seal still signs)"
              },
              "attachData": {
                "type": "boolean",
                "default": false,
                "description": "The data the document was filled with attached as data.json (with dataXml the XML file as data.xml) (an associated file, relation Data); with PDF/A only in part 3 (400 otherwise)"
              },
              "dataXml": {
                "type": "string",
                "format": "byte",
                "description": "The data as an XML file in base64 instead of data (an ERP export, a KSeF invoice FA(2)/FA(3)), read as JSON like oomplo pdf --data file.xml; a KSeF invoice also gets $ksef (verification code KOD I from the file's exact bytes: url, urlTest, urlDemo, hash, nip, date, label OFFLINE). Not together with data (400)"
              },
              "markup": {
                "type": "boolean",
                "default": false,
                "description": "The PDF with markup: comments and tracked changes in balloons beside the scaled page, as Word exports a document shown with all markup"
              }
            },
            "example": {
              "docx": "UEsDBBQAAAAIA…",
              "title": "Umowa 7/2026",
              "data": {
                "client": {
                  "name": "Anna Kowalska"
                }
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "document"
            ],
            "properties": {
              "document": {
                "type": "object",
                "description": "DocumentSource in format 3"
              },
              "data": {
                "description": "Template data replacing the document's own (a plain JSON object is the source `json.dane1`, as above)"
              },
              "strict": {
                "type": "boolean",
                "default": false,
                "description": "Refuse a template whose PDF would have simplifications (422 with the warnings)"
              },
              "missing": {
                "type": "string",
                "enum": [
                  "error",
                  "empty"
                ],
                "default": "error",
                "description": "A value the template reads that the data does not have: error (422 naming every missing value, each path once with the first item without it) or empty (an empty text, an unchecked box, no rows of a missing array). A field's default text is used either way"
              },
              "format": {
                "type": "string",
                "enum": [
                  "pdf",
                  "docx"
                ],
                "default": "pdf",
                "description": "Docx returns the filled Word document (application/vnd.openxmlformats-officedocument.wordprocessingml.document) instead of the PDF"
              },
              "fields": {
                "type": "string",
                "enum": [
                  "text",
                  "keep"
                ],
                "default": "text",
                "description": "With docx: keep leaves the data fields as Word content controls showing their values (paths of array items get the item's index, e.g. items[1].price) and the data in the template part, so the file is still a template; text makes them plain text"
              },
              "response": {
                "type": "string",
                "enum": [
                  "file",
                  "json"
                ],
                "default": "file",
                "description": "Json answers { file (base64), contentType, fileName, pages, warnings, fontsSubstituted } instead of the file (low-code tools); the headers stay"
              },
              "pdfa": {
                "type": "string",
                "enum": [
                  "2b",
                  "2u",
                  "2a",
                  "3b",
                  "3u",
                  "3a"
                ],
                "description": "Archival PDF/A (ISO 19005): part 2 or 3, level b (appearance), u (also Unicode text) or a (also the structure); the PDF is refused (422 naming the rule) when it cannot meet it, e.g. a font that forbids embedding or a CMYK picture. Pictures are not smoothed when scaled (PDF/A forbids it)"
              },
              "pdfua": {
                "type": "boolean",
                "default": false,
                "description": "Accessible PDF/UA-1 (ISO 14289-1): the title from the document's properties, the language, an outline, headings, lists, tables (header rows as TH), notes, pictures with their Word description as figures, links; headers, footers and repeated header rows as artifacts; without the empty signature fields (a seal still signs)"
              },
              "attachData": {
                "type": "boolean",
                "default": false,
                "description": "The data the document was filled with attached as data.json (with dataXml the XML file as data.xml) (an associated file, relation Data); with PDF/A only in part 3 (400 otherwise)"
              },
              "dataXml": {
                "type": "string",
                "format": "byte",
                "description": "The data as an XML file in base64 instead of data (an ERP export, a KSeF invoice FA(2)/FA(3)), read as JSON like oomplo pdf --data file.xml; a KSeF invoice also gets $ksef (verification code KOD I from the file's exact bytes: url, urlTest, urlDemo, hash, nip, date, label OFFLINE). Not together with data (400)"
              }
            }
          }
        ]
      },
      "SchemaField": {
        "type": "object",
        "required": [
          "path",
          "kind",
          "uses",
          "required"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "Full address of the value, e.g. json.dane1.klient.nazwa"
          },
          "kind": {
            "type": "string",
            "enum": [
              "text",
              "checkbox",
              "email",
              "date",
              "number",
              "image",
              "barcode"
            ],
            "description": "barcode: the value of a QR code or barcode (Word field DISPLAYBARCODE), the example has 12 digits, which QR, CODE128 and EAN13 all take; checkbox: a Word check box (true or false); email: the address of a signer; date and number: a field (or marker) with a date or number format (Word switch \\@ or \\#), the example has 2026-01-31 or 1234.5; image: a picture of the data, a PNG or JPEG as a data: address (data:image/png;base64,…) or plain base64, the example is a grey PNG of one pixel"
          },
          "uses": {
            "type": "integer",
            "description": "How many places of the template read it"
          },
          "required": {
            "type": "boolean",
            "description": "False when every use has a text without data (default)"
          }
        }
      },
      "TemplateReport": {
        "type": "object",
        "required": [
          "qualified",
          "pages",
          "fonts",
          "elements",
          "warnings",
          "notes"
        ],
        "properties": {
          "qualified": {
            "type": "boolean",
            "description": "No warnings (strict mode accepts the template)"
          },
          "pages": {
            "type": "integer"
          },
          "fonts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "family",
                "status"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Font name in the document"
                },
                "family": {
                  "type": "string",
                  "description": "Bundled family that draws it"
                },
                "alternate": {
                  "type": "string",
                  "description": "The font table's alternative (w:altName) drawn in place of a missing font, as Word draws it; only when used"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "embedded",
                    "organization",
                    "bundled",
                    "sameWidths",
                    "sameLetterWidths",
                    "otherWidths"
                  ],
                  "description": "embedded in the DOCX (drawn with its own file); bundled; replaced by a font with the same glyph widths (breaks as in Word); replaced by a font with Word's widths for letters and digits only (nearly always breaks as in Word; still a warning); replaced by a font with other widths (text may break differently)"
                }
              }
            }
          },
          "elements": {
            "type": "array",
            "description": "Word elements kept in the document but not shown as in Word (bookmarks and other elements Word does not draw are left out)",
            "items": {
              "type": "object",
              "required": [
                "name",
                "count"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "example": "w:footnoteReference"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
