> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdocs.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Export the current document as a styled .docx (default), .pdf, .html, .md, or .txt file with full fidelity.

> Round-trips the document through the original docx renderer, preserving tables, borders, shading, alternating row colors, headers, footers, fonts, inline styling, and embedded images. Two modes: pass html directly to export ad-hoc content, OR pass session_id to export the session's current state. Format options: 'docx' (default, native Open XML, best for programmatic processing or mail merge), 'pdf', 'html', 'markdown', or 'txt' ('doc' is a legacy Word-compatible HTML alias). Fidelity is the differentiator vs naive HTML to docx converters.



## OpenAPI

````yaml /openapi.json post /v1/documents/export
openapi: 3.1.0
info:
  title: Universal Document AI API
  description: AI-powered document editing with multi-tenant organization support
  version: 2.0.0
servers: []
security: []
paths:
  /v1/documents/export:
    post:
      tags:
        - v1
        - mcp
      summary: >-
        Export the current document as a styled .docx (default), .pdf, .html,
        .md, or .txt file with full fidelity.
      description: >-
        Round-trips the document through the original docx renderer, preserving
        tables, borders, shading, alternating row colors, headers, footers,
        fonts, inline styling, and embedded images. Two modes: pass html
        directly to export ad-hoc content, OR pass session_id to export the
        session's current state. Format options: 'docx' (default, native Open
        XML, best for programmatic processing or mail merge), 'pdf', 'html',
        'markdown', or 'txt' ('doc' is a legacy Word-compatible HTML alias).
        Fidelity is the differentiator vs naive HTML to docx converters.
      operationId: export_document
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ExportRequest:
      properties:
        session_id:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Session Id
          description: >-
            Session ID to export from (the document is taken from the session).
            Required if html is omitted.
        html:
          anyOf:
            - type: string
              maxLength: 200000000
            - type: 'null'
          title: Html
          description: >-
            HTML content to export inline. Used instead of the session document
            if provided.
        format:
          type: string
          enum:
            - docx
            - pdf
            - html
            - markdown
            - txt
            - doc
          title: Format
          description: Export format. One of docx (default), pdf, html, markdown, txt.
          default: docx
        options:
          $ref: '#/components/schemas/ExportOptions'
          description: Customization (paper, margins, filename, watermark, etc.).
        filename:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Filename
          description: DEPRECATED. Use options.filename. Top-level kept for legacy callers.
        upload_id:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Upload Id
          description: >-
            ID returned by /v1/uploads (large-document upload flow, for payloads
            above ~25 MB). When set, the route fetches the HTML body from the
            uploaded payload instead of using the html field.
      type: object
      title: ExportRequest
      description: |-
        Unified request body for POST /v1/documents/export.

        Backward-compat notes:
        - Top-level ``filename`` is retained for legacy clients that sent only
          ``{ html }`` and relied on the filename being auto-extracted from the
          first <h1>. New clients should use ``options.filename`` —
          options.filename wins when both are set.
        - ``format`` defaults to "docx". Legacy callers passing format="doc"
          explicitly keep working during a short back-compat window.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ExportOptions:
      properties:
        paper_size:
          type: string
          enum:
            - A4
            - Letter
            - A3
            - Legal
          title: Paper Size
          description: Page size for DOCX/PDF/legacy .doc. HTML/MD/TXT exports ignore.
          default: Letter
        orientation:
          type: string
          enum:
            - portrait
            - landscape
          title: Orientation
          description: Page orientation for DOCX/PDF/legacy .doc.
          default: portrait
        margins:
          type: string
          enum:
            - narrow
            - normal
            - wide
            - custom
          title: Margins
          description: >-
            Page margins preset. 'narrow' = 0.5in, 'normal' = 1.0in, 'wide' =
            1.5in. 'custom' uses custom_margins_inches.
          default: normal
        custom_margins_inches:
          anyOf:
            - additionalProperties:
                type: number
              propertyNames:
                enum:
                  - top
                  - right
                  - bottom
                  - left
              type: object
            - type: 'null'
          title: Custom Margins Inches
          description: Required when margins='custom'. Each value 0.25-3.0 inches.
        filename:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Filename
          description: >-
            Custom filename (no extension). Auto-detected from first <h1> if
            unset.
        embed_images:
          type: boolean
          title: Embed Images
          description: >-
            HTML export only. When True, images are base64-embedded for offline
            portability (raises size cap to 150 MB). When False, images are
            referenced by URL (smaller file, online-only).
          default: false
        watermark_text:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Watermark Text
          description: PDF only. Optional text watermark overlaid on every page.
        watermark_opacity:
          type: number
          maximum: 1
          minimum: 0.05
          title: Watermark Opacity
          description: PDF watermark opacity, 0.05-1.0.
          default: 0.3
      type: object
      title: ExportOptions
      description: |-
        User-facing export customisation (page size, orientation, margins,
        filename, watermark). Sent on every export request.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````