openapi: "3.1.0"
info:
  title: MiOffice API
  version: "1.0.0"
  description: >
    AI-Powered Workspace for Documents, Images, Video, Audio & more.
    Files are processed locally in your browser via WebAssembly — they never leave your device. AI tools process on secure GPU servers and files are deleted immediately after processing.
    No signup required.
servers:
  - url: https://mioffice.ai
    description: Production

paths:
  /api/pdf-process:
    post:
      operationId: processPdf
      summary: Process PDF files (merge, split, compress, convert)
      description: >
        Upload a PDF file with an action to process it.
        Supported actions: merge (multiple files), split, compress, docToPdf, xlsxToPdf.
        For merge, upload multiple files. For split, specify page ranges.
        Max file size: 100MB. Rate limit: 15 requests/hour.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [action, file]
              properties:
                action:
                  type: string
                  enum: [compress, merge, split, docToPdf, xlsxToPdf]
                  description: The processing action to perform
                file:
                  type: string
                  format: binary
                  description: The PDF file to process
                files:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: Multiple PDF files (for merge action)
                pages:
                  type: string
                  description: Page ranges for split (e.g. "1-3,5,7-9")
                quality:
                  type: string
                  enum: [low, medium, high]
                  default: medium
                  description: Compression quality level
      responses:
        "200":
          description: Processed file
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        "413":
          description: File too large (max 100MB)
        "429":
          description: Rate limit exceeded

  /api/image-process:
    post:
      operationId: processImage
      summary: Process images (compress, resize, convert, rotate)
      description: >
        Upload an image with an action to process it.
        Supported actions: compress, resize, rotate, convert, heicToJpg,
        webpToPng, webpToJpg, pngToWebp, jpgToWebp, avifToJpg.
        Max file size: 25MB. Rate limit: 30 requests/hour.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [action, file]
              properties:
                action:
                  type: string
                  enum: [compress, resize, rotate, convert, heicToJpg, webpToPng, webpToJpg, pngToWebp, jpgToWebp, avifToJpg]
                  description: The processing action to perform
                file:
                  type: string
                  format: binary
                  description: The image file to process
                quality:
                  type: integer
                  minimum: 1
                  maximum: 100
                  default: 80
                  description: Output quality (1-100)
                width:
                  type: integer
                  description: Target width in pixels (for resize)
                height:
                  type: integer
                  description: Target height in pixels (for resize)
                format:
                  type: string
                  enum: [jpeg, png, webp, avif]
                  description: Output format (for convert action)
                rotation:
                  type: integer
                  enum: [90, 180, 270]
                  description: Rotation degrees (for rotate action)
      responses:
        "200":
          description: Processed image
          content:
            image/*:
              schema:
                type: string
                format: binary
        "413":
          description: File too large (max 25MB)
        "429":
          description: Rate limit exceeded

  /api/ai-process:
    post:
      operationId: processAI
      summary: AI-powered image processing (remove background, upscale)
      description: >
        Upload an image for AI processing. Supported actions:
        removeBackground (transparent PNG output), upscale (2x/4x enlargement).
        Max file size: 10MB. Rate limit: 10 requests/hour.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [action, file]
              properties:
                action:
                  type: string
                  enum: [removeBackground, upscale]
                  description: The AI action to perform
                file:
                  type: string
                  format: binary
                  description: The image file to process
                scale:
                  type: integer
                  enum: [2, 4]
                  default: 2
                  description: Upscale factor (for upscale action)
      responses:
        "200":
          description: Processed image
          content:
            image/png:
              schema:
                type: string
                format: binary
        "413":
          description: File too large (max 10MB)
        "429":
          description: Rate limit exceeded
