{
  "openapi": "3.0.4",
  "info": {
    "title": "DocPayload API",
    "description": "Document generation API. Send a JSON document definition and receive a formatted document.\n\n**Resources:**\n- [Document Definition JSON Schema](https://schemas.docpayload.com/v1/document-definition.schema.json)\n- [Documentation](https://docs.docpayload.com/)\n- [Changelog](https://docs.docpayload.com/changelog)",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://api.docpayload.com"
    }
  ],
  "paths": {
    "/v1/api-auth/token": {
      "post": {
        "tags": [
          "ApiAuth"
        ],
        "summary": "Issues access tokens for API key authentication (OAuth 2.0 Client Credentials Flow)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiTokenRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiTokenRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ApiTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/templates/browse": {
      "get": {
        "tags": [
          "CommunityTemplates"
        ],
        "summary": "Browse shared and community templates with filtering, search, and sorting.",
        "parameters": [
          {
            "name": "visibility",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tags",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "popular"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateSummaryDto"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateSummaryDto"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateSummaryDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates/browse/{id}": {
      "get": {
        "tags": [
          "CommunityTemplates"
        ],
        "summary": "Get full details of a shared or community template (read-only, for preview).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates/{id}/like": {
      "post": {
        "tags": [
          "CommunityTemplates"
        ],
        "summary": "Like a shared or community template.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "CommunityTemplates"
        ],
        "summary": "Unlike a shared or community template.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/documents/generate-from-payload": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Generate a document from a JSON definition payload.\nSee the Document Definition JSON Schema for the full request body format.",
        "description": "The request body is a JSON document definition. See https://schemas.docpayload.com/v1/document-definition.schema.json",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OutputFormat"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/documents/generate-from-payload/{format}": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Generate a document from a JSON definition payload.\nSee the Document Definition JSON Schema for the full request body format.",
        "description": "The request body is a JSON document definition. See https://schemas.docpayload.com/v1/document-definition.schema.json",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OutputFormat"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "List all generated documents for the tenant.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Documents"
        ],
        "summary": "Batch delete documents by IDs.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchDeleteRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchDeleteRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/BatchDeleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/documents/{fileName}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Download a generated document by file name.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fileName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/json": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/documents/generate-from-template": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Generate a document from a stored template or raw content, with $data injection.\nWhen Content is provided, it is used directly. Otherwise TemplateId is loaded from DB.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OutputFormat"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFromTemplateRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFromTemplateRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFromTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/documents/generate-from-template/{format}": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Generate a document from a stored template or raw content, with $data injection.\nWhen Content is provided, it is used directly. Otherwise TemplateId is loaded from DB.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OutputFormat"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFromTemplateRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFromTemplateRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFromTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/platform/templates/contract-migration": {
      "post": {
        "tags": [
          "Platform"
        ],
        "summary": "The stored-template run; dry unless apply. An applied run names writtenBefore,\nwhen the reference stopped writing: the operator knows it, the server must not guess.",
        "parameters": [
          {
            "name": "apply",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "writtenBefore",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/StoredTemplateReport"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredTemplateReport"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredTemplateReport"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates": {
      "get": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateDto"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateDto"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateDto"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateCreateDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateCreateDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateCreateDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchDeleteRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchDeleteRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/BatchDeleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/names": {
      "get": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateSummaryDto"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateSummaryDto"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateSummaryDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}": {
      "get": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdateDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdateDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdateDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/rename": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "The editor's save: a new name renames the template, and changed content or data is its next revision.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateRenameDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateRenameDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateRenameDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{templateId}/revisions": {
      "post": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdateDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdateDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdateDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateDto"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateDto"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{templateId}/revisions/{revisionId}": {
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Takes one revision out of its template's history. The revision after it then follows the one before it: left\npointing at a deleted row, it read as the start of a second template. The only revision is not removed here -\nthat is deleting the template.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "revisionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{templateId}/revisions/{revisionId}/revert": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Restores a revision: its content and data become the template's next revision, after the current one, so the\nhistory stays one line and nothing in it is lost. Restoring what is already current changes nothing.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "revisionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates/fork": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Fork a shared, community, or own template into this tenant's account.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateForkDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateForkDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateForkDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates/fork-examples": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Batch fork public example templates by slug into the tenant's workspace.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "text/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "application/*+json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/publish": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Publish a tenant template to the community.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplatePublishDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplatePublishDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplatePublishDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/unpublish": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Unpublish a community template back to private.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/publish-to-docs": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Publish a template as a docs example — generates PDF and uploads to blob. Platform admin only.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExamplePublishDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExamplePublishDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExamplePublishDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/unpublish-from-docs": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Unpublish a docs example — removes from public listing and deletes blob PDF. Platform admin only.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/upstream": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Check if the upstream source of a forked template has been updated.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateUpstreamDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateUpstreamDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateUpstreamDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates/{id}/pull": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Pull the latest content from the upstream source into this forked template.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{tenantId}/templates/folders": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Get the implicit folder tree derived from template Path values.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateFolderDto"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateFolderDto"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TemplateFolderDto"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Create a new folder.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderCreateDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderCreateDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/FolderCreateDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Delete a folder — optionally delete contents or move them to parent.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "deleteContents",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/move": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Move templates to a target folder.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateMoveDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateMoveDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateMoveDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/{tenantId}/templates/folders/rename": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Rename a folder by updating all template paths with that prefix.",
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderRenameDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderRenameDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/FolderRenameDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiTokenRequest": {
        "required": [
          "clientId",
          "clientSecret"
        ],
        "type": "object",
        "properties": {
          "clientId": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "clientSecret": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string"
          },
          "requestedScopes": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BatchDeleteRequest": {
        "required": [
          "ids"
        ],
        "type": "object",
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "additionalProperties": false
      },
      "DocumentGenerationResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/DocumentGenerationStatus"
          },
          "triggeredAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "documentId": {
            "type": "string",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "nullable": true
          },
          "downloadUrl": {
            "type": "string",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "fileSizeBytes": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "sizeClass": {
            "type": "string",
            "description": "The size class the document is priced by: \"small\", \"standard\" or \"large\".",
            "nullable": true
          },
          "charge": {
            "type": "number",
            "description": "What this generation was charged, in the plan's currency; null on a plan that charges none.",
            "format": "double",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errorCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What the document asked for and did not get, by code; empty when it got everything.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DocumentGenerationStatus": {
        "enum": [
          "Succeeded",
          "Failed",
          "Processing"
        ],
        "type": "string"
      },
      "ExamplePublishDto": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request body for publishing a template as a docs example.\nSlug is auto-derived from the template name — not user-supplied."
      },
      "FolderCreateDto": {
        "required": [
          "path"
        ],
        "type": "object",
        "properties": {
          "path": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "FolderRenameDto": {
        "required": [
          "newName",
          "oldPath"
        ],
        "type": "object",
        "properties": {
          "oldPath": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string"
          },
          "newName": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "GenerateFromTemplateRequest": {
        "required": [
          "data"
        ],
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string",
            "description": "Stored template ID. Ignored when DocDefinition is provided.",
            "format": "uuid",
            "nullable": true
          },
          "docDefinition": {
            "description": "Optional document definition. When provided, used instead of loading from TemplateId.",
            "nullable": true
          },
          "data": {
            "type": "object",
            "additionalProperties": { }
          }
        },
        "additionalProperties": false
      },
      "OutputFormat": {
        "enum": [
          0,
          1
        ],
        "type": "integer",
        "format": "int32"
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "StoredTemplateReport": {
        "type": "object",
        "properties": {
          "applied": {
            "type": "boolean"
          },
          "writtenBefore": {
            "type": "string",
            "format": "date-time"
          },
          "rows": {
            "type": "integer",
            "format": "int32"
          },
          "unchanged": {
            "type": "integer",
            "format": "int32"
          },
          "migrated": {
            "type": "integer",
            "format": "int32"
          },
          "lossy": {
            "type": "integer",
            "format": "int32"
          },
          "refused": {
            "type": "integer",
            "format": "int32"
          },
          "written": {
            "type": "integer",
            "format": "int32"
          },
          "words": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            },
            "nullable": true
          },
          "lostWords": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            },
            "nullable": true
          },
          "attention": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateAttention"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateAttention": {
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "code": {
            "type": "string",
            "nullable": true
          },
          "path": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "`refused`: off the schema, not written; `lost`: written with a loss. Never a refusal's message, which\n            can quote the document."
      },
      "TemplateCreateDto": {
        "required": [
          "content",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string"
          },
          "path": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "content": {
            "minLength": 1,
            "type": "string"
          },
          "data": {
            "type": "string",
            "nullable": true
          },
          "createdBy": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "Accepted and not read: a template is signed with its caller.",
            "nullable": true
          },
          "owner": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "parentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "parentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "tenantId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "path": {
            "type": "string",
            "nullable": true
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string",
            "nullable": true
          },
          "owner": {
            "type": "string",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revision": {
            "type": "string",
            "nullable": true
          },
          "visibility": {
            "$ref": "#/components/schemas/TemplateVisibility"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "thumbnailUrl": {
            "type": "string",
            "nullable": true
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "publishedBy": {
            "type": "string",
            "nullable": true
          },
          "license": {
            "type": "string",
            "nullable": true
          },
          "forkedFromId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "forkCount": {
            "type": "integer",
            "format": "int32"
          },
          "likeCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "TemplateFolderDto": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "templateCount": {
            "type": "integer",
            "format": "int32"
          },
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateFolderDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateForkDto": {
        "required": [
          "sourceTemplateId"
        ],
        "type": "object",
        "properties": {
          "sourceTemplateId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateMoveDto": {
        "required": [
          "templateIds"
        ],
        "type": "object",
        "properties": {
          "templateIds": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "targetPath": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplatePublishDto": {
        "required": [
          "category",
          "description",
          "tags"
        ],
        "type": "object",
        "properties": {
          "description": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string"
          },
          "tags": {
            "maxItems": 5,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "category": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string"
          },
          "thumbnailUrl": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "license": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateRenameDto": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string"
          },
          "content": {
            "type": "string",
            "description": "Optional — when provided, updates the content in-place alongside the rename.",
            "nullable": true
          },
          "data": {
            "type": "string",
            "description": "Optional — when provided, updates the data in-place alongside the rename.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateSummaryDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "path": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "thumbnailUrl": {
            "type": "string",
            "nullable": true
          },
          "publishedBy": {
            "type": "string",
            "nullable": true
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "visibility": {
            "$ref": "#/components/schemas/TemplateVisibility"
          },
          "forkedFromId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "forkCount": {
            "type": "integer",
            "format": "int32"
          },
          "likeCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "TemplateUpdateDto": {
        "required": [
          "content",
          "id"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "parentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "path": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "content": {
            "minLength": 1,
            "type": "string"
          },
          "data": {
            "type": "string",
            "nullable": true
          },
          "createdBy": {
            "type": "string",
            "nullable": true
          },
          "owner": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "TemplateUpstreamDto": {
        "type": "object",
        "properties": {
          "hasUpdate": {
            "type": "boolean"
          },
          "forkedFromId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "forkedFromName": {
            "type": "string",
            "nullable": true
          },
          "forkedFromRevision": {
            "type": "string",
            "nullable": true
          },
          "currentRevision": {
            "type": "string",
            "nullable": true
          },
          "publishedBy": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TemplateVisibility": {
        "enum": [
          0,
          1,
          2,
          3
        ],
        "type": "integer",
        "format": "int32"
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "JWT Bearer token. Obtain via `POST https://api.docpayload.com/v1/api-auth/token` with client credentials.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "tags": [
    {
      "name": "ApiAuth"
    },
    {
      "name": "CommunityTemplates"
    },
    {
      "name": "Documents"
    },
    {
      "name": "Platform"
    },
    {
      "name": "Templates"
    }
  ]
}