{
  "openapi": "3.1.0",
  "info": {
    "title": "Templo API",
    "version": "1",
    "description": "Render PDFs from your published Templo templates and your data.\n\nSign in with an API key of your workspace: `Authorization: Bearer templo_…`. Every error is JSON `{ \"error\": { \"code\", \"message\" } }` with a stable code; `x-templo-errors` lists each code with what to do about it, `x-templo-warnings` each render warning.\n\n## Limits\n\n- **Requests:** 60 per minute and workspace, all its API keys together; every request counts. Over it: 429 `E_RATE_LIMITED` with `Retry-After`. Every answer except a 401 carries `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` and `RateLimit-Policy`.\n- **Renders at once:** 2 of a workspace's renders run at the same time and 8 more wait their turn. More than that: 429 `E_RATE_LIMITED` with `Retry-After: 2`. When the whole server is busy: 503 `E_RENDER_BUSY`.\n- **Time:** a render may take 10 seconds; then it is stopped (503 `E_RENDER_TIMEOUT`).\n- **Size:** `data` at most 1 MB as JSON (413 `E_RENDER_TOO_LARGE`); a body over 2.1 MB is refused before it is read (413 `E_PAYLOAD_TOO_LARGE`). The document at most 50 MB (422 `E_RENDER_TOO_LARGE`)."
  },
  "externalDocs": {
    "description": "API reference and the template format",
    "url": "https://docs.templo.at/reference/render-api"
  },
  "servers": [
    {
      "url": "https://app.templo.at/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/workspace": {
      "get": {
        "operationId": "getWorkspace",
        "summary": "Check an API key",
        "description": "The workspace the API key belongs to. Use it to check that a key works before you render; it counts against the request limit like every request.",
        "responses": {
          "200": {
            "description": "The workspace of the API key.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceResponse"
                },
                "example": {
                  "data": {
                    "id": "ws_01JDQ8XK2M4N6P8R0S2T4V6W8Y",
                    "name": "Bergwerk Design"
                  }
                }
              }
            }
          },
          "401": {
            "description": "`E_UNAUTHORIZED`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_UNAUTHORIZED": {
                    "$ref": "#/components/examples/E_UNAUTHORIZED"
                  }
                }
              }
            }
          },
          "429": {
            "description": "`E_RATE_LIMITED`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_RATE_LIMITED": {
                    "$ref": "#/components/examples/E_RATE_LIMITED"
                  }
                }
              }
            }
          },
          "500": {
            "description": "`E_INTERNAL_ERROR`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_INTERNAL_ERROR": {
                    "$ref": "#/components/examples/E_INTERNAL_ERROR"
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl 'https://app.templo.at/api/v1/workspace' \\\n  -H \"Authorization: Bearer $TEMPLO_API_KEY\""
          }
        ]
      }
    },
    "/render": {
      "post": {
        "operationId": "renderDocument",
        "summary": "Render a document",
        "description": "Renders a published version of a template with your data and answers the document: by default the template's latest published version as a PDF. The draft in the editor is never rendered, so your documents only change when the template is published.\n\nThe answer is the file itself (`application/pdf`), with the rendered version, the language and the number of warnings in headers. Send `Accept: application/json` to get JSON instead, with the file in base64 and every warning.\n\nNeither your data nor the document is stored or logged.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderRequest"
              },
              "example": {
                "template": "tpl_01JDQ8Z3V6K9W2X4Y5A7B8C9D0",
                "version": 3,
                "data": {
                  "company": {
                    "name": "Bergwerk Design OG",
                    "street": "Museumstraße 4",
                    "city": "6020 Innsbruck",
                    "country": "Austria",
                    "iban": "AT61 1904 3002 3457 3201"
                  },
                  "customer": {
                    "name": "Muster GmbH",
                    "vat_id": "ATU12345678",
                    "address": {
                      "street": "Kärntner Straße 21",
                      "city": "1010 Wien",
                      "country": "Austria"
                    }
                  },
                  "invoice": {
                    "number": "INV-2026-0142",
                    "date": "26 Nov 2026",
                    "due": "10 Dec 2026"
                  },
                  "items": [
                    {
                      "description": "Template design workshop",
                      "qty": 1,
                      "price": "€1,200.00",
                      "amount": "€1,200.00"
                    },
                    {
                      "description": "PDF generation, 12,000 documents",
                      "qty": 12,
                      "price": "€45.00",
                      "amount": "€540.00"
                    },
                    {
                      "description": "Priority support, monthly",
                      "qty": 1,
                      "price": "€150.00",
                      "amount": "€150.00"
                    }
                  ],
                  "totals": {
                    "subtotal": "€1,890.00",
                    "vat": "€378.00",
                    "total": "€2,268.00"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The document. With `Accept: application/json`, JSON with the document in base64 and its warnings.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "Content-Language": {
                "$ref": "#/components/headers/Content-Language"
              },
              "Templo-Template-Version": {
                "$ref": "#/components/headers/Templo-Template-Version"
              },
              "Templo-Warnings": {
                "$ref": "#/components/headers/Templo-Warnings"
              },
              "Content-Disposition": {
                "$ref": "#/components/headers/Content-Disposition"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/pdf"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenderResponse"
                },
                "example": {
                  "data": {
                    "template": "tpl_01JDQ8Z3V6K9W2X4Y5A7B8C9D0",
                    "version": 3,
                    "format": "pdf",
                    "language": "en",
                    "pages": 1,
                    "contentType": "application/pdf",
                    "content": "JVBERi0xLjcKJcfsj6IK",
                    "warnings": [
                      {
                        "code": "missing-data",
                        "elementId": "order-reference",
                        "pageId": "page-1",
                        "path": "customer.order_reference",
                        "message": "Element \"order-reference\": no data at \"customer.order_reference\", left empty"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "`E_BAD_REQUEST`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_BAD_REQUEST": {
                    "$ref": "#/components/examples/E_BAD_REQUEST"
                  }
                }
              }
            }
          },
          "401": {
            "description": "`E_UNAUTHORIZED`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_UNAUTHORIZED": {
                    "$ref": "#/components/examples/E_UNAUTHORIZED"
                  }
                }
              }
            }
          },
          "404": {
            "description": "`E_TEMPLATE_NOT_FOUND`, `E_VERSION_NOT_FOUND`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_TEMPLATE_NOT_FOUND": {
                    "$ref": "#/components/examples/E_TEMPLATE_NOT_FOUND"
                  },
                  "E_VERSION_NOT_FOUND": {
                    "$ref": "#/components/examples/E_VERSION_NOT_FOUND"
                  }
                }
              }
            }
          },
          "409": {
            "description": "`E_TEMPLATE_NOT_PUBLISHED`, `E_TEMPLATE_DOCUMENT_UNREADABLE`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_TEMPLATE_NOT_PUBLISHED": {
                    "$ref": "#/components/examples/E_TEMPLATE_NOT_PUBLISHED"
                  },
                  "E_TEMPLATE_DOCUMENT_UNREADABLE": {
                    "$ref": "#/components/examples/E_TEMPLATE_DOCUMENT_UNREADABLE"
                  }
                }
              }
            }
          },
          "413": {
            "description": "`E_PAYLOAD_TOO_LARGE`, `E_RENDER_TOO_LARGE`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_PAYLOAD_TOO_LARGE": {
                    "$ref": "#/components/examples/E_PAYLOAD_TOO_LARGE"
                  },
                  "E_RENDER_TOO_LARGE": {
                    "$ref": "#/components/examples/E_RENDER_TOO_LARGE"
                  }
                }
              }
            }
          },
          "415": {
            "description": "`E_UNSUPPORTED_MEDIA_TYPE`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_UNSUPPORTED_MEDIA_TYPE": {
                    "$ref": "#/components/examples/E_UNSUPPORTED_MEDIA_TYPE"
                  }
                }
              }
            }
          },
          "422": {
            "description": "`E_VALIDATION_ERROR`, `E_RENDER_INVALID_TEMPLATE`, `E_RENDER_INVALID_INPUT`, `E_RENDER_UNSUPPORTED`, `E_RENDER_TOO_LARGE`, `E_RENDER_FAILED`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_VALIDATION_ERROR": {
                    "$ref": "#/components/examples/E_VALIDATION_ERROR"
                  },
                  "E_RENDER_INVALID_TEMPLATE": {
                    "$ref": "#/components/examples/E_RENDER_INVALID_TEMPLATE"
                  },
                  "E_RENDER_INVALID_INPUT": {
                    "$ref": "#/components/examples/E_RENDER_INVALID_INPUT"
                  },
                  "E_RENDER_UNSUPPORTED": {
                    "$ref": "#/components/examples/E_RENDER_UNSUPPORTED"
                  },
                  "E_RENDER_TOO_LARGE": {
                    "$ref": "#/components/examples/E_RENDER_TOO_LARGE"
                  },
                  "E_RENDER_FAILED": {
                    "$ref": "#/components/examples/E_RENDER_FAILED"
                  }
                }
              }
            }
          },
          "429": {
            "description": "`E_RATE_LIMITED`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_RATE_LIMITED": {
                    "$ref": "#/components/examples/E_RATE_LIMITED"
                  }
                }
              }
            }
          },
          "500": {
            "description": "`E_INTERNAL_ERROR`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_INTERNAL_ERROR": {
                    "$ref": "#/components/examples/E_INTERNAL_ERROR"
                  }
                }
              }
            }
          },
          "503": {
            "description": "`E_RENDER_BUSY`, `E_RENDER_TIMEOUT`",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "E_RENDER_BUSY": {
                    "$ref": "#/components/examples/E_RENDER_BUSY"
                  },
                  "E_RENDER_TIMEOUT": {
                    "$ref": "#/components/examples/E_RENDER_TIMEOUT"
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST 'https://app.templo.at/api/v1/render' \\\n  -H \"Authorization: Bearer $TEMPLO_API_KEY\" \\\n  -H 'Content-Type: application/json' \\\n  --data '{\n  \"template\": \"tpl_01JDQ8Z3V6K9W2X4Y5A7B8C9D0\",\n  \"version\": 3,\n  \"data\": {\n    \"company\": {\n      \"name\": \"Bergwerk Design OG\",\n      \"street\": \"Museumstraße 4\",\n      \"city\": \"6020 Innsbruck\",\n      \"country\": \"Austria\",\n      \"iban\": \"AT61 1904 3002 3457 3201\"\n    },\n    \"customer\": {\n      \"name\": \"Muster GmbH\",\n      \"vat_id\": \"ATU12345678\",\n      \"address\": {\n        \"street\": \"Kärntner Straße 21\",\n        \"city\": \"1010 Wien\",\n        \"country\": \"Austria\"\n      }\n    },\n    \"invoice\": {\n      \"number\": \"INV-2026-0142\",\n      \"date\": \"26 Nov 2026\",\n      \"due\": \"10 Dec 2026\"\n    },\n    \"items\": [\n      {\n        \"description\": \"Template design workshop\",\n        \"qty\": 1,\n        \"price\": \"€1,200.00\",\n        \"amount\": \"€1,200.00\"\n      },\n      {\n        \"description\": \"PDF generation, 12,000 documents\",\n        \"qty\": 12,\n        \"price\": \"€45.00\",\n        \"amount\": \"€540.00\"\n      },\n      {\n        \"description\": \"Priority support, monthly\",\n        \"qty\": 1,\n        \"price\": \"€150.00\",\n        \"amount\": \"€150.00\"\n      }\n    ],\n    \"totals\": {\n      \"subtotal\": \"€1,890.00\",\n      \"vat\": \"€378.00\",\n      \"total\": \"€2,268.00\"\n    }\n  }\n}' \\\n  -o document.pdf"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key of your workspace (`templo_…`), created on the API keys page by an owner or admin. It is shown once; keep it on your server, never in a browser or an app. Missing or invalid API key. Send it as \"Authorization: Bearer <key>\"."
      }
    },
    "headers": {
      "RateLimit-Limit": {
        "description": "Requests the workspace may send per window.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Remaining": {
        "description": "Requests left in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Reset": {
        "description": "Seconds until the window starts again.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Policy": {
        "description": "The limit and its window in seconds, e.g. `60;w=60`.",
        "schema": {
          "type": "string"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before trying again. Sent with `E_RATE_LIMITED` and `E_RENDER_BUSY`.",
        "schema": {
          "type": "integer"
        }
      },
      "Content-Language": {
        "description": "The language the document was rendered in.",
        "schema": {
          "type": "string"
        }
      },
      "Templo-Template-Version": {
        "description": "The published version that was rendered.",
        "schema": {
          "type": "integer"
        }
      },
      "Templo-Warnings": {
        "description": "The number of warnings (0 when nothing is missing). Ask for JSON to get the warnings themselves.",
        "schema": {
          "type": "integer"
        }
      },
      "Content-Disposition": {
        "description": "`attachment`, with a file name made from the template's name and the version.",
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "RenderRequest": {
        "description": "What to render, from which data.",
        "type": "object",
        "properties": {
          "template": {
            "type": "string",
            "maxLength": 64,
            "description": "The template's ID (`tpl_…`), shown in the editor's publish area. The API renders a published version of it, never the draft.",
            "examples": [
              "tpl_01JDQ8Z3V6K9W2X4Y5A7B8C9D0"
            ],
            "externalDocs": {
              "description": "How a template is built",
              "url": "https://docs.templo.at/reference/template-format"
            }
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647,
            "description": "The published version to render. Default: the latest published version. Pin it so your documents only change when you change the number.",
            "examples": [
              3
            ]
          },
          "data": {
            "type": "object",
            "description": "The data the template's placeholders are filled from: a JSON object, sent as it is (strings aren't trimmed). Required; send `{}` for a template without placeholders.",
            "examples": [
              {
                "customer": {
                  "name": "Anna Berger"
                },
                "total": "€ 1,250.00"
              }
            ]
          },
          "language": {
            "type": "string",
            "maxLength": 35,
            "pattern": "^\\s*[A-Za-z]{2,3}([-_]([A-Za-z]{2}|[0-9]{3}))?\\s*$",
            "description": "The language to render in, a language tag with an optional region (`de`, `de-AT`). A text without that language falls back to the language without its region, then another region of it, then the template's default language. Default: the template's default language.",
            "examples": [
              "de-AT"
            ]
          },
          "format": {
            "type": "string",
            "maxLength": 20,
            "description": "The output format. Supported: `pdf`. Default: `pdf`. Any other value is answered with `E_RENDER_UNSUPPORTED`.",
            "default": "pdf",
            "examples": [
              "pdf"
            ]
          }
        },
        "required": [
          "template",
          "data"
        ],
        "additionalProperties": false
      },
      "RenderResponse": {
        "type": "object",
        "description": "The JSON answer of a render (`Accept: application/json`).",
        "required": [
          "data"
        ],
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "template",
              "version",
              "format",
              "language",
              "pages",
              "contentType",
              "content",
              "warnings"
            ],
            "additionalProperties": false,
            "properties": {
              "template": {
                "type": "string",
                "description": "The template's ID."
              },
              "version": {
                "type": "integer",
                "description": "The published version that was rendered."
              },
              "format": {
                "type": "string",
                "enum": [
                  "pdf"
                ],
                "description": "The output format."
              },
              "language": {
                "type": "string",
                "description": "The language it was rendered in."
              },
              "pages": {
                "type": "integer",
                "minimum": 1,
                "description": "Number of pages."
              },
              "contentType": {
                "type": "string",
                "enum": [
                  "application/pdf"
                ],
                "description": "The media type of `content`."
              },
              "content": {
                "type": "string",
                "contentEncoding": "base64",
                "description": "The document, base64-encoded."
              },
              "warnings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Warning"
                },
                "description": "Every warning, in document order. Empty when nothing is missing."
              }
            }
          }
        }
      },
      "Warning": {
        "type": "object",
        "description": "Something in the document that may not look as intended: the document is still rendered. The same warnings show in the editor.",
        "required": [
          "code",
          "elementId",
          "pageId",
          "message"
        ],
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "missing-data",
              "unsupported-value",
              "overflow",
              "unknown-font"
            ],
            "description": "What happened; see `x-templo-warnings`."
          },
          "elementId": {
            "type": "string",
            "description": "The element of the template it concerns."
          },
          "pageId": {
            "type": "string",
            "description": "The page the element is on."
          },
          "path": {
            "type": "string",
            "description": "The placeholder path (`missing-data`, `unsupported-value`)."
          },
          "valueType": {
            "type": "string",
            "enum": [
              "object",
              "array"
            ],
            "description": "What was found at the path instead of a value (`unsupported-value`)."
          },
          "fontFamily": {
            "type": "string",
            "description": "The unknown font (`unknown-font`)."
          },
          "atMinFontSize": {
            "type": "boolean",
            "description": "Shrink to fit is on and the text does not fit even at its smallest font size (`overflow`)."
          },
          "message": {
            "type": "string",
            "description": "The warning as an English sentence."
          }
        }
      },
      "WorkspaceResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The workspace's ID (`ws_…`)."
              },
              "name": {
                "type": "string",
                "description": "The workspace's name."
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Every error answer.",
        "required": [
          "error"
        ],
        "additionalProperties": false,
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "E_BAD_REQUEST",
                  "E_UNAUTHORIZED",
                  "E_FORBIDDEN",
                  "E_NOT_FOUND",
                  "E_METHOD_NOT_ALLOWED",
                  "E_PAYLOAD_TOO_LARGE",
                  "E_UNSUPPORTED_MEDIA_TYPE",
                  "E_VALIDATION_ERROR",
                  "E_TOO_MANY_REQUESTS",
                  "E_RATE_LIMITED",
                  "E_REQUEST_FAILED",
                  "E_INTERNAL_ERROR",
                  "E_TEMPLATE_NOT_FOUND",
                  "E_TEMPLATE_NOT_PUBLISHED",
                  "E_VERSION_NOT_FOUND",
                  "E_TEMPLATE_DOCUMENT_UNREADABLE",
                  "E_RENDER_INVALID_TEMPLATE",
                  "E_RENDER_INVALID_INPUT",
                  "E_RENDER_UNSUPPORTED",
                  "E_RENDER_TOO_LARGE",
                  "E_RENDER_BUSY",
                  "E_RENDER_TIMEOUT",
                  "E_RENDER_FAILED"
                ],
                "description": "Stable: react to the code, not the message. See `x-templo-errors`."
              },
              "message": {
                "type": "string",
                "description": "What went wrong, in English. It never contains your data."
              },
              "fields": {
                "type": "array",
                "description": "With `E_VALIDATION_ERROR`: each failing field of the body.",
                "items": {
                  "type": "object",
                  "required": [
                    "field",
                    "message"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "field": {
                      "type": "string",
                      "description": "The field (`data`, `version`); empty for the body itself."
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "examples": {
      "E_BAD_REQUEST": {
        "summary": "Send the body as valid JSON.",
        "value": {
          "error": {
            "code": "E_BAD_REQUEST",
            "message": "The request could not be read."
          }
        }
      },
      "E_UNAUTHORIZED": {
        "summary": "Send an API key of the workspace as `Authorization: Bearer <key>`; a revoked key needs a new one from the API keys page.",
        "value": {
          "error": {
            "code": "E_UNAUTHORIZED",
            "message": "Missing or invalid API key. Send it as \"Authorization: Bearer <key>\"."
          }
        }
      },
      "E_FORBIDDEN": {
        "summary": "Check that this request is one the API offers; this reference lists them.",
        "value": {
          "error": {
            "code": "E_FORBIDDEN",
            "message": "Not allowed."
          }
        }
      },
      "E_NOT_FOUND": {
        "summary": "Check the method and path against this reference; every path starts with `/api/v1/`.",
        "value": {
          "error": {
            "code": "E_NOT_FOUND",
            "message": "Not found."
          }
        }
      },
      "E_METHOD_NOT_ALLOWED": {
        "summary": "Use the method this reference names for the path.",
        "value": {
          "error": {
            "code": "E_METHOD_NOT_ALLOWED",
            "message": "Method not allowed."
          }
        }
      },
      "E_PAYLOAD_TOO_LARGE": {
        "summary": "Send less data: see the limits in this reference.",
        "value": {
          "error": {
            "code": "E_PAYLOAD_TOO_LARGE",
            "message": "The request body is too large."
          }
        }
      },
      "E_UNSUPPORTED_MEDIA_TYPE": {
        "summary": "Send the body as JSON with `Content-Type: application/json`.",
        "value": {
          "error": {
            "code": "E_UNSUPPORTED_MEDIA_TYPE",
            "message": "Unsupported content type."
          }
        }
      },
      "E_VALIDATION_ERROR": {
        "summary": "Fix the fields listed in `error.fields`, then send the request again.",
        "value": {
          "error": {
            "code": "E_VALIDATION_ERROR",
            "message": "The request is invalid."
          }
        }
      },
      "E_TOO_MANY_REQUESTS": {
        "summary": "Wait a moment, then try again.",
        "value": {
          "error": {
            "code": "E_TOO_MANY_REQUESTS",
            "message": "Too many requests."
          }
        }
      },
      "E_RATE_LIMITED": {
        "summary": "Wait for the seconds in `Retry-After`, then retry; send fewer requests at once.",
        "value": {
          "error": {
            "code": "E_RATE_LIMITED",
            "message": "Too many requests for this workspace. Wait for the seconds in Retry-After, then try again."
          }
        }
      },
      "E_REQUEST_FAILED": {
        "summary": "Check the request against this reference.",
        "value": {
          "error": {
            "code": "E_REQUEST_FAILED",
            "message": "The request failed."
          }
        }
      },
      "E_INTERNAL_ERROR": {
        "summary": "Try again later; if it keeps failing, report it with the time of the request.",
        "value": {
          "error": {
            "code": "E_INTERNAL_ERROR",
            "message": "Something went wrong on our side."
          }
        }
      },
      "E_TEMPLATE_NOT_FOUND": {
        "summary": "Check the template ID, and that the API key belongs to the template's workspace.",
        "value": {
          "error": {
            "code": "E_TEMPLATE_NOT_FOUND",
            "message": "No template with this ID in the workspace of this API key."
          }
        }
      },
      "E_TEMPLATE_NOT_PUBLISHED": {
        "summary": "Publish the template in the editor, then send the request again.",
        "value": {
          "error": {
            "code": "E_TEMPLATE_NOT_PUBLISHED",
            "message": "The template has no published version yet. Publish it in the Templo editor: the API renders published versions only, never the draft."
          }
        }
      },
      "E_VERSION_NOT_FOUND": {
        "summary": "Pin a version that is published, or leave out `version` to get the latest.",
        "value": {
          "error": {
            "code": "E_VERSION_NOT_FOUND",
            "message": "The template has no published version with this number."
          }
        }
      },
      "E_TEMPLATE_DOCUMENT_UNREADABLE": {
        "summary": "Try again later; if it keeps failing, publish the template again in the editor.",
        "value": {
          "error": {
            "code": "E_TEMPLATE_DOCUMENT_UNREADABLE",
            "message": "This version of the template can't be read by the server right now."
          }
        }
      },
      "E_RENDER_INVALID_TEMPLATE": {
        "summary": "Open the template in the editor, fix it and publish a new version.",
        "value": {
          "error": {
            "code": "E_RENDER_INVALID_TEMPLATE",
            "message": "The template version is invalid and can't be rendered."
          }
        }
      },
      "E_RENDER_INVALID_INPUT": {
        "summary": "Send `data` as a JSON object.",
        "value": {
          "error": {
            "code": "E_RENDER_INVALID_INPUT",
            "message": "The data can't be rendered."
          }
        }
      },
      "E_RENDER_UNSUPPORTED": {
        "summary": "Use a format the message names, or leave out `format` for a PDF.",
        "value": {
          "error": {
            "code": "E_RENDER_UNSUPPORTED",
            "message": "This format isn't supported for this template."
          }
        }
      },
      "E_RENDER_TOO_LARGE": {
        "summary": "Send less data, or make the document shorter.",
        "value": {
          "error": {
            "code": "E_RENDER_TOO_LARGE",
            "message": "The data is larger than the limit."
          }
        }
      },
      "E_RENDER_BUSY": {
        "summary": "Wait for the seconds in `Retry-After`, then try again.",
        "value": {
          "error": {
            "code": "E_RENDER_BUSY",
            "message": "Too many documents are being rendered right now. Try again in a moment."
          }
        }
      },
      "E_RENDER_TIMEOUT": {
        "summary": "Send less data or simplify the template, then try again.",
        "value": {
          "error": {
            "code": "E_RENDER_TIMEOUT",
            "message": "The render took too long and was stopped."
          }
        }
      },
      "E_RENDER_FAILED": {
        "summary": "Check the data against the template in the editor's preview; if it renders there, report it.",
        "value": {
          "error": {
            "code": "E_RENDER_FAILED",
            "message": "The template couldn't be rendered with this data."
          }
        }
      }
    }
  },
  "x-templo-errors": {
    "E_BAD_REQUEST": {
      "status": [
        400
      ],
      "message": "The request could not be read.",
      "hint": "Send the body as valid JSON."
    },
    "E_UNAUTHORIZED": {
      "status": [
        401
      ],
      "message": "Missing or invalid API key. Send it as \"Authorization: Bearer <key>\".",
      "hint": "Send an API key of the workspace as `Authorization: Bearer <key>`; a revoked key needs a new one from the API keys page."
    },
    "E_FORBIDDEN": {
      "status": [
        403
      ],
      "message": "Not allowed.",
      "hint": "Check that this request is one the API offers; this reference lists them."
    },
    "E_NOT_FOUND": {
      "status": [
        404
      ],
      "message": "Not found.",
      "hint": "Check the method and path against this reference; every path starts with `/api/v1/`."
    },
    "E_METHOD_NOT_ALLOWED": {
      "status": [
        405
      ],
      "message": "Method not allowed.",
      "hint": "Use the method this reference names for the path."
    },
    "E_PAYLOAD_TOO_LARGE": {
      "status": [
        413
      ],
      "message": "The request body is too large.",
      "hint": "Send less data: see the limits in this reference."
    },
    "E_UNSUPPORTED_MEDIA_TYPE": {
      "status": [
        415
      ],
      "message": "Unsupported content type.",
      "hint": "Send the body as JSON with `Content-Type: application/json`."
    },
    "E_VALIDATION_ERROR": {
      "status": [
        422
      ],
      "message": "The request is invalid.",
      "hint": "Fix the fields listed in `error.fields`, then send the request again."
    },
    "E_TOO_MANY_REQUESTS": {
      "status": [
        429
      ],
      "message": "Too many requests.",
      "hint": "Wait a moment, then try again."
    },
    "E_RATE_LIMITED": {
      "status": [
        429
      ],
      "message": "Too many requests for this workspace. Wait for the seconds in Retry-After, then try again.",
      "hint": "Wait for the seconds in `Retry-After`, then retry; send fewer requests at once."
    },
    "E_REQUEST_FAILED": {
      "status": [
        400,
        "4XX"
      ],
      "message": "The request failed.",
      "hint": "Check the request against this reference."
    },
    "E_INTERNAL_ERROR": {
      "status": [
        500
      ],
      "message": "Something went wrong on our side.",
      "hint": "Try again later; if it keeps failing, report it with the time of the request."
    },
    "E_TEMPLATE_NOT_FOUND": {
      "status": [
        404
      ],
      "message": "No template with this ID in the workspace of this API key.",
      "hint": "Check the template ID, and that the API key belongs to the template's workspace."
    },
    "E_TEMPLATE_NOT_PUBLISHED": {
      "status": [
        409
      ],
      "message": "The template has no published version yet. Publish it in the Templo editor: the API renders published versions only, never the draft.",
      "hint": "Publish the template in the editor, then send the request again."
    },
    "E_VERSION_NOT_FOUND": {
      "status": [
        404
      ],
      "message": "The template has no published version with this number.",
      "hint": "Pin a version that is published, or leave out `version` to get the latest."
    },
    "E_TEMPLATE_DOCUMENT_UNREADABLE": {
      "status": [
        409
      ],
      "message": "This version of the template can't be read by the server right now.",
      "hint": "Try again later; if it keeps failing, publish the template again in the editor."
    },
    "E_RENDER_INVALID_TEMPLATE": {
      "status": [
        422
      ],
      "message": "The template version is invalid and can't be rendered.",
      "hint": "Open the template in the editor, fix it and publish a new version."
    },
    "E_RENDER_INVALID_INPUT": {
      "status": [
        422
      ],
      "message": "The data can't be rendered.",
      "hint": "Send `data` as a JSON object."
    },
    "E_RENDER_UNSUPPORTED": {
      "status": [
        422
      ],
      "message": "This format isn't supported for this template.",
      "hint": "Use a format the message names, or leave out `format` for a PDF."
    },
    "E_RENDER_TOO_LARGE": {
      "status": [
        413,
        422
      ],
      "message": "The data is larger than the limit.",
      "hint": "Send less data, or make the document shorter."
    },
    "E_RENDER_BUSY": {
      "status": [
        503
      ],
      "message": "Too many documents are being rendered right now. Try again in a moment.",
      "hint": "Wait for the seconds in `Retry-After`, then try again."
    },
    "E_RENDER_TIMEOUT": {
      "status": [
        503
      ],
      "message": "The render took too long and was stopped.",
      "hint": "Send less data or simplify the template, then try again."
    },
    "E_RENDER_FAILED": {
      "status": [
        422
      ],
      "message": "The template couldn't be rendered with this data.",
      "hint": "Check the data against the template in the editor's preview; if it renders there, report it."
    }
  },
  "x-templo-warnings": {
    "missing-data": {
      "when": "A placeholder's path has no value in the data. The placeholder is left empty.",
      "hint": "Send a value at that path, or fix the path in the template."
    },
    "unsupported-value": {
      "when": "The value at a placeholder's path is an object or a list, not a single value. The placeholder is left empty.",
      "hint": "Point the placeholder at a single value inside it (`items.0.name`), or send a string."
    },
    "overflow": {
      "when": "A text with a fixed size is taller than its box: it runs past the bottom of the box. With shrink to fit, it still does not fit at its smallest font size (`atMinFontSize` is true).",
      "hint": "Shorten the text, make the box larger, lower the smallest font size, or let the box grow with the text (auto height) in the template."
    },
    "unknown-font": {
      "when": "A text's font isn't one of Templo's fonts. It is drawn in the default font.",
      "hint": "Pick one of the fonts the editor offers."
    }
  }
}
