{
  "openapi": "3.0.3",
  "info": {
    "title": "Shipwave PDF Studio API",
    "version": "4.2.0",
    "description": "Shipwave PDF processing, personal accounts and subscription billing. Original processing paths, file fields and omitted-field defaults are retained. Supabase sessions and personal API keys enforce account features and shared rate/monthly limits; legacy Basic/query credentials are accepted only when Supabase is omitted. Account/key/billing management requires a verified user session. Stripe webhooks require a signed raw body. Geometry fields support logo rotation/placement, visible watermarks and exact thermal crops. Processing is stateless: use a saved input to replace an edit or chain the latest output to add a step. See docs/API.md, ACCOUNTS.md, BILLING.md and PLACEMENT.md. Release 4.1 adds preview rulers/grid and a reusable visible-page region for coordinate-based editing, plus authenticated coordinate metadata/conversion at /api/pdf/coordinates. Existing omitted-field defaults remain unchanged. Release 4.2 adds optional direct object-frame placement for logos, text and watermarks, plus authenticated font outline metadata at /api/pdf/placement-preview. Live workspace gestures remain local until Apply. The main browser interface now runs the rebranded PDFCraft editor and presents the same 63 callable Shipwave tools with unchanged fields and defaults. Native-only editor commands and Undo/Redo are local UI features, not new HTTP endpoints; service edits become native history steps. See docs/PDFCRAFT_MIGRATION.md."
  },
  "servers": [
    {
      "url": "/",
      "description": "Current application origin"
    }
  ],
  "security": [
    {
      "supabaseSession": []
    },
    {
      "apiKey": []
    },
    {
      "basicAuth": []
    },
    {
      "apiKeyQuery": []
    }
  ],
  "tags": [
    {
      "name": "Labels"
    },
    {
      "name": "Conversion"
    },
    {
      "name": "Organization"
    },
    {
      "name": "Branding"
    },
    {
      "name": "Editing"
    },
    {
      "name": "Tools"
    },
    {
      "name": "Security"
    },
    {
      "name": "Legacy"
    },
    {
      "name": "Service"
    },
    {
      "name": "AI",
      "description": "External AI provider tasks; require server-side configuration and explicit invocation."
    },
    {
      "name": "Accounts",
      "description": "User sessions, owned API keys and effective limits."
    },
    {
      "name": "Billing",
      "description": "Server-verified subscription payments and customer billing."
    },
    {
      "name": "Native editor",
      "description": "Authenticated, bounded HTTP access to the real PDFCraft command engine; independent nativeFeatures apply."
    }
  ],
  "paths": {
    "/api/convert": {
      "post": {
        "operationId": "post_api_convert",
        "summary": "Thermal label to A4, with optional shipping guide",
        "tags": [
          "Labels"
        ],
        "description": "Original PyMuPDF layout, one portrait A4 page per input page. Center y is one-third of remaining height from the TOP. Source label size is retained except horizontal+guide: label fitted proportionally in top half, rotated guide in bottom half. Other guide layout uses available side space and may omit the guide when too small. A4 595.276 x 841.890 points; 36-point top positions. Output: <input>_A4.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "position": {
                    "type": "string",
                    "default": "center",
                    "enum": [
                      "center",
                      "top",
                      "top-left"
                    ]
                  },
                  "orientation": {
                    "type": "string",
                    "default": "vertical",
                    "enum": [
                      "vertical",
                      "horizontal"
                    ]
                  },
                  "guide": {
                    "type": "string",
                    "description": "Accepts true/1/yes/on or false/0/no/off (case insensitive).",
                    "default": "false"
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/label-to-a4": {
      "post": {
        "operationId": "post_api_convert_label_to_a4",
        "summary": "Place label on A4 using original main-server positioning",
        "tags": [
          "Labels"
        ],
        "description": "Retains source label physical size and filename. Center y is one-third of remaining height from the BOTTOM, unlike /api/convert. Landscape rotates the label 90 degrees on a portrait A4 page. Edge margin 36 points. No guide.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "position": {
                    "type": "string",
                    "default": "center",
                    "enum": [
                      "center",
                      "top",
                      "top-left",
                      "top-right",
                      "bottom",
                      "bottom-left",
                      "bottom-right",
                      "left",
                      "right"
                    ]
                  },
                  "orientation": {
                    "type": "string",
                    "default": "portrait",
                    "enum": [
                      "portrait",
                      "landscape"
                    ]
                  },
                  "offsetX": {
                    "type": "number",
                    "default": 0,
                    "description": "Positive moves right."
                  },
                  "offsetY": {
                    "type": "number",
                    "default": 0,
                    "description": "Positive moves down."
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              },
              "X-Position": {
                "schema": {
                  "type": "string"
                },
                "description": "Applied placement."
              },
              "X-Orientation": {
                "schema": {
                  "type": "string"
                },
                "description": "Applied label orientation."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/html-string": {
      "post": {
        "operationId": "post_api_convert_html_string",
        "summary": "Render HTML string to PDF in Chromium",
        "tags": [
          "Conversion"
        ],
        "description": "Standard mode: A4 portrait with 1cm margins. Custom width/height or preserveOriginalSize mode: zero default margins. CSS @page rules are respected by default. Output: converted-<timestamp>.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "html": {
                    "type": "string",
                    "minLength": 1
                  },
                  "options": {
                    "$ref": "#/components/schemas/HtmlOptions"
                  }
                },
                "required": [
                  "html"
                ]
              },
              "example": {
                "html": "<style>@page{size:4in 6in;margin:0}body{margin:0}</style><h1>Label</h1>",
                "options": {
                  "preserveOriginalSize": true
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/html-file": {
      "post": {
        "operationId": "post_api_convert_html_file",
        "summary": "Render uploaded HTML file to PDF",
        "tags": [
          "Conversion"
        ],
        "description": "Individual fields override options JSON. Uses the same three size modes as html-string. Output preserves input basename with .pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "htmlFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "HTML file"
                  },
                  "options": {
                    "type": "string",
                    "description": "JSON string matching HtmlOptions."
                  },
                  "width": {
                    "type": "string"
                  },
                  "height": {
                    "type": "string"
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "A4",
                      "A3",
                      "A5",
                      "Letter",
                      "Legal",
                      "Tabloid"
                    ]
                  },
                  "orientation": {
                    "type": "string",
                    "enum": [
                      "portrait",
                      "landscape"
                    ]
                  },
                  "preserveOriginalSize": {
                    "type": "string",
                    "enum": [
                      "true",
                      "false"
                    ]
                  },
                  "scale": {
                    "type": "number",
                    "minimum": 0.1,
                    "maximum": 2
                  },
                  "printBackground": {
                    "type": "string",
                    "enum": [
                      "true",
                      "false"
                    ]
                  }
                },
                "required": [
                  "htmlFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_api_convert_html_file",
        "summary": "Get HTML upload endpoint information",
        "tags": [
          "Service"
        ],
        "description": "Use POST with the htmlFile multipart field to convert.",
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit reached, when enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/url-to-pdf": {
      "post": {
        "operationId": "post_api_convert_url_to_pdf",
        "summary": "Render an HTTP(S) URL to PDF",
        "tags": [
          "Conversion"
        ],
        "description": "Background printing and CSS page size enabled. Output: <hostname>-<timestamp>.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^https?://"
                  },
                  "options": {
                    "type": "object",
                    "properties": {
                      "format": {
                        "type": "string",
                        "default": "A4",
                        "enum": [
                          "A4",
                          "A3",
                          "A5",
                          "Letter",
                          "Legal",
                          "Tabloid"
                        ]
                      },
                      "orientation": {
                        "type": "string",
                        "default": "portrait",
                        "enum": [
                          "portrait",
                          "landscape"
                        ]
                      },
                      "fullPage": {
                        "type": "boolean",
                        "default": true,
                        "description": "Compatibility field. Chromium PDF pagination follows print layout, not screenshot fullPage behavior."
                      },
                      "waitUntil": {
                        "type": "string",
                        "default": "networkidle2",
                        "enum": [
                          "load",
                          "domcontentloaded",
                          "networkidle0",
                          "networkidle2"
                        ]
                      },
                      "timeout": {
                        "type": "integer",
                        "default": 30000,
                        "minimum": 5000,
                        "maximum": 60000
                      },
                      "viewport": {
                        "type": "object",
                        "properties": {
                          "width": {
                            "type": "integer",
                            "default": 1920,
                            "minimum": 100,
                            "maximum": 3840
                          },
                          "height": {
                            "type": "integer",
                            "default": 1080,
                            "minimum": 100,
                            "maximum": 2160
                          }
                        }
                      }
                    }
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/office-to-pdf": {
      "post": {
        "operationId": "post_api_convert_office_to_pdf",
        "summary": "Convert DOCX, DOC, XLSX, XLS, PPTX or PPT",
        "tags": [
          "Conversion"
        ],
        "description": "DOCX retains Mammoth HTML conversion; spreadsheets retain first-sheet HTML conversion where applicable. LibreOffice handles remaining supported formats and is included in Docker. Output: input basename with .pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "officeFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "Office document; 100 MiB maximum."
                  }
                },
                "required": [
                  "officeFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/merge/pdf-files": {
      "post": {
        "operationId": "post_api_merge_pdf_files",
        "summary": "Merge complete PDFs in upload order",
        "tags": [
          "Organization"
        ],
        "description": "2-20 PDFs; main file-size limit per PDF. Output: merged-<count>-files-<timestamp>.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFiles": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary",
                      "description": "PDF file"
                    },
                    "minItems": 2,
                    "maxItems": 20
                  }
                },
                "required": [
                  "pdfFiles"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/upload/temp": {
      "post": {
        "operationId": "post_api_upload_temp",
        "summary": "Cache a PDF for organized merging",
        "tags": [
          "Organization"
        ],
        "description": "Temporary file IDs expire after roughly one hour and do not survive restarts. Use the same running instance for subsequent requests.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "default": true
                    },
                    "fileId": {
                      "type": "string"
                    },
                    "originalName": {
                      "type": "string"
                    },
                    "pageCount": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/merge/organized": {
      "post": {
        "operationId": "post_api_merge_organized",
        "summary": "Merge selected pages in exact array order",
        "tags": [
          "Organization"
        ],
        "description": "Upload source files to /api/upload/temp first. pageIndex is zero-based. Pages may be repeated or omitted. Output: merged-<count>-pages-<timestamp>.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "fileId": {
                          "type": "string"
                        },
                        "pageIndex": {
                          "type": "integer",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "fileId",
                        "pageIndex"
                      ]
                    },
                    "minItems": 1
                  }
                },
                "required": [
                  "pages"
                ]
              },
              "example": {
                "pages": [
                  {
                    "fileId": "FIRST_FILE_ID",
                    "pageIndex": 1
                  },
                  {
                    "fileId": "SECOND_FILE_ID",
                    "pageIndex": 0
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/split/pdf-pages": {
      "post": {
        "operationId": "post_api_split_pdf_pages",
        "summary": "Split PDF into pages, ranges or size-based groups",
        "tags": [
          "Organization"
        ],
        "description": "One result returns application/pdf. Multiple results return a ZIP containing PDFs. Page mode names files page-1.pdf etc; range mode pages-<start>-<end>.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "splitType": {
                    "type": "string",
                    "default": "pages",
                    "enum": [
                      "pages",
                      "range",
                      "size"
                    ]
                  },
                  "pageRanges": {
                    "type": "string",
                    "description": "JSON string array of inclusive 1-based {start,end} ranges; required for splitType=range. Example: [{\"start\":1,\"end\":2}]"
                  },
                  "maxSizeKB": {
                    "type": "number",
                    "minimum": 100,
                    "description": "Required for splitType=size. Consecutive page groups; rejects a single page larger than the target."
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "ZIP containing one PDF per split result"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/logo/remove": {
      "post": {
        "operationId": "post_api_logo_remove",
        "summary": "Cover a logo area on every page",
        "tags": [
          "Branding"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Visual cover, not secure redaction. Debug adds a 2-point red border. Retains input filename. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Fills the exact region with the chosen color; debug outlines it. Visual covering does not remove underlying content. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "x": {
                    "type": "number",
                    "default": 125,
                    "minimum": 0
                  },
                  "y": {
                    "type": "number",
                    "default": 450,
                    "minimum": 0
                  },
                  "width": {
                    "type": "number",
                    "default": 100,
                    "minimum": 0.001
                  },
                  "height": {
                    "type": "number",
                    "default": 25,
                    "minimum": 0.001
                  },
                  "color": {
                    "type": "string",
                    "default": "#ffffff",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "debug": {
                    "type": "boolean",
                    "default": false
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, page, pages (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Fills the exact region with the chosen color; debug outlines it. Visual covering does not remove underlying content.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/logo/add": {
      "post": {
        "operationId": "post_api_logo_add",
        "summary": "Add a custom or bundled logo with optional visual placement",
        "tags": [
          "Branding"
        ],
        "description": "Original requests containing only x/y/width/height retain the raw, unrotated coordinate formula, all pages, and default 100 × 50 point logo at (100,100), without bounds adjustment. Supplying any position, rotation, angle, scale, opacity, margin or pages field enables visible-page geometry. In that mode custom x/y locate the final rotated visual bounding box from the visible bottom-left; anchors use the visible CropBox intersected with MediaBox and compensate source rotation. Do not supply x/y for an anchor. Out-of-bounds placements return 400. Dimensions and page count remain unchanged; existing form fields are not flattened. Retains the input filename. Optional new fields intentionally have no schema defaults: sending even a default-valued new field opts into the new geometry. See docs/PLACEMENT.md. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. The logo preserves aspect ratio and is centered/fitted inside the region after optional rotation/angle; opacity is retained. Existing width/height/scale/anchor settings cannot accompany region. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md. Release 4.2: optional placement JSON supplies the actual unrotated visible-page object frame and center rotation for exactly one page. Draws the image at exactly the frame width/height; API clients preserve aspect ratio when desired. Optional opacity remains available. Do not combine with region or conflicting raw placement/sizing/scope fields, even when equal to old defaults. Live browser previews do not consume processing operations; this PDF request does.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "logoImage": {
                    "type": "string",
                    "format": "binary",
                    "description": "Optional PNG/JPEG logo; omitted uses bundled Shipwave default."
                  },
                  "x": {
                    "type": "number",
                    "default": 100,
                    "minimum": 0,
                    "description": "PDF points. Legacy: raw unrotated x. Visible custom mode: final rotated visual rectangle bottom-left x relative to the visible page. Forbidden with an anchor position."
                  },
                  "y": {
                    "type": "number",
                    "default": 100,
                    "minimum": 0,
                    "description": "PDF points. Legacy: raw unrotated y. Visible custom mode: final rotated visual rectangle bottom-left y relative to the visible page. Forbidden with an anchor position."
                  },
                  "width": {
                    "type": "number",
                    "default": 100,
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "description": "Positive unrotated logo dimension in PDF points, before uniform scaling and rotation."
                  },
                  "height": {
                    "type": "number",
                    "default": 50,
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "description": "Positive unrotated logo dimension in PDF points, before uniform scaling and rotation."
                  },
                  "position": {
                    "type": "string",
                    "enum": [
                      "custom",
                      "center",
                      "top",
                      "top-left",
                      "top-right",
                      "bottom",
                      "bottom-left",
                      "bottom-right",
                      "left",
                      "right"
                    ],
                    "description": "Opts into visible-page geometry. Default within that mode: custom. Anchor positions use the rotated footprint and margin; custom uses x/y."
                  },
                  "rotation": {
                    "type": "number",
                    "minimum": -360,
                    "maximum": 360,
                    "description": "Counterclockwise angle as seen in the preview. Opts into visible-page geometry; defaults to 0 within that mode. Mutually exclusive with angle."
                  },
                  "angle": {
                    "type": "number",
                    "minimum": -360,
                    "maximum": 360,
                    "description": "Alias for rotation; do not supply both. Opts into visible-page geometry."
                  },
                  "scale": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 10,
                    "description": "Uniform size multiplier. Opts into visible-page geometry; defaults to 1 within that mode."
                  },
                  "opacity": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Image opacity; 0 is completely transparent. Opts into visible-page geometry; defaults to 1 within that mode."
                  },
                  "margin": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1440,
                    "description": "Anchor inset in PDF points; ignored for custom coordinates. Opts into visible-page geometry; defaults to 18 within that mode."
                  },
                  "pages": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Opts into visible-page geometry; omitted means all pages. Other source pages remain present without a logo. Distinct one-based page numbers/ranges, or all; e.g. 1,3-5. At most 1000 selected pages. Repeated, descending, empty or out-of-range selections are rejected.",
                    "example": "1,3-5"
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, position, scale, margin, pages, page (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. The logo preserves aspect ratio and is centered/fitted inside the region after optional rotation/angle; opacity is retained. Existing width/height/scale/anchor settings cannot accompany region.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  },
                  "placement": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFObjectPlacement. Do not combine with region, x, y, width, height, page, pages, position, margin, rotation, angle, scale, placementMode. All rotated frame corners must fit the visible page; source crop/rotation and UserUnit are accounted for. Draws the image at exactly the frame width/height; API clients preserve aspect ratio when desired. Optional opacity remains available.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFObjectPlacement"
                    },
                    "example": "{\"page\":1,\"x\":100,\"y\":400,\"width\":240,\"height\":100,\"rotation\":30,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile"
                ],
                "allOf": [
                  {
                    "not": {
                      "required": [
                        "rotation",
                        "angle"
                      ]
                    }
                  },
                  {
                    "not": {
                      "allOf": [
                        {
                          "required": [
                            "position"
                          ],
                          "properties": {
                            "position": {
                              "enum": [
                                "center",
                                "top",
                                "top-left",
                                "top-right",
                                "bottom",
                                "bottom-left",
                                "bottom-right",
                                "left",
                                "right"
                              ]
                            }
                          }
                        },
                        {
                          "anyOf": [
                            {
                              "required": [
                                "x"
                              ]
                            },
                            {
                              "required": [
                                "y"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "position"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "scale"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "margin"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "placement",
                            "region"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "position"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "margin"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "rotation"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "angle"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "scale"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "placementMode"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              },
              "X-Logo-Type": {
                "schema": {
                  "type": "string"
                },
                "description": "default or custom."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/watermark/add-watermark": {
      "post": {
        "operationId": "post_api_watermark_add_watermark",
        "summary": "Add text watermarks with optional visible-page placement",
        "tags": [
          "Branding"
        ],
        "description": "Helvetica text; image watermarks are not supported. Omitted placementMode or legacy preserves the original raw placement and 50-point edge offsets. placementMode=visible anchors the rotated text footprint inside the visible CropBox intersected with MediaBox, compensates source page rotation, and rejects placements that do not fit with 400. Rotation is counterclockwise. Page selection is available in both modes, retaining unselected source pages. Retains the input filename. See docs/PLACEMENT.md. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Centers the single-line text in the region, compensating source rotation; text shrinks if needed to fit and never grows above the requested fontSize. Font size, text, rotation, opacity and color still apply. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md. Release 4.2: optional placement JSON supplies the actual unrotated visible-page object frame and center rotation for exactly one page. Draws a single-line text watermark in embedded Liberation Sans, uniformly fitted and centered by actual ink bounds in the frame. Width/height determine text size; fontSize/size are forbidden. Text is limited to 2000 supported characters. Text/type/color and existing opacity 0.1–1 remain available. Legacy/region fonts and behavior are unchanged. Do not combine with region or conflicting raw placement/sizing/scope fields, even when equal to old defaults. Live browser previews do not consume processing operations; this PDF request does.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "watermarkText": {
                    "type": "string"
                  },
                  "watermarkType": {
                    "type": "string",
                    "default": "text",
                    "enum": [
                      "text"
                    ]
                  },
                  "position": {
                    "type": "string",
                    "default": "center",
                    "enum": [
                      "center",
                      "top-left",
                      "top-right",
                      "bottom-left",
                      "bottom-right",
                      "top-center",
                      "bottom-center"
                    ]
                  },
                  "opacity": {
                    "type": "number",
                    "default": 0.5,
                    "minimum": 0.1,
                    "maximum": 1
                  },
                  "fontSize": {
                    "type": "number",
                    "default": 24,
                    "minimum": 8,
                    "maximum": 72
                  },
                  "color": {
                    "type": "string",
                    "description": "Omitted: original 50% gray.",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "rotation": {
                    "type": "number",
                    "default": 0,
                    "minimum": -180,
                    "maximum": 180,
                    "description": "Counterclockwise degrees; visible mode compensates the source page rotation."
                  },
                  "placementMode": {
                    "type": "string",
                    "enum": [
                      "legacy",
                      "visible"
                    ],
                    "description": "Omitted means legacy. Set visible explicitly to use bounded visual anchors and source rotation compensation."
                  },
                  "margin": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1440,
                    "description": "Visible-mode anchor inset in PDF points; defaults to 50 in visible mode. Does not change the original legacy offsets."
                  },
                  "pages": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Omitted means all pages. Works in both legacy and visible placement modes. Distinct one-based page numbers/ranges, or all; e.g. 1,3-5. At most 1000 selected pages. Repeated, descending, empty or out-of-range selections are rejected.",
                    "example": "1,3-5"
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with position, margin, pages, page, placementMode (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Centers the single-line text in the region, compensating source rotation; text shrinks if needed to fit and never grows above the requested fontSize. Font size, text, rotation, opacity and color still apply.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  },
                  "placement": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFObjectPlacement. Do not combine with region, x, y, width, height, page, pages, position, margin, rotation, angle, scale, placementMode, size, fontSize. All rotated frame corners must fit the visible page; source crop/rotation and UserUnit are accounted for. Draws a single-line text watermark in embedded Liberation Sans, uniformly fitted and centered by actual ink bounds in the frame. Width/height determine text size; fontSize/size are forbidden. Text is limited to 2000 supported characters. Text/type/color and existing opacity 0.1–1 remain available. Legacy/region fonts and behavior are unchanged.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFObjectPlacement"
                    },
                    "example": "{\"page\":1,\"x\":100,\"y\":400,\"width\":240,\"height\":100,\"rotation\":30,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile",
                  "watermarkText"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "position"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "margin"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "placementMode"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "placement",
                            "region"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "position"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "margin"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "rotation"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "angle"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "scale"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "placementMode"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "size"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "fontSize"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/optimize/compress": {
      "post": {
        "operationId": "post_api_optimize_compress",
        "summary": "Optimize PDF object streams and optional metadata",
        "tags": [
          "Tools"
        ],
        "description": "Compression level controls serialization batching. File-size reduction is not guaranteed; a result may be larger. Retains input filename.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "compressionLevel": {
                    "type": "string",
                    "default": "medium",
                    "enum": [
                      "low",
                      "medium",
                      "high"
                    ]
                  },
                  "imageQuality": {
                    "type": "number",
                    "default": 75,
                    "minimum": 10,
                    "maximum": 100,
                    "description": "Compatibility parameter; this lossless optimizer does not recompress images."
                  },
                  "removeAnnotations": {
                    "type": "boolean",
                    "default": false
                  },
                  "removeBookmarks": {
                    "type": "boolean",
                    "default": false
                  },
                  "removeMetadata": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              },
              "X-Original-Size": {
                "schema": {
                  "type": "string"
                },
                "description": "Original bytes."
              },
              "X-Compressed-Size": {
                "schema": {
                  "type": "string"
                },
                "description": "Output bytes."
              },
              "X-Compression-Ratio": {
                "schema": {
                  "type": "string"
                },
                "description": "Size reduction percentage; may be negative."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/super-grid": {
      "post": {
        "operationId": "post_api_tools_super_grid",
        "summary": "Add coordinate grid to every page",
        "tags": [
          "Tools"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Original light-gray grid, coordinate labels and origin/corner markers. Retains input filename.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "gridSize": {
                    "type": "number",
                    "default": 50,
                    "minimum": 5,
                    "maximum": 1000
                  },
                  "showLabels": {
                    "type": "boolean",
                    "default": true
                  },
                  "lineWidth": {
                    "type": "number",
                    "default": 0.5,
                    "minimum": 0.001,
                    "maximum": 10
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pdf/analyze": {
      "post": {
        "operationId": "post_api_pdf_analyze",
        "summary": "Inspect PDF fields, page dimensions and text blocks",
        "tags": [
          "Editing"
        ],
        "description": "Returns a temporary fileId for editing plus documentInfo, pages, formFields, textContent, editableCount and textBlockCount. Extracted text positions are approximate and text blocks retain page=1 from the original extractor. Not OCR.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "default": true
                    },
                    "fileId": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "documentInfo": {
                      "type": "object",
                      "properties": {
                        "pageCount": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "author": {
                          "type": "string"
                        },
                        "subject": {
                          "type": "string"
                        },
                        "creator": {
                          "type": "string"
                        },
                        "hasForm": {
                          "type": "boolean",
                          "default": false
                        },
                        "isEncrypted": {
                          "type": "boolean",
                          "default": false
                        }
                      }
                    },
                    "pages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "pageNumber": {
                            "type": "integer"
                          },
                          "width": {
                            "type": "number"
                          },
                          "height": {
                            "type": "number"
                          },
                          "rotation": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "formFields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "value": {},
                          "isReadOnly": {
                            "type": "boolean",
                            "default": false
                          },
                          "isRequired": {
                            "type": "boolean",
                            "default": false
                          },
                          "position": {
                            "type": "object",
                            "properties": {
                              "x": {
                                "type": "number",
                                "minimum": 0
                              },
                              "y": {
                                "type": "number",
                                "minimum": 0
                              },
                              "width": {
                                "type": "number",
                                "minimum": 0.001
                              },
                              "height": {
                                "type": "number",
                                "minimum": 0.001
                              }
                            },
                            "required": [
                              "x",
                              "y",
                              "width",
                              "height"
                            ]
                          },
                          "page": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "textContent": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "preview": {
                            "type": "string"
                          },
                          "charCount": {
                            "type": "integer"
                          },
                          "page": {
                            "type": "integer",
                            "default": 1
                          }
                        }
                      }
                    },
                    "editableCount": {
                      "type": "integer"
                    },
                    "textBlockCount": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pdf/edit": {
      "post": {
        "operationId": "post_api_pdf_edit",
        "summary": "Fill form fields, overlay text and cover/replace visible text",
        "tags": [
          "Editing"
        ],
        "description": "PDF points measured from the bottom-left, 72 per inch. At least one edit required. Covers are visual, not secure redaction. Retains source filename. If any requested edit fails, returns HTTP 422 with no output PDF; successful responses report zero errors.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "Supply this or fileId."
                  },
                  "fileId": {
                    "type": "string",
                    "description": "Temporary analysis ID, consumed after an edit."
                  },
                  "edits": {
                    "type": "string",
                    "description": "JSON string matching PdfEdits."
                  },
                  "formEdits": {
                    "type": "string",
                    "description": "Alternative JSON array of {fieldName,value}."
                  },
                  "textOverlays": {
                    "type": "string",
                    "description": "Alternative JSON array matching PdfEdits.textOverlays."
                  },
                  "textReplacements": {
                    "type": "string",
                    "description": "Alternative JSON array matching PdfEdits.textReplacements."
                  },
                  "flattenForm": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileId": {
                    "type": "string"
                  },
                  "edits": {
                    "$ref": "#/components/schemas/PdfEdits"
                  }
                },
                "required": [
                  "fileId",
                  "edits"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              },
              "X-Form-Fields-Updated": {
                "schema": {
                  "type": "string"
                },
                "description": "Successful form edit count."
              },
              "X-Text-Overlays-Added": {
                "schema": {
                  "type": "string"
                },
                "description": "Successful overlay/replacement count."
              },
              "X-Edit-Errors": {
                "schema": {
                  "type": "string"
                },
                "description": "Individual error count."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "A requested edit could not be applied. No output PDF.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pdf/replace-text": {
      "post": {
        "operationId": "post_api_pdf_replace_text",
        "summary": "Cover an area and draw replacement text",
        "tags": [
          "Editing"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Draws white cover, then black Helvetica at x+2,y+4. Cosmetic replacement, not underlying text removal. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Covers the exact region in white, then fits the single-line newText in black Helvetica from the viewed bottom-left. This is cosmetic, not secure redaction. fontSize remains 6–72. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "page": {
                    "type": "integer",
                    "default": 1,
                    "minimum": 1
                  },
                  "x": {
                    "type": "number",
                    "minimum": 0
                  },
                  "y": {
                    "type": "number",
                    "minimum": 0
                  },
                  "width": {
                    "type": "number",
                    "default": 200,
                    "minimum": 0.001
                  },
                  "height": {
                    "type": "number",
                    "default": 20,
                    "minimum": 0.001
                  },
                  "newText": {
                    "type": "string"
                  },
                  "fontSize": {
                    "type": "number",
                    "default": 12,
                    "minimum": 6,
                    "maximum": 72
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, page, pages (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Covers the exact region in white, then fits the single-line newText in black Helvetica from the viewed bottom-left. This is cosmetic, not secure redaction. fontSize remains 6–72.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile",
                  "newText"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "anyOf": [
                      {
                        "required": [
                          "region"
                        ]
                      },
                      {
                        "required": [
                          "x",
                          "y"
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "A requested edit could not be applied. No output PDF.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pdf/fill-form": {
      "post": {
        "operationId": "post_api_pdf_fill_form",
        "summary": "Fill form fields by name",
        "tags": [
          "Editing"
        ],
        "description": "Retains filename. Forms remain interactive unless flatten=true. If any field edit fails, returns HTTP 422 with no output PDF.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "formData": {
                    "type": "string",
                    "description": "JSON object mapping field names to string/boolean/number values."
                  },
                  "flatten": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "pdfFile",
                  "formData"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              },
              "X-Fields-Updated": {
                "schema": {
                  "type": "string"
                },
                "description": "Successful field count."
              },
              "X-Errors": {
                "schema": {
                  "type": "string"
                },
                "description": "none, or semicolon-separated error descriptions."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "A requested edit could not be applied. No output PDF.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/remove-logo": {
      "post": {
        "operationId": "post_remove_logo",
        "summary": "Legacy white logo cover on all pages",
        "tags": [
          "Legacy"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Original integer coordinate defaults retained; explicit zero is accepted. Upload limit 10 MiB per file. Debug outline is 1 point. Output: logo-removed.pdf. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Covers the exact region in white on its selected page. Visual covering is not secure redaction. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "x": {
                    "type": "integer",
                    "default": 125
                  },
                  "y": {
                    "type": "integer",
                    "default": 450
                  },
                  "width": {
                    "type": "integer",
                    "default": 100,
                    "minimum": 1
                  },
                  "height": {
                    "type": "integer",
                    "default": 25,
                    "minimum": 1
                  },
                  "debug": {
                    "type": "boolean",
                    "default": false
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, page, pages (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Covers the exact region in white on its selected page. Visual covering is not secure redaction.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdf"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/super-grid": {
      "post": {
        "operationId": "post_super_grid",
        "summary": "Legacy detailed grid on the first page",
        "tags": [
          "Legacy"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Original integer coordinate defaults retained; explicit zero is accepted. Upload limit 10 MiB per file. Original 10-point grid, 50-point major lines and 25-point labels. Remaining pages unchanged. Output: super-grid.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  }
                },
                "required": [
                  "pdf"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/a4-to-thermal": {
      "post": {
        "operationId": "post_a4_to_thermal",
        "summary": "Convert A4 to thermal with optional viewed-half crop and rotation",
        "tags": [
          "Labels"
        ],
        "description": "Upload field pdf; 10 MiB per file; output thermal-label.pdf. If cropPreset, rotation, outputOrientation, allPages and pages are all absent, retains the historical first-page crop offset formula unchanged: integer-parsed cropX/Y/Width/Height defaults 0/0/400/600 and 288 × 432 point output, without a new clipping boundary. Supplying any new field enables exact clipping, clockwise rotation after cropping, and proportional centered fitting. Presets select the viewed visible page, including source rotation. New custom coordinates use the unrotated visible bottom-left and must fit CropBox intersected with MediaBox. New mode flattens source form appearances and rebuilds pages without interactive annotations or links. Crop is a layout operation, not secure redaction; embedded source objects may remain. New optional fields intentionally have no schema defaults so older requests do not opt into a different crop formula. See docs/PLACEMENT.md. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Clips the chosen source-page region, applies the selected additional clockwise rotation, and fits/centers it in portrait or landscape thermal output. Unlike editing routes, output contains only this selected page. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "cropX": {
                    "type": "number",
                    "default": 0,
                    "description": "Offset in PDF points. Legacy mode parses integer coordinates. New custom mode accepts fractional points, requires a nonnegative value at most 14400 and a rectangle fitting the unrotated visible page. Ignored by non-custom crop presets."
                  },
                  "cropY": {
                    "type": "number",
                    "default": 0,
                    "description": "Offset in PDF points. Legacy mode parses integer coordinates. New custom mode accepts fractional points, requires a nonnegative value at most 14400 and a rectangle fitting the unrotated visible page. Ignored by non-custom crop presets."
                  },
                  "cropWidth": {
                    "type": "number",
                    "default": 400,
                    "minimum": 0,
                    "description": "Positive size in PDF points. Legacy mode parses integer coordinates. New custom mode accepts fractional points, requires a positive value at most 14400 and a rectangle fitting the unrotated visible page. Ignored by non-custom crop presets.",
                    "exclusiveMinimum": true
                  },
                  "cropHeight": {
                    "type": "number",
                    "default": 600,
                    "minimum": 0,
                    "description": "Positive size in PDF points. Legacy mode parses integer coordinates. New custom mode accepts fractional points, requires a positive value at most 14400 and a rectangle fitting the unrotated visible page. Ignored by non-custom crop presets.",
                    "exclusiveMinimum": true
                  },
                  "cropPreset": {
                    "type": "string",
                    "enum": [
                      "custom",
                      "top-half",
                      "bottom-half",
                      "left-half",
                      "right-half",
                      "full"
                    ],
                    "description": "Opts into exact crop geometry. Default in that mode: custom. Half-page and full presets use viewed visible-page axes, including source rotation; raw crop fields do not affect presets."
                  },
                  "rotation": {
                    "type": "integer",
                    "enum": [
                      0,
                      90,
                      180,
                      270
                    ],
                    "description": "Clockwise quarter-turn AFTER cropping, additional to source rotation. Opts into exact crop geometry; default within that mode: 0."
                  },
                  "outputOrientation": {
                    "type": "string",
                    "enum": [
                      "portrait",
                      "landscape"
                    ],
                    "description": "Opts into exact crop geometry. Default in that mode: portrait (288 × 432 points); landscape produces 432 × 288 points."
                  },
                  "allPages": {
                    "type": "boolean",
                    "description": "Opts into exact crop geometry. Default within that mode: false (first page only); true selects all source pages, up to 100. Explicit pages overrides this field."
                  },
                  "pages": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Opts into exact crop geometry. Explicit selection overrides allPages and retains the specified order. Omitted: first page unless allPages=true. Distinct one-based page numbers/ranges, or all; e.g. 1,3-5. At most 100 selected pages. Repeated, descending, empty or out-of-range selections are rejected.",
                    "example": "1,3-5"
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with cropPreset, cropX, cropY, cropWidth, cropHeight, allPages, pages, page (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Clips the chosen source-page region, applies the selected additional clockwise rotation, and fits/centers it in portrait or landscape thermal output. Unlike editing routes, output contains only this selected page.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdf"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "cropPreset"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "cropX"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "cropY"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "cropWidth"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "cropHeight"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "allPages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/add-logo": {
      "post": {
        "operationId": "post_add_logo",
        "summary": "Legacy custom logo placement on all pages",
        "tags": [
          "Legacy"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Original integer coordinate defaults retained; explicit zero is accepted. Upload limit 10 MiB per file. Output: logo-added.pdf. This route requires a custom logo and retains different defaults from /api/logo/add. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. The required custom logo preserves aspect ratio and is centered/fitted inside the region on its selected page. This legacy route does not add new rotation/opacity options. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "logo": {
                    "type": "string",
                    "format": "binary",
                    "description": "Required PNG/JPEG logo."
                  },
                  "x": {
                    "type": "integer",
                    "default": 50
                  },
                  "y": {
                    "type": "integer",
                    "default": 500
                  },
                  "width": {
                    "type": "integer",
                    "default": 100,
                    "minimum": 1
                  },
                  "height": {
                    "type": "integer",
                    "default": 50,
                    "minimum": 1
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, position, scale, margin, pages, page (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. The required custom logo preserves aspect ratio and is centered/fitted inside the region on its selected page. This legacy route does not add new rotation/opacity options.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdf",
                  "logo"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "position"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "scale"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "margin"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/add-text": {
      "post": {
        "operationId": "post_add_text",
        "summary": "Legacy Helvetica text on all pages",
        "tags": [
          "Legacy"
        ],
        "description": "PDF points from the bottom-left; 72 points = 1 inch. Original integer coordinate defaults retained; explicit zero is accepted. Upload limit 10 MiB per file. Text must use Helvetica/WinAnsi characters. Output: text-added.pdf. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Places one single line in the region from its viewed bottom-left and shrinks the requested size if needed. Helvetica/WinAnsi still applies; the rest of the document is unchanged. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md. Release 4.2: optional placement JSON supplies the actual unrotated visible-page object frame and center rotation for exactly one page. Draws a single line in embedded Liberation Sans, uniformly fitted and centered by actual ink bounds in the frame. Width/height determine text size; size/fontSize are forbidden. Text supports the embedded font glyphs and is limited to 2000 characters; named colors or #RRGGBB and opacity 0–1 are available. Legacy/region Helvetica behavior is unchanged. Do not combine with region or conflicting raw placement/sizing/scope fields, even when equal to old defaults. Live browser previews do not consume processing operations; this PDF request does.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "text": {
                    "type": "string",
                    "default": "Sample Text",
                    "description": "Original default retained. With placement: nonempty single line, at most 2000 supported embedded Liberation Sans characters."
                  },
                  "x": {
                    "type": "integer",
                    "default": 50
                  },
                  "y": {
                    "type": "integer",
                    "default": 500
                  },
                  "size": {
                    "type": "integer",
                    "default": 12,
                    "minimum": 1
                  },
                  "color": {
                    "type": "string",
                    "default": "black",
                    "anyOf": [
                      {
                        "enum": [
                          "black",
                          "red",
                          "blue",
                          "green"
                        ]
                      },
                      {
                        "pattern": "^#[0-9A-Fa-f]{6}$"
                      }
                    ],
                    "description": "Legacy and region accept black/red/blue/green only. placement additionally accepts #RRGGBB."
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, page, pages (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Places one single line in the region from its viewed bottom-left and shrinks the requested size if needed. Helvetica/WinAnsi still applies; the rest of the document is unchanged.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  },
                  "placement": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFObjectPlacement. Do not combine with region, x, y, width, height, page, pages, position, margin, rotation, angle, scale, placementMode, size, fontSize. All rotated frame corners must fit the visible page; source crop/rotation and UserUnit are accounted for. Draws a single line in embedded Liberation Sans, uniformly fitted and centered by actual ink bounds in the frame. Width/height determine text size; size/fontSize are forbidden. Text supports the embedded font glyphs and is limited to 2000 characters; named colors or #RRGGBB and opacity 0–1 are available. Legacy/region Helvetica behavior is unchanged.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFObjectPlacement"
                    },
                    "example": "{\"page\":1,\"x\":100,\"y\":400,\"width\":240,\"height\":100,\"rotation\":30,\"coordinateSpace\":\"visible\"}"
                  },
                  "opacity": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "default": 1,
                    "description": "Optional opacity for placement, default 1 in that mode. Omitted placement retains legacy/region behavior, where this unsupported setting has no effect."
                  }
                },
                "required": [
                  "pdf"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "placement",
                            "region"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "position"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "margin"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "rotation"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "angle"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "scale"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "placementMode"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "size"
                          ]
                        },
                        {
                          "required": [
                            "placement",
                            "fontSize"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/merge-pdfs": {
      "post": {
        "operationId": "post_merge_pdfs",
        "summary": "Legacy complete PDF merge",
        "tags": [
          "Legacy"
        ],
        "description": "Concatenates pages in upload order; 10 MiB per file. Output: merged.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfs": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary",
                      "description": "PDF file"
                    },
                    "minItems": 2,
                    "maxItems": 50
                  }
                },
                "required": [
                  "pdfs"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/split-pdf": {
      "post": {
        "operationId": "post_split_pdf",
        "summary": "Legacy extract a single numbered page",
        "tags": [
          "Legacy"
        ],
        "description": "Page is 1-based. Output: page-<number>.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  },
                  "page": {
                    "type": "integer",
                    "default": 1,
                    "minimum": 1
                  }
                },
                "required": [
                  "pdf"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/image-to-pdf": {
      "post": {
        "operationId": "post_image_to_pdf",
        "summary": "Legacy centered PNG/JPEG conversion",
        "tags": [
          "Legacy"
        ],
        "description": "Proportionally contains image with no margin. Thermal is 288 x 432 points. Output: image-converted.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "PNG/JPEG image."
                  },
                  "format": {
                    "type": "string",
                    "default": "A4",
                    "enum": [
                      "A4",
                      "Letter",
                      "thermal"
                    ]
                  }
                },
                "required": [
                  "image"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/html-to-pdf": {
      "post": {
        "operationId": "post_html_to_pdf",
        "summary": "Legacy plain-text extraction of HTML",
        "tags": [
          "Legacy"
        ],
        "description": "Strips tags and decodes basic entities; renders one A4 page using Helvetica 12, x50 and initial y=height-50, 20-point line spacing. Content below the margin is omitted. Does not render HTML/CSS. Use main HTML endpoints for full rendering. Output: html-converted.pdf.",
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "PDF file"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested attachment filename."
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "text/html": {
              "schema": {
                "type": "string"
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "html": {
                    "type": "string"
                  }
                },
                "required": [
                  "html"
                ]
              }
            }
          }
        }
      }
    },
    "/pdf-info": {
      "post": {
        "operationId": "post_pdf_info",
        "summary": "Legacy PDF dimensions and file-size information",
        "tags": [
          "Legacy"
        ],
        "description": "Returns pageCount, pages[{pageNumber,width,height,sizeInInches:{width,height}}], fileSize bytes and fileSizeMB string.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file"
                  }
                },
                "required": [
                  "pdf"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "get_health",
        "summary": "Application liveness and status",
        "tags": [
          "Service"
        ],
        "description": "Public Railway health check. Conversion checks should use representative requests or the smoke suite.",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit reached, when enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "get_api_health",
        "summary": "Application liveness and status",
        "tags": [
          "Service"
        ],
        "description": "Public Railway health check. Conversion checks should use representative requests or the smoke suite.",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit reached, when enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ping": {
      "get": {
        "operationId": "get_ping",
        "summary": "Simple liveness ping",
        "tags": [
          "Service"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit reached, when enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/info": {
      "get": {
        "operationId": "get_api_info",
        "summary": "Thermal conversion API metadata and A4 dimensions",
        "tags": [
          "Service"
        ],
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit reached, when enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/options": {
      "get": {
        "operationId": "get_api_options",
        "summary": "Main HTML conversion options",
        "tags": [
          "Service"
        ],
        "responses": {
          "200": {
            "description": "Successful response. File responses include a suggested filename in Content-Disposition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload or body exceeds configured limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit reached, when enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PDF processing or conversion engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/rotate": {
      "post": {
        "operationId": "post_api_tools_rotate",
        "summary": "Rotate selected PDF pages",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. Adds the angle to existing rotation, retaining page order and count. Output: <input>_rotated.pdf.",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "1-based page list with ascending ranges, e.g. 1,3-5,2. Duplicate selectors rejected except the pages arrangement route. Modifier operations retain source order and page count."
                  },
                  "angle": {
                    "type": "integer",
                    "default": 90,
                    "enum": [
                      90,
                      180,
                      270,
                      -90
                    ]
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/resize": {
      "post": {
        "operationId": "post_api_tools_resize",
        "summary": "Resize selected pages with contain, cover or stretch",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. Default physical output 4 x 6 inches, regardless of unit. Rebuilds selected pages using their visible crop and rotation, preserving vector appearance. Flattens ALL form appearances, even on unselected pages. Selected rebuilt pages discard interactive links/annotations. Unselected page sizes and order remain. Output: <input>_resized.pdf.",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "1-based page list with ascending ranges, e.g. 1,3-5,2. Duplicate selectors rejected except the pages arrangement route. Modifier operations retain source order and page count."
                  },
                  "unit": {
                    "type": "string",
                    "default": "pt",
                    "enum": [
                      "pt",
                      "mm",
                      "in"
                    ]
                  },
                  "width": {
                    "type": "number",
                    "default": 288,
                    "description": "Default physical width is 288 pt / 101.6 mm / 4 in according to unit. Supplied values must convert to 1-14400 PDF points."
                  },
                  "height": {
                    "type": "number",
                    "default": 432,
                    "description": "Default physical height is 432 pt / 152.4 mm / 6 in according to unit. Supplied values must convert to 1-14400 PDF points."
                  },
                  "fit": {
                    "type": "string",
                    "default": "contain",
                    "enum": [
                      "contain",
                      "cover",
                      "stretch"
                    ]
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/crop": {
      "post": {
        "operationId": "post_api_tools_crop",
        "summary": "Set the visible crop area on selected pages",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. Crop rectangle must fit every selected page. Sets a visibility box; does not remove underlying content or provide secure redaction. Default physical crop size is 4 x 6 inches. Output: <input>_cropped.pdf. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Converts the selected visible rectangle to the page native CropBox. This only changes visibility and is not secure redaction. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "1-based page list with ascending ranges, e.g. 1,3-5,2. Duplicate selectors rejected except the pages arrangement route. Modifier operations retain source order and page count."
                  },
                  "unit": {
                    "type": "string",
                    "default": "pt",
                    "enum": [
                      "pt",
                      "mm",
                      "in"
                    ]
                  },
                  "x": {
                    "type": "number",
                    "default": 0,
                    "minimum": 0,
                    "description": "Relative to media-box bottom-left in unrotated PDF coordinates; maximum 14400 pt after conversion."
                  },
                  "y": {
                    "type": "number",
                    "default": 0,
                    "minimum": 0,
                    "description": "Relative to media-box bottom-left in unrotated PDF coordinates; maximum 14400 pt after conversion."
                  },
                  "width": {
                    "type": "number",
                    "default": 288,
                    "description": "Default physical width is 288 pt / 101.6 mm / 4 in according to unit. Supplied values must convert to 1-14400 PDF points."
                  },
                  "height": {
                    "type": "number",
                    "default": 432,
                    "description": "Default physical height is 432 pt / 152.4 mm / 6 in according to unit. Supplied values must convert to 1-14400 PDF points."
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, pages, page, unit (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Converts the selected visible rectangle to the page native CropBox. This only changes visibility and is not secure redaction.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "unit"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/pages": {
      "post": {
        "operationId": "post_api_tools_pages",
        "summary": "Reorder, duplicate, extract or omit PDF pages",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. Produces a new document in the exact supplied page order. Unlisted pages omitted. Flattens all form appearances before copying or repeating pages: visible values are retained as read-only content without interactive form widgets. Output: <input>_pages.pdf.",
        "tags": [
          "Organization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "1-based comma-separated page list/ranges, e.g. 3,1,1,5-6. Exact order retained and repeated pages permitted. Maximum 2000 output pages."
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/page-numbers": {
      "post": {
        "operationId": "post_api_tools_page_numbers",
        "summary": "Add page numbers to selected pages",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. Selected pages are numbered in source order, incrementing from start. Example pages=2,4 and start=10 gives 10 / 2, 11 / 2 with default template. Helvetica text and margins must fit each selected crop box. Output: <input>_numbered.pdf. Placement follows each page’s visible rotation.",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "1-based page list with ascending ranges, e.g. 1,3-5,2. Duplicate selectors rejected except the pages arrangement route. Modifier operations retain source order and page count."
                  },
                  "start": {
                    "type": "integer",
                    "default": 1,
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "fontSize": {
                    "type": "number",
                    "default": 10,
                    "minimum": 6,
                    "maximum": 72
                  },
                  "margin": {
                    "type": "number",
                    "default": 24,
                    "minimum": 0,
                    "maximum": 1000,
                    "description": "Points from the crop-box edges."
                  },
                  "position": {
                    "type": "string",
                    "default": "bottom-center",
                    "enum": [
                      "bottom-center",
                      "bottom-left",
                      "bottom-right",
                      "top-center",
                      "top-left",
                      "top-right"
                    ]
                  },
                  "color": {
                    "type": "string",
                    "default": "#64748b",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "format": {
                    "type": "string",
                    "default": "{page} / {total}",
                    "description": "Must include {page}; {total} is the selected-page count. Other placeholders rejected.",
                    "maxLength": 200
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/metadata": {
      "post": {
        "operationId": "post_api_tools_metadata",
        "summary": "Update or clear document metadata",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. clear=true removes metadata, then applies explicit fields. Does not remove document content, annotations or attachments. Output: <input>_metadata.pdf.",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "clear": {
                    "type": "boolean",
                    "default": false,
                    "description": "Remove Info dictionary entries and XMP before applying supplied fields."
                  },
                  "title": {
                    "type": "string",
                    "description": "Optional text; omitted values preserved, empty string clears the field.",
                    "maxLength": 10000
                  },
                  "author": {
                    "type": "string",
                    "description": "Optional text; omitted values preserved, empty string clears the field.",
                    "maxLength": 10000
                  },
                  "subject": {
                    "type": "string",
                    "description": "Optional text; omitted values preserved, empty string clears the field.",
                    "maxLength": 10000
                  },
                  "creator": {
                    "type": "string",
                    "description": "Optional text; omitted values preserved, empty string clears the field.",
                    "maxLength": 10000
                  },
                  "keywords": {
                    "type": "string",
                    "description": "Comma-separated text, maximum 10000 characters. Empty string clears keywords.",
                    "maxLength": 10000
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/images-to-pdf": {
      "post": {
        "operationId": "post_api_convert_images_to_pdf",
        "summary": "Combine image files into a multipage PDF",
        "description": "Maximum 100 MiB combined upload. One page per image in upload order; proportional contain/center. EXIF orientation applied. GIF/TIFF first frame/page only. Thermal is 288 x 432 pt; image format derives dimensions from image DPI (72 fallback), adds margins, then enforces selected orientation. Resulting page dimensions 1-14400 pt. Output: <first-image-name>_images.pdf.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary",
                      "description": "PNG/JPEG/WebP/TIFF/GIF; maximum 20 MiB per file and 50 million pixels."
                    },
                    "minItems": 1,
                    "maxItems": 20
                  },
                  "format": {
                    "type": "string",
                    "default": "A4",
                    "enum": [
                      "A4",
                      "Letter",
                      "thermal",
                      "image"
                    ]
                  },
                  "orientation": {
                    "type": "string",
                    "default": "portrait",
                    "enum": [
                      "portrait",
                      "landscape"
                    ]
                  },
                  "margin": {
                    "type": "number",
                    "default": 0,
                    "minimum": 0,
                    "maximum": 1000,
                    "description": "PDF points; must leave room for image."
                  }
                },
                "required": [
                  "images"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/pdf-to-images": {
      "post": {
        "operationId": "post_api_convert_pdf_to_images",
        "summary": "Export selected PDF pages as PNG/JPEG ZIP",
        "description": "Upload an unencrypted PDF of at most 50 MiB and 2000 source pages. Always ZIP, even one selected page. Original page numbers in filenames: page-001.png or page-003.jpg. Rendering respects visible area and rotation. Limits: 20 million pixels per page, 100 million total, 100 MiB ZIP, 90-second timeout. Output: <input>_images.zip.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "1-based page list/ranges. Maximum 100 selected pages, no duplicates."
                  },
                  "format": {
                    "type": "string",
                    "default": "png",
                    "enum": [
                      "png",
                      "jpeg"
                    ]
                  },
                  "dpi": {
                    "type": "integer",
                    "default": 150,
                    "minimum": 72,
                    "maximum": 300
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/security/protect": {
      "post": {
        "operationId": "post_api_security_protect",
        "summary": "Encrypt PDF with an AES-256 opening password",
        "description": "Maximum 50 MiB, 1-500 pages and 60 seconds. Input must be unencrypted; unlock first if necessary. Opening password encrypts content; PDF viewers enforce permission flags. Accessibility/form filling remain allowed. Output: <input>-protected.pdf.",
        "tags": [
          "Security"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "password": {
                    "type": "string",
                    "description": "Required document password, 1-40 characters.",
                    "minLength": 1,
                    "maxLength": 40,
                    "format": "password"
                  },
                  "ownerPassword": {
                    "type": "string",
                    "description": "Optional owner password, 1-40 characters. An empty string is treated as omitted; omitted/empty generates a random owner password that is not returned.",
                    "minLength": 0,
                    "maxLength": 40,
                    "format": "password"
                  },
                  "allowPrinting": {
                    "type": "boolean",
                    "default": true
                  },
                  "allowCopying": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "pdfFile",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/security/unlock": {
      "post": {
        "operationId": "post_api_security_unlock",
        "summary": "Remove PDF encryption using a valid supplied password",
        "description": "Maximum 50 MiB, 1-500 pages and 60 seconds. Authenticate with a valid opening or owner password; wrong passwords return error. Already unencrypted input accepted and remains unencrypted. Does not recover unknown passwords. Output: <input>-unlocked.pdf.",
        "tags": [
          "Security"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB"
                  },
                  "password": {
                    "type": "string",
                    "description": "Required document password, 1-40 characters.",
                    "minLength": 1,
                    "maxLength": 40,
                    "format": "password"
                  }
                },
                "required": [
                  "pdfFile",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/qr": {
      "post": {
        "operationId": "post_api_tools_qr",
        "summary": "Generate a vector PDF or PNG QR code",
        "description": "No source PDF required. PDF output is a square vector QR page; PNG uses requested pixel size. A four-module quiet zone is always retained. Rejects unencodable size/payload combinations. Output: shipwave-qr.pdf or shipwave-qr.png.",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "Text/URL payload encoded exactly as supplied.",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "format": {
                    "type": "string",
                    "default": "pdf",
                    "enum": [
                      "pdf",
                      "png"
                    ]
                  },
                  "size": {
                    "type": "integer",
                    "default": 288,
                    "minimum": 96,
                    "maximum": 2048,
                    "description": "PDF page points or PNG pixels."
                  },
                  "margin": {
                    "type": "number",
                    "default": 18,
                    "minimum": 0,
                    "maximum": 500,
                    "description": "Requested minimum padding; must be less than size/2. Actual padding ensures at least four quiet-zone modules."
                  },
                  "errorCorrection": {
                    "type": "string",
                    "default": "M",
                    "enum": [
                      "L",
                      "M",
                      "Q",
                      "H"
                    ]
                  }
                },
                "required": [
                  "text"
                ]
              },
              "example": {
                "text": "https://example.com/track/123",
                "format": "pdf",
                "size": 288,
                "margin": 18,
                "errorCorrection": "M"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful binary download.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary output file"
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, password or options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds size limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Page, image or rendering limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required processing engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/repair": {
      "post": {
        "summary": "Repair and clean a recoverable PDF",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. MuPDF reconstructs recoverable cross-reference data; garbage4,clean,deflate; complete document. Output _repaired.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-PDF-Repaired": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_tools_repair"
      }
    },
    "/api/tools/redact": {
      "post": {
        "summary": "Permanently redact PDF page content",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. Provide text and/or rectangles. Actual apply_redactions removes underlying text,covered image pixels and intersecting vector content; garbage collection removes unused streams. Unselected pages retained. No matches without rectangles:422. Rectangle coordinates: unrotated media-box bottom-left PDF points, must fit visible page. Does not remove unrelated metadata/attachments. Output _redacted.pdf. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Permanently redacts the exact region through the existing redaction engine; do not also supply text or rectangles. Unselected pages remain present. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  },
                  "text": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "rectangles": {
                    "type": "string",
                    "description": "JSON array,max500 entries: [{\"page\":1,\"x\":30,\"y\":40,\"width\":80,\"height\":80}]; rectangle pages must be selected."
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with text, rectangles, pages, page, x, y, width, height (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Permanently redacts the exact region through the existing redaction engine; do not also supply text or rectangles. Unselected pages remain present.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile"
                ],
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "text"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "rectangles"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Redaction-Regions": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Redaction-Text-Matches": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Redaction-Pages": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_tools_redact"
      }
    },
    "/api/tools/compare": {
      "post": {
        "summary": "Compare PDF visual appearance and extracted text",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. At most20 selected pages over union of page counts. ZIP contains A/B/red-diff PNGs and summary.json with dimensions,changed pixels,text differences,changed pages. Missing pages treated as blank. Rendering20M pixels/page,100Mtotal. Output _comparison.zip.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfA": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pdfB": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  },
                  "dpi": {
                    "type": "integer",
                    "default": 96,
                    "minimum": 72,
                    "maximum": 150
                  }
                },
                "required": [
                  "pdfA",
                  "pdfB"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Compared-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Changed-Pages": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_tools_compare"
      }
    },
    "/api/convert/pdf-to-word": {
      "post": {
        "summary": "Extract editable Unicode PDF text to Word",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. DOCX with editable text paragraphs and source-sized sections per selected page; paragraphs may reflow. Does not recreate images,barcodes or complex layout. Image-only pages need OCR. Output _editable.docx.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Converted-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Text-Empty-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Conversion-Warnings": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_convert_pdf_to_word"
      }
    },
    "/api/convert/pdf-to-excel": {
      "post": {
        "summary": "Extract PDF tables and fallback text to Excel",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. Detected tables become Page N Table K sheets. Other pages have indexed lines in Text; Summary identifies extraction. Literal strings prevent formula injection. Limit500000cells. Output _tables.xlsx.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Converted-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Extracted-Tables": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_convert_pdf_to_excel"
      }
    },
    "/api/convert/pdf-to-powerpoint": {
      "post": {
        "summary": "Convert PDF pages to slide images",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. PPTX has one page image per selected page. First page defines deck aspect; others fit proportionally. Image text is not independently editable. Rendering20M pixels/page,100Mtotal. Output _slides.pptx.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  },
                  "dpi": {
                    "type": "integer",
                    "default": 120,
                    "minimum": 72,
                    "maximum": 150
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Converted-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Conversion-Warnings": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_convert_pdf_to_powerpoint"
      }
    },
    "/api/convert/pdf-to-markdown": {
      "post": {
        "summary": "Extract PDF reading-order text and tables to Markdown",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. UTF-8 text with Page N headings; optional detected Markdown tables appended. Image-only pages need OCR. Output _text.md.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  },
                  "tables": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Converted-Pages": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_convert_pdf_to_markdown"
      }
    },
    "/api/tools/ocr": {
      "post": {
        "summary": "Add searchable OCR text while preserving original appearance",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. Tesseract invisible text overlay on original PDF; source page vectors and images retained. Skips text pages unless force=true. Installed languages only,eng default. Configure TESSERACT_BIN/TESSDATA_PREFIX. Rendering20M pixels/page,100Mtotal. Output _searchable.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  },
                  "pages": {
                    "type": "string",
                    "default": "all",
                    "description": "Distinct one-based pages/ranges such as1,3-5. Maximum100 selected pages unless noted."
                  },
                  "language": {
                    "type": "string",
                    "default": "eng",
                    "example": "eng+fra"
                  },
                  "dpi": {
                    "type": "integer",
                    "default": 150,
                    "minimum": 72,
                    "maximum": 300
                  },
                  "force": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-OCR-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-OCR-Skipped-Pages": {
                "schema": {
                  "type": "string"
                }
              },
              "X-OCR-Language": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_tools_ocr"
      }
    },
    "/api/convert/pdf-to-pdfa": {
      "post": {
        "summary": "Generate a PDF/A-2b candidate and validate when available",
        "tags": [
          "Conversion"
        ],
        "description": "50MiB per file,1-100 source pages,100MiB output,120-second worker timeout. Shared authentication. Complete document only. Ghostscript PDF/A2 with sRGB output intent and XMP. GS_BIN and sRGB profile required. X-PDFA-Validated=true only when veraPDF confirms2b. No validator:false plus warning; failed validator:422. Never claims unverified conformance. Output _pdfa-2b.pdf.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted binary output",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-PDFA-Validated": {
                "schema": {
                  "type": "string"
                }
              },
              "X-PDFA-Profile": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Conversion-Warnings": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload exceeds limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Cannot convert, no matches, or resource limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "Required engine, language or dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_api_convert_pdf_to_pdfa"
      }
    },
    "/api/ai/run": {
      "post": {
        "operationId": "post_api_ai_run",
        "summary": "Run an explicitly requested AI document task",
        "tags": [
          "AI"
        ],
        "description": "Calls a server-configured OpenAI-compatible Chat Completions provider only after this operation is invoked. Sends extracted source text, not the original PDF binary. No API key:503 setup guidance, never a fake/local AI result. Server env AI_BASE_URL(default https://api.openai.com/v1), AI_API_KEY or OPENAI_API_KEY, AI_MODEL(default gpt-5.4-mini), AI_TIMEOUT_MS(default90000,bounds1000-180000). Chat quotes and page references are checked against the provided source; absent answers return found=false. Presentation creates 1-12 editable text slides as PPTX, marked AI-generated with source pages; resume creates a styled A4 PDF using only exact, verified source facts. Translation returns plain text and does not preserve PDF layout. Provider and schema failures return errors without automatic paid retries. See docs/API.md for every task result shape and provider/data routing.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "task": {
                    "type": "string",
                    "enum": [
                      "summarize",
                      "chat",
                      "translate",
                      "flashcards",
                      "quiz",
                      "mind-map",
                      "presentation",
                      "resume"
                    ]
                  },
                  "question": {
                    "type": "string",
                    "description": "Required for chat; omit when unused rather than sending empty text.",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "language": {
                    "type": "string",
                    "description": "Required for translate; optional for other generated text. Resume facts retain source wording.",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "text": {
                    "type": "string",
                    "description": "Use this OR multipart pdfFile, never both. Supplied text is source page 1.",
                    "minLength": 1,
                    "maxLength": 60000
                  }
                },
                "required": [
                  "task",
                  "text"
                ]
              },
              "example": {
                "task": "translate",
                "text": "Returns must be filed within thirty days.",
                "language": "French"
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "task": {
                    "type": "string",
                    "enum": [
                      "summarize",
                      "chat",
                      "translate",
                      "flashcards",
                      "quiz",
                      "mind-map",
                      "presentation",
                      "resume"
                    ]
                  },
                  "question": {
                    "type": "string",
                    "description": "Required for chat; omit when unused rather than sending empty text.",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "language": {
                    "type": "string",
                    "description": "Required for translate; optional for other generated text. Resume facts retain source wording.",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "pdfFile": {
                    "type": "string",
                    "description": "PDF up to 20 MiB, 1-200 pages. Local extraction includes first 60000 characters with truncation metadata. Run OCR first for scans.",
                    "format": "binary"
                  }
                },
                "required": [
                  "task",
                  "pdfFile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON for summarize/chat/translate/flashcards/quiz/mind-map; PPTX for presentation; PDF for resume. Binary filenames <source>-ai-presentation.pptx / <source>-ai-resume.pdf; pasted text basename document.",
            "headers": {
              "X-AI-Generated": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              },
              "X-AI-Task": {
                "schema": {
                  "type": "string"
                }
              },
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Suggested download filename, for presentation/resume binary results."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AIResponse"
                }
              },
              "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid task/options/source combination or password-protected PDF.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "PDF upload exceeds 20 MiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "PDF text unavailable, more than200pages, insufficient verified resume facts, or provider declined the task.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "description": "Provider connection/JSON/schema/evidence verification failure or incomplete response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "AI provider key/configuration or required PDF text engine unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "PDF extraction or AI provider timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/image-files-to-pdf": {
      "post": {
        "operationId": "post_api_convert_image_files_to_pdf",
        "summary": "Combine extended image formats into PDF",
        "description": "PNG,JPEG,WebP,GIF,TIFF,BMP,HEIC/HEIF and Photoshop PSD embedded composite. EXIF orientation and white alpha background. Max100pages,40MPperimage,160MPtotal,20files/100MiBcombined. Image-native size uses one point per pixel; thermal is288x432pt. Existing image APIs retain their original settings.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "images": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "description": "Image, max20MiB each,100MiB combined",
                      "format": "binary"
                    }
                  },
                  "format": {
                    "type": "string",
                    "description": "Target page size",
                    "enum": [
                      "A4",
                      "Letter",
                      "thermal",
                      "image"
                    ],
                    "default": "A4"
                  },
                  "orientation": {
                    "type": "string",
                    "enum": [
                      "portrait",
                      "landscape"
                    ],
                    "default": "portrait"
                  },
                  "margin": {
                    "type": "number",
                    "default": 0,
                    "minimum": 0,
                    "maximum": 100
                  },
                  "frameMode": {
                    "type": "string",
                    "description": "first uses first frame, all includes TIFF/GIF frames within resource limits",
                    "enum": [
                      "first",
                      "all"
                    ],
                    "default": "first"
                  },
                  "filter": {
                    "type": "string",
                    "description": "Only applied by scan-to-pdf",
                    "enum": [
                      "color",
                      "gray",
                      "bw"
                    ],
                    "default": "gray"
                  },
                  "cleanup": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "images"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/scan-to-pdf": {
      "post": {
        "operationId": "post_api_convert_scan_to_pdf",
        "summary": "Clean captured document images into a PDF",
        "description": "Same image limits/formats. Gray(default), color or black-and-white threshold, optional auto-contrast and sharpening. Does not detect perspective or add OCR; use /api/tools/ocr afterward. Camera is a browser input option, never started automatically.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "images": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "description": "Image, max20MiB each,100MiB combined",
                      "format": "binary"
                    }
                  },
                  "format": {
                    "type": "string",
                    "description": "Target page size",
                    "enum": [
                      "A4",
                      "Letter",
                      "thermal",
                      "image"
                    ],
                    "default": "A4"
                  },
                  "orientation": {
                    "type": "string",
                    "enum": [
                      "portrait",
                      "landscape"
                    ],
                    "default": "portrait"
                  },
                  "margin": {
                    "type": "number",
                    "default": 0,
                    "minimum": 0,
                    "maximum": 100
                  },
                  "frameMode": {
                    "type": "string",
                    "description": "first uses first frame, all includes TIFF/GIF frames within resource limits",
                    "enum": [
                      "first",
                      "all"
                    ],
                    "default": "first"
                  },
                  "filter": {
                    "type": "string",
                    "description": "Only applied by scan-to-pdf",
                    "enum": [
                      "color",
                      "gray",
                      "bw"
                    ],
                    "default": "gray"
                  },
                  "cleanup": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "images"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/text-to-pdf": {
      "post": {
        "operationId": "post_api_convert_text_to_pdf",
        "summary": "Convert plain text to a Unicode PDF",
        "description": "Escapes all text/title as literal content before Chromium rendering. Max200000characters. A4orLetter,8–28pt. No upload required.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 200000,
                    "minLength": 1
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200,
                    "default": ""
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "A4",
                      "Letter"
                    ],
                    "default": "A4"
                  },
                  "fontSize": {
                    "type": "number",
                    "default": 12,
                    "minimum": 8,
                    "maximum": 28
                  }
                },
                "required": [
                  "text"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/rtf-to-pdf": {
      "post": {
        "operationId": "post_api_convert_rtf_to_pdf",
        "summary": "Convert RTF to PDF",
        "description": "officeFile must have .rtf extension and RTF header, max50MiB. LibreOffice with a unique temporary profile;90secondtimeout. When no LibreOffice is installed, text/basic span-style fallback via rtf-parser and Chromium supports up to2MiB, exposes X-Conversion-Engine:rtf-text-fallback. Complex RTF layout/images require LibreOffice.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "officeFile": {
                    "type": "string",
                    "description": "RTF file, max50MiB",
                    "format": "binary"
                  }
                },
                "required": [
                  "officeFile"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/sign": {
      "post": {
        "operationId": "post_api_tools_sign",
        "summary": "Place a visual signature on a PDF",
        "description": "pdfFile max50MiB,1–1000pages. Provide signatureImage OR nonempty text. Typed signatures support WinAnsi; use an image for other scripts. Coordinates are absolute unrotated bottom-left PDF points. Rectangle must fit the visible CropBox/MediaBox intersection. Preserves page dimensions/rotation. This is a visible signature, without cryptographic certification. X-Signature-Type:visual. Release 4.1: optional region JSON selects exactly one source page in viewed visible coordinates. Fits and centers a signature image preserving aspect ratio, or fits centered typed text, within the selected region. This remains a visual signature without cryptographic certification. Conflicting raw placement/scope fields are rejected with 400; omit them instead of sending defaults. See docs/PLACEMENT.md.",
        "tags": [
          "Security"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "description": "Unencrypted PDF",
                    "format": "binary"
                  },
                  "signatureImage": {
                    "type": "string",
                    "description": "Signature image, decoded max20MP",
                    "format": "binary"
                  },
                  "text": {
                    "type": "string",
                    "description": "Typed signature if image omitted",
                    "maxLength": 160,
                    "default": ""
                  },
                  "page": {
                    "type": "integer",
                    "default": 1,
                    "minimum": 1
                  },
                  "x": {
                    "type": "number",
                    "default": 36,
                    "minimum": 0
                  },
                  "y": {
                    "type": "number",
                    "default": 36,
                    "minimum": 0
                  },
                  "width": {
                    "type": "number",
                    "default": 180,
                    "minimum": 10,
                    "maximum": 1440
                  },
                  "height": {
                    "type": "number",
                    "default": 60,
                    "minimum": 10,
                    "maximum": 1440
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Optional JSON string matching PDFVisibleRegion: {page,x,y,width,height,coordinateSpace:\"visible\"}. Source page only; coordinates follow the viewed visible page, including existing rotation/crop. Do not combine region with x, y, width, height, page, pages (even when they equal legacy defaults). Omitted region retains this endpoint's original behavior. Fits and centers a signature image preserving aspect ratio, or fits centered typed text, within the selected region. This remains a visual signature without cryptographic certification.",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    },
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}"
                  }
                },
                "required": [
                  "pdfFile"
                ],
                "additionalProperties": false,
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "x"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "y"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "width"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "height"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "pages"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/convert/design-to-pdf": {
      "post": {
        "operationId": "post_api_convert_design_to_pdf",
        "summary": "Convert compatible AI/EPS/PostScript designs",
        "description": "designFile .ai,.eps,.ps up to50MiB. PDF-compatible Illustrator files retain their embedded PDF bytes; PostScript is converted with Ghostscript SAFER,90secondtimeout. Native InDesign or AI without PDF/PostScript content is rejected422. Does not imply native Adobe layout support.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "designFile": {
                    "type": "string",
                    "description": "Compatible AI, EPS or PS file",
                    "format": "binary"
                  }
                },
                "required": [
                  "designFile"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/compress": {
      "post": {
        "operationId": "post_api_tools_compress",
        "summary": "Recompress PDF images with three strength levels",
        "description": "pdfFile max50MiB,300pages. Preserves text/vectorcontent; image quality may decrease. low200dpi/90quality,medium150dpi/75quality,high96dpi/55quality. Optional targetDpi and imageQuality override level. Max40MPperimage/200MPtotal. Keeps original bytes if candidate is larger. Size/percent savings in X-Original-Size,X-Compressed-Size,X-Compression-Ratio. Existing /api/optimize/compress remains unchanged.",
        "tags": [
          "Conversion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "description": "Unencrypted PDF",
                    "format": "binary"
                  },
                  "level": {
                    "type": "string",
                    "enum": [
                      "low",
                      "medium",
                      "high"
                    ],
                    "default": "medium"
                  },
                  "targetDpi": {
                    "type": "integer",
                    "minimum": 72,
                    "maximum": 300
                  },
                  "imageQuality": {
                    "type": "integer",
                    "minimum": 30,
                    "maximum": 95
                  }
                },
                "required": [
                  "pdfFile"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Binary PDF download.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "description": "Output PDF",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/request-signatures": {
      "post": {
        "operationId": "post_api_tools_request_signatures",
        "summary": "Send a DocuSeal template signature invitation",
        "description": "Requires server DOCUSEAL_API_KEY and optional DOCUSEAL_BASE_URL(defaulthttps://api.docuseal.com). Create/upload a single-signer template in DocuSeal first. Invokes POST/submissions with send_email=true; this action sends the named signer an email invitation. No document is uploaded by this endpoint. Service/license/email configuration follows your DocuSeal deployment. No automatic retry, credentials never returned. Result contains submissionId and signers{name,email,status,signingUrl}.",
        "tags": [
          "Security"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "templateId": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "signerEmail": {
                    "type": "string",
                    "description": "Signer email",
                    "format": "email",
                    "maxLength": 254
                  },
                  "signerName": {
                    "type": "string",
                    "maxLength": 200,
                    "default": ""
                  }
                },
                "required": [
                  "templateId",
                  "signerEmail"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful service response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Upload too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Document or processing limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Processing error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "External service rejected or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Required engine or service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Processing timeout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/capabilities": {
      "get": {
        "operationId": "get_api_capabilities",
        "summary": "Inspect configured processing engines and services",
        "tags": [
          "Service"
        ],
        "description": "Protected by the same application authentication. Returns booleans and model name, never engine paths, provider URLs or credentials. Engine presence does not guarantee that a particular document will convert.",
        "responses": {
          "200": {
            "description": "Runtime availability: ai{configured,model,protocol,tasks},signing{configured,provider},engines{python,ocr,pdfa,office,pdfaValidator},formats,features.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/account/config": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "security": [],
        "summary": "Get public account client configuration",
        "description": "Public client bootstrap. Returns no server credential and performs no database availability probe.",
        "responses": {
          "200": {
            "description": "Public account configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountConfig"
                },
                "example": {
                  "enabled": true,
                  "ready": true,
                  "supabaseUrl": "https://YOUR_PROJECT.supabase.co",
                  "publishableKey": "YOUR_PUBLIC_PUBLISHABLE_KEY"
                }
              }
            }
          }
        },
        "operationId": "get_api_account_config"
      }
    },
    "/api/account/me": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Get current profile, limits, plan and usage",
        "description": "Verified session only. plan is effective access; subscription retains billing state, which can differ. limits includes per-user overrides. Reading the account does not consume a processing operation. limits.nativeFeatures applies owner native-editor overrides independently of limits.features. Native local editing is unmetered.",
        "responses": {
          "200": {
            "description": "Current raw account snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSnapshot"
                },
                "example": {
                  "user": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "email": "person@example.com",
                    "name": "Sam"
                  },
                  "profile": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "email": "person@example.com",
                    "displayName": "Sam",
                    "disabled": false,
                    "createdAt": "2026-11-19T12:00:00.000Z"
                  },
                  "subscription": {
                    "planId": "free",
                    "status": "free",
                    "currentPeriodStart": null,
                    "currentPeriodEnd": null,
                    "cancelAtPeriodEnd": false,
                    "billingHold": false,
                    "riskReason": null
                  },
                  "plan": {
                    "id": "free",
                    "name": "Free",
                    "priceCents": 0,
                    "currency": "cad",
                    "features": [
                      "core"
                    ],
                    "nativeFeatures": [
                      "core"
                    ]
                  },
                  "limits": {
                    "webMonthly": 100,
                    "apiMonthly": 100,
                    "requestsPerMinute": 10,
                    "maxApiKeys": 1,
                    "features": [
                      "core"
                    ],
                    "nativeFeatures": [
                      "core"
                    ]
                  },
                  "usage": {
                    "period": "2026-11",
                    "webUsed": 2,
                    "apiUsed": 3,
                    "webRemaining": 98,
                    "apiRemaining": 97
                  },
                  "isAdmin": false
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required, or new key creation is blocked for a disabled account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "503": {
            "description": "Accounts are disabled, credentials are missing or Supabase is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          }
        },
        "operationId": "get_api_account_me"
      }
    },
    "/api/account/api-keys": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "List owned API key metadata",
        "description": "Returns at most 100 records: active keys first (newest created first), then most recently revoked keys. Contains neither hashes nor complete secrets. Listing keys does not consume processing quota.",
        "responses": {
          "200": {
            "description": "Owned safe key metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyList"
                },
                "example": {
                  "keys": [
                    {
                      "id": "22222222-2222-4222-8222-222222222222",
                      "name": "Website integration",
                      "prefix": "sw_live_A1b2C3d4",
                      "createdAt": "2026-11-19T12:00:00.000Z",
                      "lastUsedAt": null,
                      "revokedAt": null
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required, or new key creation is blocked for a disabled account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "503": {
            "description": "Accounts are disabled, credentials are missing or Supabase is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          }
        },
        "operationId": "get_api_account_api_keys"
      },
      "post": {
        "tags": [
          "Accounts"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Create a personal API key",
        "description": "Verified session only. Returns the complete secret once with HTTP 201. Store it securely and use X-API-Key for processing. Only the hash and safe metadata are persisted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Trimmed display label; whitespace-only names are rejected.",
                    "minLength": 1,
                    "maxLength": 80
                  }
                }
              },
              "example": {
                "name": "Website integration"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. Copy the full key now; this illustrative example is not a valid credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyCreated"
                },
                "example": {
                  "key": "sw_live_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                  "apiKey": {
                    "id": "22222222-2222-4222-8222-222222222222",
                    "name": "Website integration",
                    "prefix": "sw_live_AAAAAAAA",
                    "createdAt": "2026-11-19T12:00:00.000Z",
                    "lastUsedAt": null,
                    "revokedAt": null
                  }
                }
              }
            }
          },
          "400": {
            "description": "The key name must contain 1–80 non-whitespace characters and no extra request fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required, or new key creation is blocked for a disabled account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "409": {
            "description": "Active API key allowance reached (API_KEY_LIMIT). Revoke a key before creating another.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "503": {
            "description": "Accounts are disabled, credentials are missing or Supabase is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          }
        },
        "operationId": "post_api_account_api_keys"
      }
    },
    "/api/account/api-keys/{id}": {
      "delete": {
        "tags": [
          "Accounts"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Revoke an owned API key",
        "description": "Immediately prevents future requests with this key. Requests already authenticated may complete. Another account’s key ID is not accessible. HTTP 200 confirms revocation.",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "UUID returned in apiKey.id or keys[].id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The owned key is revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "400": {
            "description": "The key ID is not a valid UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required, or new key creation is blocked for a disabled account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "404": {
            "description": "No matching owned key exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "503": {
            "description": "Accounts are disabled, credentials are missing or Supabase is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          }
        },
        "operationId": "delete_api_account_api_keys_id"
      }
    },
    "/api/billing/plans": {
      "get": {
        "tags": [
          "Billing"
        ],
        "security": [],
        "summary": "Get public active plans and billing readiness",
        "description": "Database-backed catalog; prices are currency minor units per month before tax. testMode identifies Stripe test credentials. Readiness flags do not grant access or guarantee provider availability. Each plan exposes separate features (original APIs) and nativeFeatures (native editor/HTTP tools).",
        "responses": {
          "200": {
            "description": "Active plans and configuration flags.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingPlans"
                },
                "example": {
                  "success": true,
                  "enabled": true,
                  "checkoutReady": true,
                  "testMode": true,
                  "taxReady": false,
                  "currency": "cad",
                  "plans": [
                    {
                      "id": "starter",
                      "name": "Starter",
                      "priceCents": 900,
                      "currency": "cad",
                      "interval": "month",
                      "limits": {
                        "webMonthly": 1000,
                        "apiMonthly": 2000,
                        "requestsPerMinute": 30,
                        "maxApiKeys": 3
                      },
                      "features": [
                        "core",
                        "office",
                        "ocr",
                        "pdfa"
                      ],
                      "checkoutAvailable": true,
                      "nativeFeatures": [
                        "core",
                        "advanced",
                        "office",
                        "ocr",
                        "pdfa"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Account, billing, provider or tax setup is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          }
        },
        "operationId": "get_api_billing_plans"
      }
    },
    "/api/billing/checkout": {
      "post": {
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Open a hosted subscription Checkout",
        "description": "Verified session only. Uses the server-owned catalog/customer mapping and a shared checkout lease. Reuses a matching open session. Existing nonterminal subscriptions must be managed through the portal. Returning from the success URL never grants paid access; verified webhooks and a confirmed paid invoice do.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "planId"
                ],
                "properties": {
                  "planId": {
                    "type": "string",
                    "enum": [
                      "starter",
                      "pro",
                      "business"
                    ]
                  }
                }
              },
              "example": {
                "planId": "pro"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hosted Checkout URL for this customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingRedirect"
                },
                "example": {
                  "success": true,
                  "url": "https://checkout.stripe.com/c/pay/EXAMPLE_SESSION"
                }
              }
            }
          },
          "400": {
            "description": "Choose an active supported paid plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage billing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "409": {
            "description": "A checkout is already opening, the catalog changed or a nonterminal subscription already exists. Use the billing portal for an existing subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "503": {
            "description": "Account, billing, provider or tax setup is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          }
        },
        "operationId": "post_api_billing_checkout"
      }
    },
    "/api/billing/portal": {
      "post": {
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Open the current customer’s billing portal",
        "description": "Verified session only. Returns a server-created Stripe customer portal URL for payment methods, plan changes, cancellation and invoice history. No customer ID is accepted from the caller.",
        "responses": {
          "200": {
            "description": "Hosted customer portal URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingRedirect"
                },
                "example": {
                  "success": true,
                  "url": "https://billing.stripe.com/p/session/EXAMPLE_SESSION"
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage billing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "503": {
            "description": "Account, billing, provider or tax setup is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          }
        },
        "operationId": "post_api_billing_portal"
      }
    },
    "/api/billing/invoices": {
      "get": {
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "List the current customer’s latest invoices",
        "description": "Verified session only. Returns at most 24 invoices for the customer mapped to the signed-in account. The caller cannot select a customer ID.",
        "responses": {
          "200": {
            "description": "Owned invoices; empty when no customer/invoices exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingInvoices"
                },
                "example": {
                  "success": true,
                  "invoices": [
                    {
                      "id": "in_EXAMPLE",
                      "number": "EXAMPLE-0001",
                      "status": "paid",
                      "amountPaid": 1900,
                      "currency": "cad",
                      "created": 1795089600,
                      "hostedUrl": "https://invoice.stripe.com/i/EXAMPLE",
                      "pdfUrl": "https://pay.stripe.com/invoice/EXAMPLE/pdf"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase Bearer session is required; personal API keys cannot manage billing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "403": {
            "description": "Email confirmation is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          },
          "503": {
            "description": "Account, billing, provider or tax setup is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                }
              }
            }
          }
        },
        "operationId": "get_api_billing_invoices"
      }
    },
    "/api/billing/webhook": {
      "post": {
        "tags": [
          "Billing"
        ],
        "security": [],
        "summary": "Receive signed Stripe subscription/payment events",
        "description": "Provider-only endpoint. The Stripe-Signature header authenticates the original raw request bytes with this endpoint’s signing secret. Do not call this to upgrade an account. Successful/duplicate/unrelated events return received:true; failed processing must be retried by Stripe.",
        "x-shipwave-auth": "stripe-signature",
        "parameters": [
          {
            "in": "header",
            "name": "Stripe-Signature",
            "required": true,
            "description": "Stripe-generated timestamped HMAC signature over the exact raw body. A Supabase token or user API key cannot replace it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event accepted, ignored or already processed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StripeWebhookReceived"
                },
                "example": {
                  "received": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid signature or test/live mode mismatch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookError"
                }
              }
            }
          },
          "503": {
            "description": "Webhook configuration or processing unavailable. Retry delivery.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookError"
                }
              }
            }
          }
        },
        "operationId": "post_api_billing_webhook"
      }
    },
    "/api/pdf/coordinates": {
      "post": {
        "operationId": "post_api_pdf_coordinates",
        "summary": "Measure the visible PDF page or resolve two corners to a reusable region",
        "tags": [
          "Editing"
        ],
        "description": "Authenticated metadata-only upload; does not modify/export a PDF and does not consume a monthly PDF processing operation. Upload pdfFile and optionally page (default 1 when region is absent). For a selected area, send points as a JSON array of exactly two visible bottom-left x/y corners, or supply region JSON. region cannot be combined with page or points. Corner order does not matter. CropBox/MediaBox intersections and existing page rotations are accounted for; sourceRect is the unrotated equivalent. Coordinates remain raw PDF units, independent of preview pixels/device scale; UserUnit explains physical size. With neither points nor region, returns page metadata only. Protected/invalid PDFs or zero-area/out-of-bounds rectangles return 400.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "pdfFile"
                ],
                "properties": {
                  "pdfFile": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file, maximum 50 MiB by default; unencrypted source required."
                  },
                  "page": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "One-based source page. Default 1 when region is absent; forbidden when region is supplied."
                  },
                  "points": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "JSON array of exactly two numeric {x,y} objects in visible bottom-left raw PDF units. Both corners must fit the page; resulting width/height must be at least 0.01. Forbidden with region.",
                    "example": "[{\"x\":36,\"y\":48},{\"x\":156,\"y\":108}]",
                    "x-json-schema": {
                      "type": "array",
                      "minItems": 2,
                      "maxItems": 2,
                      "items": {
                        "$ref": "#/components/schemas/PDFCoordinatePoint"
                      }
                    }
                  },
                  "region": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "JSON object matching PDFVisibleRegion; cannot combine with page or points.",
                    "example": "{\"page\":1,\"x\":36,\"y\":48,\"width\":120,\"height\":60,\"coordinateSpace\":\"visible\"}",
                    "x-json-schema": {
                      "$ref": "#/components/schemas/PDFVisibleRegion"
                    }
                  }
                },
                "allOf": [
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "region",
                            "page"
                          ]
                        },
                        {
                          "required": [
                            "region",
                            "points"
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Visible-page metadata, and normalized region/sourceRect only when points or region was supplied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PDFCoordinateMeasurement"
                },
                "example": {
                  "success": true,
                  "page": 1,
                  "coordinateSpace": "visible",
                  "unit": "pt",
                  "userUnit": 1,
                  "width": 595.28,
                  "height": 841.89,
                  "rotation": 0,
                  "sourceBox": {
                    "x": 0,
                    "y": 0,
                    "width": 595.28,
                    "height": 841.89
                  },
                  "points": [
                    {
                      "x": 36,
                      "y": 48
                    },
                    {
                      "x": 156,
                      "y": 108
                    }
                  ],
                  "region": {
                    "page": 1,
                    "x": 36,
                    "y": 48,
                    "width": 120,
                    "height": 60,
                    "coordinateSpace": "visible"
                  },
                  "sourceRect": {
                    "x": 36,
                    "y": 48,
                    "width": 120,
                    "height": 60
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid PDF, password, points, region, source page, bounds or conflicting fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "PDF exceeds upload limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/pdf/placement-preview": {
      "post": {
        "operationId": "post_api_pdf_placement_preview",
        "summary": "Get font outlines for a live text or watermark placement preview",
        "tags": [
          "Editing"
        ],
        "description": "Authenticated read-only JSON request. No PDF upload, document processing, external AI provider, monthly processing operation or per-user processing request reservation. Existing authentication, account availability and server admission limits still apply. Uses the same embedded Liberation Sans and shaped ink layout as direct placement on /add-text and /api/watermark/add-watermark. Returns glyph paths in font units with Y increasing upward and normalized actual ink bounds. Center a uniform fit of those bounds within the unrotated placement frame, then rotate the frame counterclockwise about its center. Cache by text to avoid a request during pointer moves. Request body limit 32 KiB. Legacy and region text fonts do not change.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PDFPlacementPreviewRequest"
              },
              "example": {
                "text": "A"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Font identity, normalized vector ink bounds and positioned glyph outlines.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PDFPlacementPreview"
                },
                "example": {
                  "font": "Liberation Sans",
                  "fontMetrics": {
                    "unitsPerEm": 2048,
                    "ascent": 1854,
                    "descent": -434,
                    "width": 1358,
                    "height": 1409,
                    "paths": [
                      {
                        "d": "M1167 0L1006 412L364 412L202 0L4 0L579 1409L796 1409L1362 0ZM768 1026Q752 1066 737.5 1107Q723 1148 712 1181.5Q701 1215 693.5 1237.5Q686 1260 685 1265Q683 1260 676 1237Q669 1214 657.5 1180Q646 1146 631.5 1105Q617 1064 602 1024L422 561L949 561Z",
                        "x": -4,
                        "y": 0
                      }
                    ]
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store. Clients may retain tab-local metrics while editing; the response must not be stored in shared HTTP caches."
              }
            }
          },
          "400": {
            "description": "Invalid JSON, unknown keys, empty or multiline text, more than 2000 characters, or glyphs unsupported by the embedded font.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "success": false,
                  "error": "PDF placement preview failed",
                  "message": "text must be a nonempty single line of at most 2000 characters"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "JSON request body exceeds 32 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "description": "Font/layout engine error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/account/editor-access": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "get_api_account_editor_access",
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Read verified native editor access metadata",
        "description": "No processing quota is charged. Returns native groups independently of original API rights. ready is configuration metadata, not an access proof. Legacy shared-auth/private installations follow their configured legacy policy.",
        "responses": {
          "200": {
            "description": "Native access metadata; no private key, token or PDF contents.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NativeEditorAccess"
                },
                "example": {
                  "enabled": true,
                  "ready": true,
                  "mode": "local",
                  "plan": {
                    "id": "free",
                    "name": "Free",
                    "priceCents": 0,
                    "currency": "cad",
                    "features": [
                      "core"
                    ],
                    "nativeFeatures": [
                      "core"
                    ]
                  },
                  "features": [
                    "core"
                  ],
                  "leaseSeconds": 300,
                  "localEditsMetered": false
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase session is required in account mode. Personal API keys cannot obtain native browser leases. Legacy installations use their existing explicit authentication policy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "403": {
            "description": "Email is unconfirmed, account is disabled or billing is on hold.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "503": {
            "description": "Account/database or signing configuration is unavailable. Missing/mismatched private signing seeds fail closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "post_api_account_editor_access",
        "security": [
          {
            "supabaseSession": []
          }
        ],
        "summary": "Issue a signed nonce-bound local editor feature lease",
        "description": "Uses the verified account and native_features from Supabase, never client-selected flags. Pass the nonce from the existing native tab state. Raw signed payload contains v1, nonce, Unix-second times, allowed native features and mode local. Native WASM verifies its pinned Ed25519 public key, nonce and expiry. Maximum lifetime is five minutes, capped by paid term expiry. This call/local editing is not metered; native HTTP processing retains server quotas. Extra request fields are rejected. A signed editor proof is not an HTTP API credential. Personal API keys cannot obtain leases in Supabase mode.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "nonce"
                ],
                "additionalProperties": false,
                "properties": {
                  "nonce": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 128,
                    "pattern": "^[A-Za-z0-9_-]{16,128}$",
                    "description": "Existing native tab nonce, generated by the native engine."
                  }
                }
              },
              "example": {
                "nonce": "THE_NONCE_FROM_THE_NATIVE_TAB"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Exact signed payload string and base64url Ed25519 signature. No success wrapper.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NativeEditorSignedAccess"
                }
              }
            }
          },
          "400": {
            "description": "Invalid nonce, missing nonce or unexpected request fields; INVALID_EDITOR_NONCE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "401": {
            "description": "A verified Supabase session is required in account mode. Personal API keys cannot obtain native browser leases. Legacy installations use their existing explicit authentication policy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "403": {
            "description": "Email is unconfirmed, account is disabled or billing is on hold.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          },
          "503": {
            "description": "Account/database or signing configuration is unavailable. Missing/mismatched private signing seeds fail closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountError"
                }
              }
            }
          }
        }
      }
    },
    "/api/editor/tools": {
      "get": {
        "operationId": "get_api_editor_tools",
        "tags": [
          "Native editor"
        ],
        "summary": "List every typed editor tool and its HTTP policy/schema",
        "description": "Authenticated metadata without a processing charge. Returns 215 actual typed schemas; the current hosted adapter permits 193 and explicitly refuses 22 host/system/unrestricted operations. Check allowed, available and entitled before invoking. Native permissions are independent of original API feature permissions.",
        "security": [
          {
            "supabaseSession": []
          },
          {
            "apiKey": []
          },
          {
            "basicAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Native runtime catalog and limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditorTools"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "503": {
            "description": "The command binary/account service is not installed or available.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/editor/features": {
      "get": {
        "operationId": "get_api_editor_features",
        "tags": [
          "Native editor"
        ],
        "summary": "Get the complete native and Shipwave feature inventory",
        "description": "Authenticated source-derived inventory. Includes all native categories/groups, ready/planned/provider rows, registered command IDs, typed automation definitions and original Shipwave tools. This list does not turn viewer commands or planned tools into HTTP operations. /api/editor/tools is authoritative for runnable typed schemas.",
        "security": [
          {
            "supabaseSession": []
          },
          {
            "apiKey": []
          },
          {
            "basicAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Complete feature inventory.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditorFeatures"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/editor/run": {
      "post": {
        "operationId": "post_api_editor_run",
        "tags": [
          "Native editor"
        ],
        "summary": "Run bounded native PDF editing/export steps",
        "description": "Multipart uploads and 1–20 typed tool steps in a private, confined request directory. Files become input1.pdf, input2.png, etc. autoOpen opens uploaded PDFs as document IDs 1,2,…; save appends doc_save to result.pdf for outputDoc. One accepted batch consumes one web/API operation and the shared minute limit; every step also needs its server-owned native feature. No host printer, Keychain/Windows identity, global trust-store, arbitrary JavaScript, recursive folder batch or nested command dispatch is exposed. Digital signing must use format=zip and save=false to preserve the signing output. Full examples and coordinate distinctions: docs/TOOLS_AND_API.md.",
        "security": [
          {
            "supabaseSession": []
          },
          {
            "apiKey": []
          },
          {
            "basicAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "steps"
                ],
                "properties": {
                  "files": {
                    "type": "array",
                    "maxItems": 8,
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "description": "Repeated uploads; 50 MiB each, 100 MiB total. Include a simple extension. Zero files is valid for document creation."
                  },
                  "steps": {
                    "type": "string",
                    "description": "JSON-serialized array of 1–20 EditorStep objects. args is validated against the tool-specific JSON Schema from /api/editor/tools.",
                    "example": "[{\"tool\":\"page_rotate\",\"args\":{\"doc\":1,\"pages\":[1],\"degrees\":90}}]"
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "zip",
                      "pdf",
                      "json"
                    ],
                    "default": "zip",
                    "description": "ZIP contains generated files and report.json. PDF returns the auto-saved result. JSON returns report/manifest only; generated files are deleted after the request."
                  },
                  "save": {
                    "type": "boolean",
                    "description": "Default true for ZIP/PDF, false for JSON. Appends doc_save(result.pdf); digital signing requires false."
                  },
                  "autoOpen": {
                    "type": "boolean",
                    "default": true,
                    "description": "Open PDF uploads in upload order before typed steps. Set false to use explicit doc_open/password steps."
                  },
                  "outputDoc": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000,
                    "default": 1,
                    "description": "Document ID saved when save=true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated PDF, ZIP with report/files, or JSON report. Content-Disposition supplies the download name.",
            "headers": {
              "Content-Disposition": {
                "description": "attachment; filename=\"edited.pdf\" or editor-results.zip for binary output.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditorRunReport"
                }
              }
            }
          },
          "400": {
            "description": "Malformed steps/options, unknown fields/tool, unsafe filename or signature-breaking auto-save.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Native core/step feature is not included, account is disabled/on hold, or this host action is not exposed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Upload, generated-file, report or ZIP limits exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Use multipart/form-data; JSON and raw request bodies are not accepted by this endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "A valid typed request failed on this document. Error reports list successful/error/skipped steps.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "The command binary/account service is not installed or available.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "The command process exceeded its time limit and was stopped.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "basicAuth": {
        "type": "http",
        "scheme": "basic",
        "description": "Legacy single-tenant mode only when SUPABASE_URL is absent. AUTH_USERNAME / AUTH_PASSWORD are never a bypass for Supabase account limits."
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Personal key from Account, or configured static key in legacy single-tenant mode. Header preferred."
      },
      "apiKeyQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "apiKey",
        "description": "Legacy compatibility only when SUPABASE_URL is absent. Not accepted in account mode; prefer the X-API-Key header."
      },
      "supabaseSession": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Supabase access token",
        "description": "Verified Supabase user session. Required for account/billing management; processing counts toward web quota."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "default": false
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code": {
            "type": "string",
            "description": "Optional stable account error code, such as EMAIL_NOT_VERIFIED, ACCOUNT_DISABLED, BILLING_HOLD, FEATURE_NOT_INCLUDED, RATE_LIMIT, or MONTHLY_LIMIT."
          },
          "detail": {
            "type": "string",
            "description": "Optional additional error detail used by the shared server error handler."
          },
          "report": {
            "$ref": "#/components/schemas/EditorExecutionReport",
            "description": "Optional native per-step report after an engine operation fails."
          }
        }
      },
      "HtmlOptions": {
        "type": "object",
        "properties": {
          "format": {
            "type": "string",
            "default": "A4",
            "enum": [
              "A4",
              "A3",
              "A5",
              "Letter",
              "Legal",
              "Tabloid"
            ]
          },
          "orientation": {
            "type": "string",
            "default": "portrait",
            "enum": [
              "portrait",
              "landscape"
            ]
          },
          "width": {
            "type": "string",
            "description": "Explicit page width; supply height too. Example: 4in."
          },
          "height": {
            "type": "string",
            "description": "Explicit page height; supply width too. Example: 6in."
          },
          "preserveOriginalSize": {
            "type": "boolean",
            "default": false,
            "description": "Use CSS @page dimensions, with zero default margins."
          },
          "preferCSSPageSize": {
            "type": "boolean",
            "default": true,
            "description": "Respect CSS @page size. Always enabled in preserve mode."
          },
          "margin": {
            "type": "object",
            "properties": {
              "top": {
                "type": "string",
                "description": "Defaults to 1cm in standard mode, 0 in custom/preserve mode."
              },
              "right": {
                "type": "string",
                "description": "Defaults to 1cm in standard mode, 0 in custom/preserve mode."
              },
              "bottom": {
                "type": "string",
                "description": "Defaults to 1cm in standard mode, 0 in custom/preserve mode."
              },
              "left": {
                "type": "string",
                "description": "Defaults to 1cm in standard mode, 0 in custom/preserve mode."
              }
            }
          },
          "displayHeaderFooter": {
            "type": "boolean",
            "default": false
          },
          "headerTemplate": {
            "type": "string",
            "default": ""
          },
          "footerTemplate": {
            "type": "string",
            "default": ""
          },
          "printBackground": {
            "type": "boolean",
            "default": true
          },
          "scale": {
            "type": "number",
            "default": 1,
            "minimum": 0.1,
            "maximum": 2
          }
        }
      },
      "PdfEdits": {
        "type": "object",
        "properties": {
          "formEdits": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fieldName": {
                  "type": "string"
                },
                "value": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "boolean"
                    },
                    {
                      "type": "number"
                    }
                  ]
                }
              },
              "required": [
                "fieldName",
                "value"
              ]
            },
            "default": []
          },
          "textOverlays": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "page": {
                  "type": "integer",
                  "default": 1,
                  "minimum": 1
                },
                "x": {
                  "type": "number",
                  "minimum": 0
                },
                "y": {
                  "type": "number",
                  "minimum": 0
                },
                "fontSize": {
                  "type": "number",
                  "default": 12,
                  "minimum": 6,
                  "maximum": 72
                },
                "color": {
                  "type": "object",
                  "properties": {
                    "r": {
                      "type": "number",
                      "default": 0,
                      "minimum": 0,
                      "maximum": 255
                    },
                    "g": {
                      "type": "number",
                      "default": 0,
                      "minimum": 0,
                      "maximum": 255
                    },
                    "b": {
                      "type": "number",
                      "default": 0,
                      "minimum": 0,
                      "maximum": 255
                    }
                  }
                },
                "coverArea": {
                  "type": "object",
                  "properties": {
                    "x": {
                      "type": "number",
                      "minimum": 0
                    },
                    "y": {
                      "type": "number",
                      "minimum": 0
                    },
                    "width": {
                      "type": "number",
                      "minimum": 0.001
                    },
                    "height": {
                      "type": "number",
                      "minimum": 0.001
                    }
                  },
                  "required": [
                    "x",
                    "y",
                    "width",
                    "height"
                  ]
                }
              },
              "required": [
                "text",
                "x",
                "y"
              ]
            },
            "default": []
          },
          "textReplacements": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "newText": {
                  "type": "string"
                },
                "page": {
                  "type": "integer",
                  "default": 1,
                  "minimum": 1
                },
                "x": {
                  "type": "number",
                  "minimum": 0
                },
                "y": {
                  "type": "number",
                  "minimum": 0
                },
                "width": {
                  "type": "number",
                  "default": 200,
                  "minimum": 0.001
                },
                "height": {
                  "type": "number",
                  "default": 20,
                  "minimum": 0.001
                },
                "fontSize": {
                  "type": "number",
                  "default": 12,
                  "minimum": 6,
                  "maximum": 72
                }
              },
              "required": [
                "newText",
                "x",
                "y"
              ]
            },
            "default": []
          },
          "flattenForm": {
            "type": "boolean",
            "default": false
          }
        },
        "description": "At least one edit is required. Text covering is visual, not secure redaction."
      },
      "PageRange": {
        "type": "object",
        "properties": {
          "start": {
            "type": "integer",
            "minimum": 1
          },
          "end": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "start",
          "end"
        ]
      },
      "AISource": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "pdf",
              "text"
            ]
          },
          "pageCount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "minItems": 1,
            "maxItems": 200
          },
          "characters": {
            "type": "integer",
            "minimum": 1,
            "maximum": 60000
          },
          "truncated": {
            "type": "boolean"
          }
        },
        "required": [
          "kind",
          "pageCount",
          "pages",
          "characters",
          "truncated"
        ],
        "description": "Only page references and extraction metadata, not raw source text. PDF references preserve original page numbers; pasted text is source page 1."
      },
      "AISummary": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "summary": {
            "type": "string",
            "maxLength": 10000
          },
          "keyPoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "maxLength": 1600
                },
                "pages": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "minItems": 1,
                  "maxItems": 200
                }
              },
              "required": [
                "text",
                "pages"
              ]
            },
            "minItems": 1,
            "maxItems": 16
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 100
            },
            "maxItems": 24
          }
        },
        "required": [
          "title",
          "summary",
          "keyPoints",
          "keywords"
        ]
      },
      "AIChat": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "string",
            "maxLength": 12000
          },
          "found": {
            "type": "boolean"
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "quote": {
                  "type": "string",
                  "description": "Exact excerpt verified against original source page after whitespace normalization.",
                  "maxLength": 2000
                }
              },
              "required": [
                "page",
                "quote"
              ]
            },
            "maxItems": 20
          }
        },
        "required": [
          "answer",
          "found",
          "citations"
        ],
        "description": "Found answers require verified citations. If found=false, answer is Not found in the supplied document. and citations is empty."
      },
      "AITranslation": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "language": {
            "type": "string",
            "maxLength": 80
          },
          "text": {
            "type": "string",
            "description": "Translated plain text with paragraph breaks. Original PDF layout is not preserved.",
            "maxLength": 120000
          }
        },
        "required": [
          "title",
          "language",
          "text"
        ]
      },
      "AIFlashcards": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "cards": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "question": {
                  "type": "string",
                  "maxLength": 1000
                },
                "answer": {
                  "type": "string",
                  "maxLength": 3000
                },
                "pages": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "minItems": 1,
                  "maxItems": 200
                }
              },
              "required": [
                "question",
                "answer",
                "pages"
              ]
            },
            "minItems": 1,
            "maxItems": 24
          }
        },
        "required": [
          "title",
          "cards"
        ]
      },
      "AIQuiz": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "questions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "question": {
                  "type": "string",
                  "maxLength": 1200
                },
                "choices": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "minItems": 2,
                  "maxItems": 6
                },
                "answerIndex": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 5,
                  "description": "Zero-based index into choices."
                },
                "explanation": {
                  "type": "string",
                  "maxLength": 2000
                },
                "pages": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "minItems": 1,
                  "maxItems": 200
                }
              },
              "required": [
                "question",
                "choices",
                "answerIndex",
                "explanation",
                "pages"
              ]
            },
            "minItems": 1,
            "maxItems": 20
          }
        },
        "required": [
          "title",
          "questions"
        ]
      },
      "AIMindMapNode": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "maxLength": 250
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "minItems": 1,
            "maxItems": 200
          },
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AIMindMapNode"
            },
            "maxItems": 20
          }
        },
        "required": [
          "label",
          "pages",
          "children"
        ],
        "description": "Tree limited to five levels and one hundred total nodes."
      },
      "AIMindMap": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "root": {
            "$ref": "#/components/schemas/AIMindMapNode"
          }
        },
        "required": [
          "title",
          "root"
        ]
      },
      "AIResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "generated": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "task": {
            "type": "string",
            "enum": [
              "summarize",
              "chat",
              "translate",
              "flashcards",
              "quiz",
              "mind-map"
            ]
          },
          "model": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/AISource"
          },
          "result": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AISummary"
              },
              {
                "$ref": "#/components/schemas/AIChat"
              },
              {
                "$ref": "#/components/schemas/AITranslation"
              },
              {
                "$ref": "#/components/schemas/AIFlashcards"
              },
              {
                "$ref": "#/components/schemas/AIQuiz"
              },
              {
                "$ref": "#/components/schemas/AIMindMap"
              }
            ]
          }
        },
        "required": [
          "success",
          "generated",
          "task",
          "model",
          "source",
          "result"
        ]
      },
      "AccountError": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable account error."
          },
          "code": {
            "type": "string",
            "description": "Stable account code, for example SESSION_REQUIRED, INVALID_SESSION, EMAIL_NOT_VERIFIED, ACCOUNT_DISABLED, INVALID_KEY_NAME, API_KEY_LIMIT, API_KEY_NOT_FOUND, RATE_LIMIT or MONTHLY_LIMIT. Native access may return INVALID_EDITOR_NONCE, EDITOR_ACCESS_NOT_CONFIGURED or NATIVE_FEATURE_NOT_INCLUDED."
          }
        }
      },
      "ServerError": {
        "type": "object",
        "required": [
          "success",
          "error",
          "detail"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "string",
            "description": "Human-readable error."
          },
          "detail": {
            "type": "string",
            "description": "Additional error description; currently repeats error."
          }
        }
      },
      "WebhookError": {
        "type": "object",
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "string",
            "description": "Webhook verification or processing error."
          }
        }
      },
      "AccountConfig": {
        "type": "object",
        "required": [
          "enabled",
          "ready",
          "supabaseUrl",
          "publishableKey"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Supabase account mode is configured."
          },
          "ready": {
            "type": "boolean",
            "description": "Required account credentials are configured; this flag does not probe database availability."
          },
          "supabaseUrl": {
            "type": "string",
            "description": "Public Supabase project URL, or empty when accounts are disabled."
          },
          "publishableKey": {
            "type": "string",
            "description": "Public client key, never the server credential. Empty when disabled."
          }
        }
      },
      "AccountUser": {
        "type": "object",
        "required": [
          "id",
          "email",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string",
            "description": "Display name, which can be empty."
          }
        }
      },
      "AccountProfile": {
        "type": "object",
        "required": [
          "id",
          "email",
          "displayName",
          "disabled",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "displayName": {
            "type": "string",
            "description": "Display name; profile fields are read-only through the Shipwave API."
          },
          "disabled": {
            "type": "boolean",
            "description": "An owner disabled processing/new key creation for this account."
          },
          "createdAt": {
            "type": "string",
            "description": "Profile creation time.",
            "format": "date-time"
          }
        }
      },
      "AccountSubscription": {
        "type": "object",
        "required": [
          "planId",
          "status",
          "currentPeriodStart",
          "currentPeriodEnd",
          "cancelAtPeriodEnd",
          "billingHold",
          "riskReason"
        ],
        "properties": {
          "planId": {
            "type": "string",
            "description": "Billing plan ID; can differ from the effective plan after a lapse."
          },
          "status": {
            "type": "string",
            "description": "Local entitlement status: free, active, trialing, incomplete, past_due, unpaid, canceled, paused or incomplete_expired. Unpaid initial active Stripe subscriptions remain incomplete locally."
          },
          "currentPeriodStart": {
            "type": "string",
            "description": "Confirmed entitlement period start, or null on Free.",
            "format": "date-time",
            "nullable": true
          },
          "currentPeriodEnd": {
            "type": "string",
            "description": "Confirmed entitlement expiry, or null on Free.",
            "format": "date-time",
            "nullable": true
          },
          "cancelAtPeriodEnd": {
            "type": "boolean",
            "description": "Cancellation is scheduled; access lasts only through the confirmed paid term."
          },
          "billingHold": {
            "type": "boolean",
            "description": "Processing is blocked for billing review even if an effective paid plan is shown."
          },
          "riskReason": {
            "type": "string",
            "description": "Owner review reason.",
            "nullable": true
          }
        }
      },
      "AccountPlan": {
        "type": "object",
        "required": [
          "id",
          "name",
          "priceCents",
          "currency",
          "features",
          "nativeFeatures"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Effective plan ID."
          },
          "name": {
            "type": "string",
            "description": "Effective plan name."
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "description": "Advertised monthly price in currency minor units, before tax."
          },
          "currency": {
            "type": "string",
            "description": "Lowercase ISO currency code."
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Server-owned feature group."
            },
            "description": "Original API feature groups on the effective plan, before account-specific overrides. Native groups are separate."
          },
          "nativeFeatures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NativeFeature"
            },
            "description": "Native groups on the effective plan, before account-specific overrides. limits.nativeFeatures contains the effective user access."
          }
        }
      },
      "AccountLimits": {
        "type": "object",
        "required": [
          "webMonthly",
          "apiMonthly",
          "requestsPerMinute",
          "maxApiKeys",
          "features",
          "nativeFeatures"
        ],
        "properties": {
          "webMonthly": {
            "type": "integer",
            "minimum": 0,
            "description": "Monthly operations for verified browser/Bearer sessions."
          },
          "apiMonthly": {
            "type": "integer",
            "minimum": 0,
            "description": "Monthly operations for personal API keys."
          },
          "requestsPerMinute": {
            "type": "integer",
            "minimum": 1,
            "description": "Fixed-minute processing limit shared by both channels."
          },
          "maxApiKeys": {
            "type": "integer",
            "minimum": 0,
            "description": "Maximum active personal API keys."
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Server-owned feature group."
            },
            "description": "Effective original API feature groups after owner overrides. These do not grant native editor rights."
          },
          "nativeFeatures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NativeFeature"
            },
            "description": "Effective native groups after owner overrides. NULL override inherits; an empty override disables native editing. Original API features are independent."
          }
        }
      },
      "AccountUsage": {
        "type": "object",
        "required": [
          "period",
          "webUsed",
          "apiUsed",
          "webRemaining",
          "apiRemaining"
        ],
        "properties": {
          "period": {
            "type": "string",
            "description": "UTC calendar month; independent of the subscription renewal date.",
            "pattern": "^\\d{4}-\\d{2}$"
          },
          "webUsed": {
            "type": "integer",
            "minimum": 0
          },
          "apiUsed": {
            "type": "integer",
            "minimum": 0
          },
          "webRemaining": {
            "type": "integer",
            "minimum": 0
          },
          "apiRemaining": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "AccountSnapshot": {
        "type": "object",
        "description": "Raw account snapshot: there is no outer success property. limits is authoritative when per-user overrides apply.",
        "required": [
          "user",
          "profile",
          "subscription",
          "plan",
          "limits",
          "usage",
          "isAdmin"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/AccountUser"
          },
          "profile": {
            "$ref": "#/components/schemas/AccountProfile"
          },
          "subscription": {
            "$ref": "#/components/schemas/AccountSubscription"
          },
          "plan": {
            "$ref": "#/components/schemas/AccountPlan"
          },
          "limits": {
            "$ref": "#/components/schemas/AccountLimits"
          },
          "usage": {
            "$ref": "#/components/schemas/AccountUsage"
          },
          "isAdmin": {
            "type": "boolean",
            "description": "Reserved owner membership; no public admin routes or client-side role controls exist."
          }
        }
      },
      "APIKeyMetadata": {
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix",
          "createdAt",
          "lastUsedAt",
          "revokedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "User-supplied trimmed key label.",
            "minLength": 1,
            "maxLength": 80
          },
          "prefix": {
            "type": "string",
            "description": "Safe 16-character display prefix; cannot authenticate.",
            "minLength": 16,
            "maxLength": 16
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "APIKeyList": {
        "type": "object",
        "required": [
          "keys"
        ],
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/APIKeyMetadata"
            },
            "description": "Up to 100 owned records. Active keys first, newest created first; then most recently revoked keys. Never includes hashes or complete secrets.",
            "maxItems": 100
          }
        }
      },
      "APIKeyCreated": {
        "type": "object",
        "required": [
          "key",
          "apiKey"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Full 256-bit secret shown only by this creation response. Copy it to your secret store now; listing cannot recover it.",
            "pattern": "^sw_live_[A-Za-z0-9_-]{43}$"
          },
          "apiKey": {
            "$ref": "#/components/schemas/APIKeyMetadata"
          }
        }
      },
      "Success": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "PublicPlanLimits": {
        "type": "object",
        "required": [
          "webMonthly",
          "apiMonthly",
          "requestsPerMinute",
          "maxApiKeys"
        ],
        "properties": {
          "webMonthly": {
            "type": "integer",
            "minimum": 0
          },
          "apiMonthly": {
            "type": "integer",
            "minimum": 0
          },
          "requestsPerMinute": {
            "type": "integer",
            "minimum": 1
          },
          "maxApiKeys": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "PublicPlan": {
        "type": "object",
        "required": [
          "id",
          "name",
          "priceCents",
          "currency",
          "interval",
          "limits",
          "features",
          "checkoutAvailable",
          "nativeFeatures"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "description": "Monthly price in currency minor units, before tax."
          },
          "currency": {
            "type": "string",
            "description": "Lowercase ISO currency code."
          },
          "interval": {
            "type": "string",
            "enum": [
              "month"
            ]
          },
          "limits": {
            "$ref": "#/components/schemas/PublicPlanLimits"
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Server-owned feature group."
            },
            "description": "Advertised original API feature groups. Provider configuration is separate."
          },
          "checkoutAvailable": {
            "type": "boolean",
            "description": "Paid plan plus configured account/Stripe/webhook credentials. Checkout still validates customer, price and tax readiness when requested."
          },
          "nativeFeatures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NativeFeature"
            },
            "description": "Advertised native editor/HTTP groups. Local editing is unmetered; native server processing still uses monthly web/API quotas."
          }
        }
      },
      "BillingPlans": {
        "type": "object",
        "required": [
          "success",
          "enabled",
          "checkoutReady",
          "testMode",
          "taxReady",
          "currency",
          "plans"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "enabled": {
            "type": "boolean",
            "description": "Stripe and account credentials are configured."
          },
          "checkoutReady": {
            "type": "boolean",
            "description": "Billing credentials and webhook signing secret are configured; not proof of a live-mode activation or successful payment."
          },
          "testMode": {
            "type": "boolean",
            "description": "true means Stripe test credentials are in use."
          },
          "taxReady": {
            "type": "boolean",
            "description": "Stripe reports active Tax settings and an active registration. This does not mean STRIPE_AUTOMATIC_TAX is enabled."
          },
          "currency": {
            "type": "string",
            "description": "Currency of the first active paid plan, or cad fallback."
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicPlan"
            },
            "description": "Active Supabase catalog ordered by sort_order."
          }
        }
      },
      "BillingRedirect": {
        "type": "object",
        "required": [
          "success",
          "url"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "url": {
            "type": "string",
            "description": "Hosted Stripe URL for this signed-in customer.",
            "format": "uri"
          }
        }
      },
      "Invoice": {
        "type": "object",
        "required": [
          "id",
          "number",
          "status",
          "amountPaid",
          "currency",
          "created",
          "hostedUrl",
          "pdfUrl"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "number": {
            "type": "string",
            "description": "Invoice number.",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "Stripe invoice state.",
            "nullable": true
          },
          "amountPaid": {
            "type": "integer",
            "minimum": 0,
            "description": "Amount paid in currency minor units."
          },
          "currency": {
            "type": "string",
            "description": "Lowercase ISO currency code."
          },
          "created": {
            "type": "integer",
            "minimum": 0,
            "description": "Unix timestamp in seconds."
          },
          "hostedUrl": {
            "type": "string",
            "description": "Hosted invoice URL.",
            "format": "uri",
            "nullable": true
          },
          "pdfUrl": {
            "type": "string",
            "description": "Invoice PDF URL.",
            "format": "uri",
            "nullable": true
          }
        }
      },
      "BillingInvoices": {
        "type": "object",
        "required": [
          "success",
          "invoices"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invoice"
            },
            "description": "Up to the latest 24 invoices belonging to this customer; empty if none exist.",
            "maxItems": 24
          }
        }
      },
      "StripeWebhookReceived": {
        "type": "object",
        "required": [
          "received"
        ],
        "properties": {
          "received": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "StripeWebhookEvent": {
        "type": "object",
        "description": "Raw Stripe event. Do not rebuild or reserialize the body before verifying Stripe-Signature. Additional Stripe properties are accepted.",
        "required": [
          "id",
          "type",
          "created",
          "livemode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stripe event ID used for idempotency."
          },
          "type": {
            "type": "string",
            "description": "An enabled Stripe event type."
          },
          "created": {
            "type": "integer",
            "minimum": 0,
            "description": "Stripe event creation timestamp in seconds."
          },
          "livemode": {
            "type": "boolean",
            "description": "Must match the configured Stripe key mode."
          },
          "data": {
            "type": "object",
            "required": [
              "object"
            ],
            "properties": {
              "object": {
                "type": "object",
                "description": "Canonical event payload. Stripe signs the original complete event, including additional event properties."
              }
            }
          }
        }
      },
      "PDFVisibleRegion": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "page",
          "x",
          "y",
          "width",
          "height"
        ],
        "description": "Rectangle in the viewed visible page after CropBox/MediaBox intersection and source rotation. Origin bottom-left. Values use raw PDF user-space units: normal pages use points; physical points = value × UserUnit. Page is one-based. The rectangle must fit that page. Presence selects exactly that page.",
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1,
            "description": "One-based source PDF page; must exist in the uploaded document."
          },
          "x": {
            "type": "number",
            "minimum": 0,
            "maximum": 100000,
            "description": "Distance from viewed visible left edge in raw PDF units."
          },
          "y": {
            "type": "number",
            "minimum": 0,
            "maximum": 100000,
            "description": "Distance from viewed visible bottom edge in raw PDF units."
          },
          "width": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 100000
          },
          "height": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 100000
          },
          "coordinateSpace": {
            "type": "string",
            "enum": [
              "visible"
            ],
            "default": "visible",
            "description": "Only visible-page coordinates are supported. Omission inside region means visible."
          }
        },
        "example": {
          "page": 1,
          "x": 36,
          "y": 48,
          "width": 120,
          "height": 60,
          "coordinateSpace": "visible"
        }
      },
      "PDFCoordinatePoint": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "x",
          "y"
        ],
        "properties": {
          "x": {
            "type": "number",
            "minimum": 0,
            "description": "Viewed visible-page x; must not exceed page width."
          },
          "y": {
            "type": "number",
            "minimum": 0,
            "description": "Viewed visible-page y; must not exceed page height."
          }
        }
      },
      "PDFSourceRectangle": {
        "type": "object",
        "required": [
          "x",
          "y",
          "width",
          "height"
        ],
        "properties": {
          "x": {
            "type": "number",
            "description": "Absolute unrotated source PDF x."
          },
          "y": {
            "type": "number",
            "description": "Absolute unrotated source PDF y."
          },
          "width": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "height": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          }
        }
      },
      "PDFCoordinateMeasurement": {
        "type": "object",
        "required": [
          "success",
          "page",
          "coordinateSpace",
          "unit",
          "userUnit",
          "width",
          "height",
          "rotation",
          "sourceBox"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "coordinateSpace": {
            "type": "string",
            "enum": [
              "visible"
            ]
          },
          "unit": {
            "type": "string",
            "enum": [
              "pt",
              "pdf-user-unit"
            ],
            "description": "pt when UserUnit=1; otherwise pdf-user-unit. Do not multiply returned region coordinates before reusing them."
          },
          "userUnit": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "PDF UserUnit. A raw coordinate unit equals userUnit/72 physical inches."
          },
          "width": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "Viewed visible-page width in raw PDF units."
          },
          "height": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "Viewed visible-page height in raw PDF units."
          },
          "rotation": {
            "type": "integer",
            "enum": [
              0,
              90,
              180,
              270
            ],
            "description": "Existing clockwise page rotation normalized to a quarter-turn."
          },
          "sourceBox": {
            "$ref": "#/components/schemas/PDFSourceRectangle",
            "description": "Unrotated source CropBox intersected with MediaBox."
          },
          "points": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "$ref": "#/components/schemas/PDFCoordinatePoint"
            },
            "description": "Echoed only when points was supplied."
          },
          "region": {
            "$ref": "#/components/schemas/PDFVisibleRegion",
            "description": "Normalized reusable rectangle; present when region or points was supplied."
          },
          "sourceRect": {
            "$ref": "#/components/schemas/PDFSourceRectangle",
            "description": "Equivalent absolute unrotated source rectangle; present when region or points was supplied. Do not reuse this as visible coordinates."
          }
        }
      },
      "PDFObjectPlacement": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "page",
          "x",
          "y",
          "width",
          "height"
        ],
        "description": "Unrotated object frame in viewed visible-page raw PDF units. X/Y are its lower-left before counterclockwise rotation about its center. All four rotated corners must fit the page. Distinct from PDFVisibleRegion, which bounds a fitted rotated footprint. Source crop and rotation are compensated. Only the selected one-based source page is changed. Physical points = raw value × UserUnit.",
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1,
            "description": "One-based source page; must exist in the uploaded document."
          },
          "x": {
            "type": "number",
            "minimum": -100000,
            "maximum": 100000,
            "description": "Unrotated frame lower-left X from visible left edge. Negative is valid only when all rotated corners fit the page."
          },
          "y": {
            "type": "number",
            "minimum": -100000,
            "maximum": 100000,
            "description": "Unrotated frame lower-left Y from visible bottom edge. Negative is valid only when all rotated corners fit the page."
          },
          "width": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 100000
          },
          "height": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 100000
          },
          "rotation": {
            "type": "number",
            "minimum": -360,
            "maximum": 360,
            "default": 0,
            "description": "Counterclockwise degrees about frame center; optional, defaults to 0."
          },
          "coordinateSpace": {
            "type": "string",
            "enum": [
              "visible"
            ],
            "default": "visible",
            "description": "Only visible-page coordinates are accepted; omitted means visible."
          }
        },
        "example": {
          "page": 1,
          "x": 100,
          "y": 400,
          "width": 240,
          "height": 100,
          "rotation": 30,
          "coordinateSpace": "visible"
        }
      },
      "PDFPlacementPreviewRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "Nonempty single line using glyphs supported by embedded Liberation Sans. Whitespace-only, newlines, unsupported glyphs and unknown body keys return 400. Control characters (including tabs), U+2028 and U+2029 are rejected."
          }
        },
        "example": {
          "text": "A"
        }
      },
      "PDFPlacementGlyphPath": {
        "type": "object",
        "required": [
          "d",
          "x",
          "y"
        ],
        "properties": {
          "d": {
            "type": "string",
            "description": "SVG glyph outline path in embedded font units; consume as geometry, not markup."
          },
          "x": {
            "type": "number",
            "description": "Glyph X origin relative to the normalized ink lower-left; raw font units."
          },
          "y": {
            "type": "number",
            "description": "Glyph Y origin relative to the normalized ink lower-left; raw font units, positive upward."
          }
        }
      },
      "PDFPlacementFontMetrics": {
        "type": "object",
        "required": [
          "unitsPerEm",
          "ascent",
          "descent",
          "width",
          "height",
          "paths"
        ],
        "properties": {
          "unitsPerEm": {
            "type": "integer",
            "minimum": 1
          },
          "ascent": {
            "type": "number"
          },
          "descent": {
            "type": "number"
          },
          "width": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "Actual combined ink width in font units, excluding external whitespace."
          },
          "height": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "Actual combined ink height in font units."
          },
          "paths": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PDFPlacementGlyphPath"
            },
            "description": "Positioned glyph outlines, normalized to the combined ink lower-left. Y increases upward. Uniformly fit width/height in the placement frame and center the result."
          }
        }
      },
      "PDFPlacementPreview": {
        "type": "object",
        "required": [
          "font",
          "fontMetrics"
        ],
        "properties": {
          "font": {
            "type": "string",
            "enum": [
              "Liberation Sans"
            ]
          },
          "fontMetrics": {
            "$ref": "#/components/schemas/PDFPlacementFontMetrics"
          }
        },
        "description": "Read-only vector outlines/metrics from the same embedded font and layout used for direct text/watermark placement. The PDF engine compensates source page rotation; preview clients apply visible placement center rotation themselves."
      },
      "NativeFeature": {
        "type": "string",
        "enum": [
          "core",
          "advanced",
          "office",
          "ocr",
          "pdfa",
          "signatures",
          "ai"
        ],
        "description": "Native editor/HTTP feature group, independent of the original API feature array. core is required for mutations; additional command features may also be required."
      },
      "LegacyEditorPlan": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "legacy"
            ]
          },
          "name": {
            "type": "string"
          }
        }
      },
      "NativeEditorAccess": {
        "type": "object",
        "required": [
          "enabled",
          "ready",
          "mode",
          "plan",
          "features",
          "leaseSeconds",
          "localEditsMetered"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "ready": {
            "type": "boolean",
            "description": "The server private signing seed matches the expected public key. This flag is not an access proof."
          },
          "mode": {
            "type": "string",
            "enum": [
              "local"
            ]
          },
          "plan": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AccountPlan"
              },
              {
                "$ref": "#/components/schemas/LegacyEditorPlan"
              }
            ]
          },
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NativeFeature"
            },
            "description": "Native editor groups. Empty disables native mutations; core must be present before any mutation. Independent of the original API features."
          },
          "leaseSeconds": {
            "type": "integer",
            "enum": [
              300
            ],
            "description": "Maximum lease duration; a paid term can shorten it."
          },
          "localEditsMetered": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "Local native editing does not debit web/API operations. Native HTTP processing does."
          }
        }
      },
      "NativeEditorLeasePayload": {
        "type": "object",
        "description": "Decoded JSON contained inside NativeEditorSignedAccess.payload. Verify the original raw UTF-8 payload string before decoding; re-serializing JSON changes the signed bytes.",
        "required": [
          "v",
          "nonce",
          "issuedAt",
          "expiresAt",
          "features",
          "mode"
        ],
        "additionalProperties": false,
        "properties": {
          "v": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "nonce": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{16,128}$"
          },
          "issuedAt": {
            "type": "integer",
            "format": "int64",
            "description": "Unix seconds."
          },
          "expiresAt": {
            "type": "integer",
            "format": "int64",
            "description": "Unix seconds; at most issuedAt + 300 and no later than the effective paid period end."
          },
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NativeFeature"
            },
            "description": "Native editor groups. Empty disables native mutations; core must be present before any mutation. Independent of the original API features.",
            "uniqueItems": true
          },
          "mode": {
            "type": "string",
            "enum": [
              "local"
            ]
          }
        }
      },
      "NativeEditorSignedAccess": {
        "type": "object",
        "required": [
          "payload",
          "signature"
        ],
        "additionalProperties": false,
        "properties": {
          "payload": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8192,
            "description": "Original compact JSON string containing NativeEditorLeasePayload. Pass its bytes unchanged to the native verifier."
          },
          "signature": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{86}$",
            "description": "64-byte Ed25519 signature encoded as unpadded base64url. The verifier uses the public key compiled into WASM."
          }
        }
      },
      "EditorLimits": {
        "type": "object",
        "required": [
          "files",
          "fileBytes",
          "uploadBytes",
          "outputBytes",
          "outputFiles",
          "steps",
          "reportBytes",
          "timeoutMs"
        ],
        "properties": {
          "files": {
            "type": "integer",
            "minimum": 0
          },
          "fileBytes": {
            "type": "integer",
            "minimum": 0
          },
          "uploadBytes": {
            "type": "integer",
            "minimum": 0
          },
          "outputBytes": {
            "type": "integer",
            "minimum": 0
          },
          "outputFiles": {
            "type": "integer",
            "minimum": 0
          },
          "steps": {
            "type": "integer",
            "minimum": 0
          },
          "reportBytes": {
            "type": "integer",
            "minimum": 0
          },
          "timeoutMs": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "EditorTool": {
        "type": "object",
        "required": [
          "name",
          "description",
          "input_schema",
          "read_only",
          "command",
          "feature",
          "allowed",
          "available",
          "entitled",
          "reason"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Typed tool name; not a native UI command ID."
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "input_schema": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Complete tool-specific JSON Schema returned by the actual CLI. Null only when the command engine is missing."
          },
          "read_only": {
            "type": "boolean"
          },
          "command": {
            "type": "string",
            "nullable": true
          },
          "feature": {
            "$ref": "#/components/schemas/NativeFeature"
          },
          "allowed": {
            "type": "boolean",
            "description": "false for hosted actions deliberately not exposed."
          },
          "available": {
            "type": "boolean",
            "description": "Requires an installed command engine and an allowed operation; tools may additionally need valid input/models/identity assets."
          },
          "entitled": {
            "type": "boolean",
            "description": "The current account has core and this tool’s native feature."
          },
          "reason": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "EditorTools": {
        "type": "object",
        "required": [
          "success",
          "engine",
          "version",
          "available",
          "limits",
          "tools"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "engine": {
            "type": "string",
            "enum": [
              "PDFCraft"
            ]
          },
          "version": {
            "type": "string"
          },
          "available": {
            "type": "boolean"
          },
          "limits": {
            "$ref": "#/components/schemas/EditorLimits"
          },
          "tools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EditorTool"
            }
          }
        }
      },
      "EditorStep": {
        "type": "object",
        "required": [
          "tool",
          "args"
        ],
        "properties": {
          "tool": {
            "type": "string",
            "enum": [
              "doc_bates_multi",
              "doc_fix_hairlines",
              "attachment_add",
              "attachment_delete",
              "doc_convert_colours",
              "attachment_edit",
              "doc_open",
              "doc_list",
              "doc_info",
              "doc_close",
              "doc_save",
              "doc_set_info",
              "page_render",
              "model_render",
              "object_list",
              "object_move",
              "object_copy",
              "object_paste",
              "text_word_count",
              "text_extract",
              "text_find",
              "text_replace",
              "page_rotate",
              "page_enhance_camera",
              "page_enhance_scan",
              "page_delete",
              "page_move",
              "page_reverse",
              "page_insert_blank",
              "page_insert_file",
              "page_extract",
              "doc_combine",
              "doc_create_multiple",
              "doc_split",
              "bookmark_list",
              "bookmark_add",
              "bookmark_export",
              "bookmark_import",
              "bookmark_copy",
              "bookmark_rename",
              "bookmark_delete",
              "bookmark_move",
              "bookmark_set_page",
              "bookmark_set_style",
              "bookmark_from_structure",
              "text_styles",
              "bookmark_from_text_styles",
              "page_number",
              "form_fields",
              "form_fill",
              "form_focus",
              "form_reset",
              "form_add_field",
              "form_add_field_table",
              "stamp_custom",
              "model_add",
              "form_set_image",
              "form_set_props",
              "form_tab_order",
              "form_calculation_order",
              "doc_export_data",
              "doc_import_data",
              "form_delete_field",
              "redact_mark",
              "redact_apply",
              "redact_clear",
              "doc_hidden_info",
              "doc_remove_hidden",
              "doc_audit_redactions",
              "content_list",
              "page_add_text",
              "page_add_image",
              "content_update",
              "content_copy",
              "content_delete",
              "link_list",
              "link_add",
              "link_edit",
              "link_delete",
              "links_from_urls",
              "links_remove",
              "measure_distance",
              "measure_perimeter",
              "measure_area",
              "measure_info",
              "measure_list",
              "measure_scale",
              "measure_snap",
              "measure_export",
              "comment_list",
              "comment_add",
              "comment_reply",
              "comment_set_status",
              "sign_list",
              "sign_document",
              "comment_mark",
              "comment_lock",
              "layer_set",
              "comments_hide",
              "view_reading_colors",
              "comments_summarize",
              "comment_edit",
              "comment_image_preview",
              "comment_delete",
              "comment_popup",
              "comments_copy",
              "comments_paste",
              "doc_protect",
              "doc_unprotect",
              "page_replace",
              "page_duplicate",
              "page_templates",
              "page_template_spawn",
              "page_template_set_hidden",
              "page_transition_set",
              "page_set_box",
              "doc_header_footer",
              "doc_watermark",
              "doc_background",
              "doc_printer_marks",
              "doc_backdrops",
              "doc_remove_marks",
              "doc_export_images",
              "accessibility_autotag_preview",
              "accessibility_autotag_apply",
              "accessibility_autotag_form_fields",
              "accessibility_check",
              "accessibility_find_untagged",
              "accessibility_report",
              "accessibility_review_record",
              "accessibility_review_save",
              "accessibility_review_load",
              "accessibility_review_html",
              "accessibility_fix",
              "accessibility_figures",
              "accessibility_set_alt",
              "accessibility_tags",
              "accessibility_tag_content",
              "accessibility_set_tag_property",
              "accessibility_mark_tag_artifact",
              "accessibility_layout_table_to_blocks",
              "accessibility_move_tag",
              "form_merge_data",
              "js_document_scripts",
              "js_set_document_script",
              "form_set_script",
              "doc_export_office",
              "pdfa_verify",
              "print_readiness",
              "pdfa_convert",
              "standards_remove_id",
              "action_list",
              "doc_compare",
              "doc_compare_report",
              "doc_compare_mark",
              "form_detect_fields",
              "form_actions",
              "form_set_actions",
              "ocr_recognize",
              "ocr_words",
              "ocr_review_apply",
              "ocr_dictionary",
              "ocr_recognize_files",
              "ocr_status",
              "doc_export_all_images",
              "doc_export_text",
              "fill_sign_add",
              "fill_sign_date_format",
              "doc_create",
              "doc_reduce",
              "doc_initial_view",
              "doc_audit_space",
              "text_lines",
              "image_hit",
              "page_images",
              "image_edit",
              "image_save",
              "text_font_import",
              "text_fonts",
              "text_prepare",
              "text_paragraphs",
              "text_edit_layout",
              "text_edit",
              "text_script",
              "doc_revisions",
              "doc_open_revision",
              "doc_optimize",
              "doc_flatten",
              "xfa_to_static",
              "edit_undo",
              "edit_redo",
              "doc_inspect",
              "render_preview"
            ],
            "description": "An allowed name from GET /api/editor/tools; args follows that entry’s input_schema."
          },
          "args": {
            "type": "object",
            "additionalProperties": true
          },
          "out": {
            "type": "string",
            "description": "Optional simple filename for binary image output, such as preview.png. Not a filesystem path."
          }
        }
      },
      "EditorFile": {
        "type": "object",
        "required": [
          "name",
          "bytes",
          "contentType"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Request-local generated filename."
          },
          "bytes": {
            "type": "integer",
            "minimum": 0
          },
          "contentType": {
            "type": "string"
          }
        }
      },
      "EditorRunReport": {
        "type": "object",
        "required": [
          "success",
          "engine",
          "inputs",
          "outputs",
          "report"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "engine": {
            "type": "string",
            "enum": [
              "PDFCraft"
            ]
          },
          "inputs": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "originalName",
                "bytes"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Alias such as input1.pdf."
                },
                "originalName": {
                  "type": "string"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EditorFile"
            }
          },
          "report": {
            "$ref": "#/components/schemas/EditorExecutionReport"
          }
        }
      },
      "EditorFeatures": {
        "type": "object",
        "required": [
          "success",
          "schemaVersion",
          "engine",
          "upstreamVersion",
          "categories",
          "groups",
          "commands",
          "commandFeatures",
          "automation",
          "shipwave",
          "http",
          "notes"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "schemaVersion": {
            "type": "integer",
            "minimum": 0
          },
          "engine": {
            "type": "string"
          },
          "upstreamVersion": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "All 23 native tool groups and 152 source-declared rows, including truthful ready/planned/provider states."
          },
          "commands": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "All 223 engine command IDs with native feature requirements. Viewer commands are not HTTP mutations."
          },
          "commandFeatures": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            }
          },
          "automation": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "All 215 typed automation tool definitions; allowed/available HTTP status comes from /api/editor/tools."
          },
          "shipwave": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "All 64 Shipwave entries, including 63 original processing tools and one informational entry."
          },
          "http": {
            "type": "object",
            "required": [
              "catalog",
              "run",
              "available"
            ],
            "properties": {
              "catalog": {
                "type": "string"
              },
              "run": {
                "type": "string"
              },
              "available": {
                "type": "boolean"
              }
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "commandToolAliases": {
            "type": "object",
            "description": "Verified semantic native command ID → aliases for shared typed HTTP tools. Each record has a typed tool name and partial argument hints; callers must still supply required fields and satisfy that tool’s plan/safety restrictions.",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "tool",
                  "args"
                ],
                "properties": {
                  "tool": {
                    "type": "string"
                  },
                  "args": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "note": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "commandHttpFallbacks": {
            "type": "object",
            "description": "Separate existing Shipwave service alternatives for planned/provider native rows. Does not change native UI availability.",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "toolId",
                  "method",
                  "endpoint",
                  "note"
                ],
                "properties": {
                  "toolId": {
                    "type": "string"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "POST"
                    ]
                  },
                  "endpoint": {
                    "type": "string"
                  },
                  "args": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "note": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "EditorExecutionReport": {
        "type": "object",
        "required": [
          "ok",
          "steps"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "step",
                "tool",
                "status"
              ],
              "properties": {
                "step": {
                  "type": "integer",
                  "minimum": 1
                },
                "tool": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ok",
                    "error",
                    "skipped"
                  ]
                },
                "result": {
                  "type": "array",
                  "items": {},
                  "description": "Tool-specific JSON outputs, or image metadata when the step has out."
                },
                "error": {
                  "type": "string",
                  "description": "Present for a failed step."
                }
              }
            }
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing, invalid or expired credentials. Account and billing management require a verified Supabase session; user API keys are for processing only.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Processing is unavailable to this account: email confirmation required, account disabled, billing review hold, or requested feature not included in the effective plan.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Request rate, account monthly allowance, or server processing capacity reached. Retry after the indicated interval when Retry-After is supplied.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Optional delay in seconds before retrying; monthly allowance resets at the next UTC calendar month.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    }
  }
}
