{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pictify-io/json-schema/pictify-io-template-schema.json",
  "title": "Template",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pictify-io-templates-api-openapi.yml#/components/schemas/Template",
  "type": "object",
  "properties": {
    "uid": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "engine": {
      "type": "string",
      "enum": [
        "fabric",
        "html"
      ],
      "description": "Which renderer owns this template.\n- `fabric` — legacy canvas templates (fabricJSData)\n- `html` — Handlebars + HTML templates (html field, supports `{{var}}`, `{{#each}}`, `{{#if}}`, and the built-in helper library)\n"
    },
    "html": {
      "type": "string",
      "description": "Handlebars source for `engine=html` templates."
    },
    "fabricJSData": {
      "type": "object",
      "description": "FabricJS canvas JSON for `engine=fabric` templates.",
      "additionalProperties": true
    },
    "jsEnabled": {
      "type": "boolean",
      "description": "Only meaningful for `engine=html`. When true, scripts inside the template\nexecute during render (Chart.js, KaTeX, animated SVG). Off by default\nto prevent runaway loops; a 30s hard timeout still applies.\n",
      "default": false
    },
    "strictVariables": {
      "type": "boolean",
      "description": "Only meaningful for `engine=html`. When true, rendering fails with HTTP 422\nif a root-level variable referenced in the template was not supplied.\nLeave off if you rely on `{{#if optional}}` guards.\n",
      "default": false
    },
    "type": {
      "type": "string"
    },
    "category": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "width": {
      "type": "integer"
    },
    "height": {
      "type": "integer"
    },
    "thumbnail": {
      "type": "string",
      "format": "uri"
    },
    "outputFormat": {
      "type": "string",
      "enum": [
        "image",
        "pdf"
      ],
      "default": "image"
    },
    "pdfPreset": {
      "type": "string",
      "description": "Page preset used when `outputFormat=pdf`.",
      "enum": [
        "A4",
        "A4_LANDSCAPE",
        "LETTER",
        "LETTER_LANDSCAPE",
        "LEGAL",
        "A3",
        "TABLOID"
      ],
      "default": "A4"
    },
    "variableDefinitions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/VariableDefinition"
      }
    },
    "pages": {
      "type": "array",
      "description": "Multi-page canvas pages (fabric engine).",
      "items": {
        "type": "object",
        "properties": {
          "pageNumber": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "fabricJSData": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "layouts": {
      "type": "object",
      "description": "Named layout variants. Keys are short identifiers matching\n`^[a-z0-9-]{1,64}$` (e.g. `twitter-post`, `og-image`). Each value\noverrides `width`, `height`, and renderer-specific data for that\nvariant. Limit: 20 layouts per template.\n",
      "additionalProperties": {
        "type": "object"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "VariableDefinition": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Variable identifier. Must match the name used in `{{name}}` tokens."
        },
        "type": {
          "type": "string",
          "enum": [
            "text",
            "image",
            "color",
            "chart",
            "table",
            "array",
            "object"
          ],
          "default": "text"
        },
        "defaultValue": {
          "description": "Fallback value when the variable is not supplied at render time.\nTyped according to `type` — string for text/image/color/url, number for number,\nboolean for boolean, ISO date string for date, JSON array/object for array/object.\n"
        },
        "description": {
          "type": "string"
        },
        "allowRawHtml": {
          "type": "boolean",
          "description": "Only meaningful for `type=text` on `engine=html` templates. When true the value\nis NOT HTML-escaped at render time. Use with care — treat as trusted input.\n",
          "default": false
        },
        "validation": {
          "type": "object",
          "properties": {
            "required": {
              "type": "boolean"
            },
            "minLength": {
              "type": "integer"
            },
            "maxLength": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
}