{
  "openapi": "3.0.3",
  "info": {
    "title": "pdfstork",
    "version": "v1",
    "description": "PDF generation API. Authenticate with an API token: `Authorization: Bearer {id}|{secret}`.",
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://pdfstork.com"
    }
  ],
  "tags": [
    {
      "name": "templates",
      "description": "Template management and PDF generation"
    },
    {
      "name": "html-to-pdf",
      "description": "HTML conversion"
    },
    {
      "name": "usage",
      "description": "Quota and usage"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/auth/forgot-password": {
      "post": {
        "operationId": "forgotPassword",
        "summary": "Request a password reset link",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Always 200 (no enumeration)"
          }
        }
      }
    },
    "/api/auth/login": {
      "post": {
        "operationId": "login",
        "summary": "Login with email and password (returns an API token)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token + user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "user": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "name": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "plan": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/auth/logout": {
      "post": {
        "operationId": "logout",
        "summary": "Revoke the current token",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Logged out"
          }
        }
      }
    },
    "/api/auth/register": {
      "post": {
        "operationId": "register",
        "summary": "Register a new account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "password_confirmation": {
                    "type": "string"
                  },
                  "signup_source": {
                    "type": "object",
                    "description": "Where the visitor first came from, kept by the website for 30 days. Optional; recorded once on the new account. Each value is cut to 100 characters. The ad click identifiers (gclid, gbraid, wbraid) are kept only when ads_consent is \"granted\".",
                    "properties": {
                      "utm_source": {
                        "type": "string"
                      },
                      "utm_medium": {
                        "type": "string"
                      },
                      "utm_campaign": {
                        "type": "string"
                      },
                      "utm_content": {
                        "type": "string"
                      },
                      "utm_term": {
                        "type": "string"
                      },
                      "referrer_host": {
                        "type": "string"
                      },
                      "landing_path": {
                        "type": "string"
                      },
                      "first_touch_at": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "gclid": {
                        "type": "string"
                      },
                      "gbraid": {
                        "type": "string"
                      },
                      "wbraid": {
                        "type": "string"
                      },
                      "ads_consent": {
                        "type": "string",
                        "enum": [
                          "granted",
                          "denied"
                        ],
                        "description": "The visitor's answer to the cookie banner."
                      },
                      "ads_consent_basis": {
                        "type": "string",
                        "enum": [
                          "opt_in",
                          "opt_out"
                        ],
                        "description": "opt_in: the visitor answered the banner. opt_out: measurement was on by default in their country (United States, Australia) and they did not refuse it. Honoured only from those countries."
                      },
                      "ads_consent_at": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "ads_consent_version": {
                        "type": "integer"
                      }
                    }
                  },
                  "heard_from": {
                    "$ref": "#/components/schemas/HeardFrom",
                    "description": "How did you hear about us? Without it, the app asks after sign-up."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token + user"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/auth/reset-password": {
      "post": {
        "operationId": "resetPassword",
        "summary": "Reset the password with a token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "password_confirmation": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password updated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/v1/html-to-pdf": {
      "post": {
        "tags": [
          "html-to-pdf"
        ],
        "summary": "Convert HTML to PDF",
        "description": "Accepts raw `html` (or `twig` as fallback) and renders it with Chromium (Gotenberg). Costs 1 credit per render, like any other PDF.",
        "parameters": [
          {
            "name": "output",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Output"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HtmlToPdfRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated PDF",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Base64Response"
                    },
                    {
                      "$ref": "#/components/schemas/URLResponse"
                    }
                  ]
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/QuotaExceeded"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "htmlToPdf"
      }
    },
    "/api/v1/templates": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "List templates",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateIndexResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "listTemplates"
      }
    },
    "/api/v1/templates/merge": {
      "post": {
        "tags": [
          "templates"
        ],
        "summary": "Merge multiple templates into one PDF",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MergeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Merged PDF",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Base64Response"
                    },
                    {
                      "$ref": "#/components/schemas/URLResponse"
                    }
                  ]
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "description": "Merging PDFs is available on the Pro plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanRequired"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/MergeTemplateNotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/QuotaExceeded"
          },
          "500": {
            "$ref": "#/components/responses/MergeError"
          }
        },
        "operationId": "mergeTemplates"
      }
    },
    "/api/v1/templates/{id}": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "Show a template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/TemplateResource"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/TemplateNotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "showTemplate"
      }
    },
    "/api/v1/templates/{id}/generate": {
      "post": {
        "tags": [
          "templates"
        ],
        "summary": "Generate a PDF from a template",
        "description": "Renders the template with the provided data. `output` may be `base64` (default), `url` (temporary signed URL, 60 min) or `binary` (raw PDF). It can also be passed as a query parameter (`?output=url`).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "output",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Output"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated PDF",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Base64Response"
                    },
                    {
                      "$ref": "#/components/schemas/URLResponse"
                    }
                  ]
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/TemplateNotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/QuotaExceeded"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "generateTemplate"
      }
    },
    "/api/v1/usage": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "Get usage and quota",
        "responses": {
          "200": {
            "description": "Usage for the current month with 30 days of history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getUsage"
      }
    },
    "/api/v2/assets": {
      "post": {
        "operationId": "uploadAsset",
        "summary": "Upload a template asset (logo, signature) and get a stable URL",
        "description": "The file is identified by its own bytes, not by the declared filename or content type. SVG uploads are screened for constructs that would run as script and refused with the reason. The returned URL does not expire, so it can be stored in a template; reading it needs only the URL, which carries an unguessable id.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "PNG, JPEG, GIF or WebP, or an SVG that passes screening. 10 MiB maximum."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Asset"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "503": {
            "description": "Asset storage is not configured on this instance"
          }
        }
      },
      "get": {
        "operationId": "listAssets",
        "summary": "List the assets this account owns",
        "description": "Reading an asset needs only its URL; finding out what you have needs an account. Most recent first.",
        "responses": {
          "200": {
            "description": "The account's assets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Asset"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      }
    },
    "/api/v2/assets/{id}": {
      "get": {
        "operationId": "showAsset",
        "summary": "Fetch an uploaded asset",
        "description": "Public: the unguessable id in the URL is the capability, because neither an <img> tag nor the renderer fetching it server-side can carry a bearer token. Served with a Content-Security-Policy of \"default-src 'none'; sandbox\" and X-Content-Type-Options: nosniff, which is what makes serving user-supplied SVG from this origin safe.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The id returned by the upload, extension included."
          }
        ],
        "responses": {
          "200": {
            "description": "The stored file",
            "content": {
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "No such asset"
          }
        }
      },
      "delete": {
        "operationId": "deleteAsset",
        "summary": "Delete an asset this account owns",
        "description": "An asset owned by another account answers 404, exactly as one that never existed would: distinguishing the two would reveal which ids are in use.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "No such asset, or it belongs to another account"
          }
        }
      }
    },
    "/api/v2/html/preview": {
      "post": {
        "operationId": "previewHtml",
        "summary": "Render twig to HTML (no PDF, no quota)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "twig": {
                    "type": "string"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "header": {
                    "type": "string",
                    "description": "Header template, rendered with the same data."
                  },
                  "footer": {
                    "type": "string",
                    "description": "Footer template, rendered with the same data."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rendered HTML",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "html": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string",
                      "description": "Present when success is false because the template failed to render: the engine's message. The client must show it: without it a broken template looked like a working one (#153)."
                    },
                    "header": {
                      "type": "string",
                      "description": "The rendered header, when one was sent."
                    },
                    "footer": {
                      "type": "string",
                      "description": "The rendered footer, when one was sent."
                    },
                    "line": {
                      "type": "integer",
                      "description": "Line of the error in its part, 0 when unknown."
                    },
                    "part": {
                      "type": "string",
                      "enum": [
                        "template",
                        "header",
                        "footer"
                      ],
                      "description": "Which part failed."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      }
    },
    "/api/v2/html/validate": {
      "post": {
        "operationId": "validateTwig",
        "summary": "Validate a twig template (syntactic)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "twig": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Valid",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "line": {
                      "type": "integer",
                      "description": "Line of the error, 0 when unknown."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/v2/logs": {
      "get": {
        "operationId": "listLogs",
        "summary": "Latest 10 PDF generation logs",
        "responses": {
          "200": {
            "description": "Logs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "format": "int64"
                          },
                          "template_id": {
                            "type": "integer",
                            "format": "int64",
                            "nullable": true
                          },
                          "template_name": {
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "type": "string"
                          },
                          "output_type": {
                            "type": "string"
                          },
                          "file_size": {
                            "type": "integer"
                          },
                          "generated_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "payload": {
                            "type": "string",
                            "nullable": true,
                            "description": "JSON payload sent to the renderer"
                          },
                          "error_message": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      }
    },
    "/api/v2/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Current user profile",
        "responses": {
          "200": {
            "description": "Profile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      }
    },
    "/api/v2/password": {
      "put": {
        "put": {
          "operationId": "updatePassword",
          "summary": "Update the account password",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "requestBody": {
            "required": true,
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "current_password": {
                      "type": "string"
                    },
                    "password": {
                      "type": "string"
                    },
                    "password_confirmation": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "Updated"
            },
            "422": {
              "$ref": "#/components/responses/ValidationError"
            }
          }
        }
      }
    },
    "/api/v2/profile": {
      "put": {
        "put": {
          "operationId": "updateProfile",
          "summary": "Update name and email",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "requestBody": {
            "required": true,
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "Updated"
            },
            "422": {
              "$ref": "#/components/responses/ValidationError"
            }
          }
        }
      }
    },
    "/api/v2/templates": {
      "get": {
        "operationId": "listAppTemplates",
        "summary": "List templates (full content)",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppTemplateIndexResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          }
        }
      },
      "post": {
        "operationId": "storeTemplate",
        "summary": "Create a template",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppTemplateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AppTemplateResource"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "403": {
            "description": "The team's template allowance is full (Discovery: 1, Basic: 10, Pro: unlimited)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanRequired"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/templates/preview": {
      "post": {
        "operationId": "previewTemplate",
        "summary": "Render a template editor state without saving (no quota)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/api/v2/templates/{id}": {
      "get": {
        "operationId": "showAppTemplate",
        "summary": "Show a template (full content)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AppTemplateResource"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/TemplateNotFound"
          }
        }
      },
      "put": {
        "operationId": "updateTemplate",
        "summary": "Update a template (partial fields preserve stored values)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppTemplateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AppTemplateResource"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/TemplateNotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "operationId": "deleteTemplate",
        "summary": "Delete a template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/TemplateNotFound"
          }
        }
      }
    },
    "/api/v2/templates/{id}/versions": {
      "get": {
        "operationId": "listVersions",
        "summary": "List template versions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Versions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionsResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v2/templates/{id}/versions/publish": {
      "post": {
        "operationId": "publishVersion",
        "summary": "Snapshot the template as a new version (pruned to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionResource"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v2/templates/{id}/versions/{version}/restore": {
      "post": {
        "operationId": "restoreVersion",
        "summary": "Restore a version onto the template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Restored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AppTemplateResource"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/TemplateNotFound"
          }
        }
      }
    },
    "/api/v2/tokens": {
      "get": {
        "get": {
          "operationId": "listTokens",
          "summary": "List API tokens",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "responses": {
            "200": {
              "description": "Tokens"
            }
          }
        }
      },
      "post": {
        "post": {
          "operationId": "createToken",
          "summary": "Create an API token",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "requestBody": {
            "required": true,
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "newToken (shown once)"
            }
          }
        }
      }
    },
    "/api/v2/tokens/{id}": {
      "delete": {
        "delete": {
          "operationId": "deleteToken",
          "summary": "Delete an API token",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "parameters": [
            {
              "name": "id",
              "in": "path",
              "required": true,
              "schema": {
                "type": "integer"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "Deleted"
            }
          }
        }
      }
    },
    "/api/v2/webhooks": {
      "get": {
        "get": {
          "operationId": "listWebhooks",
          "summary": "List team webhooks",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "responses": {
            "200": {
              "description": "Webhooks"
            }
          }
        }
      },
      "post": {
        "post": {
          "operationId": "createWebhook",
          "summary": "Create a webhook",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "requestBody": {
            "required": true,
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "event_name": {
                      "type": "string",
                      "nullable": true
                    },
                    "template_id": {
                      "type": "integer",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "responses": {
            "201": {
              "description": "Created"
            },
            "422": {
              "$ref": "#/components/responses/ValidationError"
            }
          }
        },
        "responses": {
          "403": {
            "description": "Webhooks are available on the Pro plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanRequired"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/webhooks/{id}": {
      "delete": {
        "delete": {
          "operationId": "deleteWebhook",
          "summary": "Delete a webhook",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "parameters": [
            {
              "name": "id",
              "in": "path",
              "required": true,
              "schema": {
                "type": "integer"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "Deleted"
            }
          }
        }
      }
    },
    "/api/v2/webhooks/{id}/secret": {
      "get": {
        "get": {
          "operationId": "webhookSecret",
          "summary": "Show a webhook signing secret",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "parameters": [
            {
              "name": "id",
              "in": "path",
              "required": true,
              "schema": {
                "type": "integer"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "Secret"
            }
          }
        }
      }
    },
    "/api/v2/webhooks/{id}/test": {
      "post": {
        "post": {
          "operationId": "testWebhook",
          "summary": "Send a test delivery",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "parameters": [
            {
              "name": "id",
              "in": "path",
              "required": true,
              "schema": {
                "type": "integer"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "Test sent"
            }
          }
        }
      }
    },
    "/api/v2/webhooks/{id}/toggle": {
      "patch": {
        "patch": {
          "operationId": "toggleWebhook",
          "summary": "Toggle a webhook active state",
          "security": [
            {
              "bearerAuth": []
            }
          ],
          "parameters": [
            {
              "name": "id",
              "in": "path",
              "required": true,
              "schema": {
                "type": "integer"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "Toggled"
            }
          }
        }
      }
    },
    "/api/v2/me/heard-from": {
      "put": {
        "operationId": "putHeardFrom",
        "summary": "Answer How did you hear about us? (once)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HeardFrom"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Not one of the answers"
          }
        }
      }
    },
    "/api/v2/me/ads-consent": {
      "put": {
        "operationId": "putAdsConsent",
        "summary": "Ad measurement consent (Settings)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "granted"
                ],
                "properties": {
                  "granted": {
                    "type": "boolean"
                  },
                  "version": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "granted missing"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API token: `{id}|{secret}`"
      }
    },
    "schemas": {
      "Output": {
        "type": "string",
        "enum": [
          "base64",
          "url",
          "binary"
        ],
        "default": "base64"
      },
      "UsageInfo": {
        "type": "object",
        "properties": {
          "current": {
            "type": "integer",
            "description": "Credits consumed this month"
          },
          "limit": {
            "type": "integer",
            "description": "Monthly credit limit"
          },
          "percentage": {
            "type": "number",
            "description": "Percentage of the limit used"
          }
        }
      },
      "TemplateResource": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "editor",
              "html"
            ],
            "description": "editor = native renderer, html = twig/Chromium"
          },
          "has_base_pdf": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TemplateIndexResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateResource"
            }
          },
          "links": {
            "type": "object",
            "properties": {
              "first": {
                "type": "string",
                "nullable": true
              },
              "last": {
                "type": "string",
                "nullable": true
              },
              "prev": {
                "type": "string",
                "nullable": true
              },
              "next": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "current_page": {
                "type": "integer"
              },
              "from": {
                "type": "integer",
                "nullable": true
              },
              "last_page": {
                "type": "integer"
              },
              "path": {
                "type": "string"
              },
              "per_page": {
                "type": "integer"
              },
              "to": {
                "type": "integer",
                "nullable": true
              },
              "total": {
                "type": "integer"
              }
            }
          }
        }
      },
      "GenerateRequest": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "description": "Template variables",
            "additionalProperties": true
          },
          "output": {
            "$ref": "#/components/schemas/Output"
          },
          "filename": {
            "type": "string",
            "description": "Custom filename (default document.pdf)",
            "pattern": "^[a-zA-Z0-9_\\-\\.]+$"
          },
          "url_expiry": {
            "type": "integer",
            "description": "Minutes until the signed URL expires (1-1440)",
            "default": 60
          },
          "metadata": {
            "$ref": "#/components/schemas/DocumentMetadata"
          }
        }
      },
      "MergeSpec": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Template id (number or numeric string)"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "MergeRequest": {
        "type": "object",
        "properties": {
          "templates": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/MergeSpec"
            }
          },
          "output": {
            "$ref": "#/components/schemas/Output"
          },
          "filename": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_\\-\\.]+$"
          },
          "url_expiry": {
            "type": "integer",
            "default": 60
          },
          "metadata": {
            "$ref": "#/components/schemas/DocumentMetadata"
          }
        }
      },
      "HtmlToPdfRequest": {
        "type": "object",
        "properties": {
          "html": {
            "type": "string",
            "description": "Raw HTML to convert"
          },
          "twig": {
            "type": "string",
            "description": "Twig template; used when html is empty"
          },
          "data": {
            "type": "object",
            "description": "Twig variables",
            "additionalProperties": true
          },
          "config": {
            "type": "object",
            "description": "Rendering options",
            "properties": {
              "format": {
                "type": "string",
                "default": "A4"
              },
              "orientation": {
                "type": "string",
                "enum": [
                  "portrait",
                  "landscape"
                ],
                "default": "portrait"
              },
              "margins": {
                "type": "object",
                "properties": {
                  "top": {
                    "type": "number",
                    "default": 10
                  },
                  "right": {
                    "type": "number",
                    "default": 10
                  },
                  "bottom": {
                    "type": "number",
                    "default": 10
                  },
                  "left": {
                    "type": "number",
                    "default": 10
                  }
                }
              },
              "header": {
                "type": "string"
              },
              "footer": {
                "type": "string"
              },
              "customWidth": {
                "type": "number"
              },
              "customHeight": {
                "type": "number"
              },
              "metadata": {
                "$ref": "#/components/schemas/DocumentMetadata"
              }
            }
          },
          "output": {
            "$ref": "#/components/schemas/Output"
          },
          "filename": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_\\-\\.]+$"
          },
          "url_expiry": {
            "type": "integer",
            "default": 60
          },
          "metadata": {
            "$ref": "#/components/schemas/DocumentMetadata"
          }
        }
      },
      "Base64Response": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "pdf": {
            "type": "string",
            "format": "byte",
            "description": "Base64-encoded PDF"
          },
          "filename": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "usage": {
            "$ref": "#/components/schemas/UsageInfo"
          }
        }
      },
      "URLResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Temporary signed URL (default 60 min)"
          },
          "filename": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "size": {
            "type": "integer"
          },
          "usage": {
            "$ref": "#/components/schemas/UsageInfo"
          }
        }
      },
      "UsageResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "current_month_usage": {
                "type": "integer"
              },
              "quota_limit": {
                "type": "integer"
              },
              "quota_percentage": {
                "type": "number"
              },
              "pack_credits": {
                "type": "integer",
                "description": "Prepaid credits left. They take over once the monthly quota is spent, and never expire."
              },
              "overage_count": {
                "type": "integer"
              },
              "has_quota_remaining": {
                "type": "boolean"
              },
              "plan": {
                "type": "string",
                "enum": [
                  "pro",
                  "basic",
                  "discovery"
                ],
                "description": "The plan of the team the token belongs to. Discovery is the free plan."
              },
              "daily_usage": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "date": {
                      "type": "string",
                      "format": "date"
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ErrorBody": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        }
      },
      "ValidationErrors": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "QuotaExceeded": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/UsageInfo"
          }
        }
      },
      "MeResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "format": "int64"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "plan": {
                "type": "string",
                "enum": [
                  "pro",
                  "basic",
                  "none"
                ]
              },
              "usage": {
                "$ref": "#/components/schemas/UsageInfo"
              },
              "needs_heard_from": {
                "type": "boolean",
                "description": "The account still owes the answer to How did you hear about us?"
              },
              "ads_consent": {
                "type": "string",
                "description": "Ad measurement consent: granted, denied, or empty when never asked."
              }
            }
          }
        }
      },
      "AppTemplateResource": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "editor",
              "html"
            ]
          },
          "content": {
            "type": "object",
            "description": "Editor DSL",
            "additionalProperties": true
          },
          "twig": {
            "type": "string",
            "nullable": true
          },
          "twig_config": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "base_pdf_path": {
            "type": "string",
            "nullable": true
          },
          "has_base_pdf": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "twig_preview_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          }
        }
      },
      "AppTemplateInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "editor",
              "html"
            ]
          },
          "content": {
            "type": "object",
            "additionalProperties": true
          },
          "twig": {
            "type": "string",
            "nullable": true
          },
          "twig_config": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "base_pdf_path": {
            "type": "string",
            "nullable": true
          },
          "twig_preview_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          }
        }
      },
      "AppTemplateIndexResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppTemplateResource"
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "current_page": {
                "type": "integer"
              },
              "last_page": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              }
            }
          }
        }
      },
      "PreviewRequest": {
        "type": "object",
        "properties": {
          "template": {
            "type": "object",
            "description": "Editor state",
            "additionalProperties": true
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          },
          "debug": {
            "type": "boolean",
            "default": false
          },
          "type": {
            "type": "string",
            "enum": [
              "editor",
              "html"
            ],
            "default": "editor"
          },
          "twig": {
            "type": "string"
          },
          "twig_config": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "VersionResource": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/TemplateVersionResource"
          }
        }
      },
      "TemplateVersionResource": {
        "type": "object",
        "description": "A published snapshot. `creator` is null when the author account no longer exists.",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "version_number": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "content": {
            "type": "object",
            "additionalProperties": true,
            "description": "Editor state captured by the snapshot (visual templates)."
          },
          "twig": {
            "type": [
              "string",
              "null"
            ],
            "description": "HTML/Twig source captured by the snapshot (HTML templates)."
          },
          "twig_config": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "Page config captured by the snapshot."
          },
          "twig_preview_data": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "Sample data captured by the snapshot. Restoring a version replays its code with its own data, not the draft's."
          },
          "creator": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "integer",
                "format": "int64"
              },
              "name": {
                "type": "string"
              }
            }
          }
        }
      },
      "VersionsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateVersionResource"
            }
          }
        }
      },
      "Asset": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "0f8b1e2c-....png"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "content_type": {
            "type": "string",
            "example": "image/png"
          },
          "bytes": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PlanRequired": {
        "type": "object",
        "required": [
          "message",
          "required_plan",
          "upgrade_url"
        ],
        "properties": {
          "message": {
            "type": "string",
            "example": "QR codes and barcodes are available on the Basic plan and above."
          },
          "required_plan": {
            "type": "string",
            "enum": [
              "basic",
              "pro"
            ]
          },
          "upgrade_url": {
            "type": "string",
            "format": "uri",
            "example": "https://pdfstork.com/settings/billing"
          }
        }
      },
      "DocumentMetadata": {
        "type": "object",
        "description": "Document properties written into the PDF (Basic plan and above). Each value may contain {{ placeholders }}, filled from the request data. A property set in the request overrides the template's own, one by one.",
        "properties": {
          "title": {
            "type": "string",
            "example": "Invoice {{ invoice_number }}"
          },
          "author": {
            "type": "string",
            "example": "Acme Inc."
          },
          "subject": {
            "type": "string",
            "example": "Monthly invoice"
          },
          "keywords": {
            "type": "string",
            "description": "Comma-separated.",
            "example": "invoice, 2026"
          },
          "creator": {
            "type": "string",
            "example": "Acme ERP"
          }
        }
      },
      "HeardFrom": {
        "type": "object",
        "required": [
          "answer"
        ],
        "properties": {
          "answer": {
            "type": "string",
            "enum": [
              "youtube",
              "google_search",
              "ai_assistant",
              "directory",
              "social_media",
              "friend_colleague",
              "blog_article",
              "other"
            ]
          },
          "detail": {
            "type": "string",
            "description": "Which directory, or the free answer for other. Cut to 100 characters."
          },
          "position": {
            "type": "integer",
            "description": "Where the chosen answer was shown (the list is shuffled)."
          }
        }
      }
    },
    "responses": {
      "Unauthenticated": {
        "description": "Missing or invalid bearer token",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorBody"
            },
            "example": {
              "message": "Unauthenticated."
            }
          }
        }
      },
      "Forbidden": {
        "description": "The template belongs to another user, or it uses a feature your plan does not include (QR codes, barcodes and form fields need Basic; an imported PDF needs Pro). A plan refusal carries `required_plan` and `upgrade_url`.",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/ErrorBody"
                },
                {
                  "$ref": "#/components/schemas/PlanRequired"
                }
              ]
            },
            "examples": {
              "not_yours": {
                "value": {
                  "message": "You do not have access to this template."
                }
              },
              "plan": {
                "value": {
                  "message": "QR codes and barcodes are available on the Basic plan and above.",
                  "required_plan": "basic",
                  "upgrade_url": "https://pdfstork.com/settings/billing"
                }
              }
            }
          }
        }
      },
      "TemplateNotFound": {
        "description": "Template not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorBody"
            },
            "example": {
              "message": "No query results for model [App\\Models\\Template] 951438176795076"
            }
          }
        }
      },
      "MergeTemplateNotFound": {
        "description": "Template not found during merge",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorBody"
            },
            "example": {
              "message": "Template not found: 123"
            }
          }
        }
      },
      "ValidationError": {
        "description": "Request validation failed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ValidationErrors"
            }
          }
        }
      },
      "QuotaExceeded": {
        "description": "Monthly credit quota exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/QuotaExceeded"
            }
          }
        }
      },
      "ServerError": {
        "description": "Rendering or storage failure",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorBody"
            },
            "example": {
              "error": "PDF generation failed"
            }
          }
        }
      },
      "MergeError": {
        "description": "Merging failure",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorBody"
            },
            "example": {
              "error": "PDF merge failed"
            }
          }
        }
      },
      "PlanRequired": {
        "description": "Your plan does not include this feature",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PlanRequired"
            }
          }
        }
      }
    }
  }
}
