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

# Parse Document

> Convert a document into structured JSON with text, tables, and figures. Returns chunks with content, bounding boxes, and block-level detail.



## OpenAPI

````yaml api-reference/openapi.json post /parse
openapi: 3.1.0
info:
  title: Aifano Platform API
  version: 1.0.0
  description: >-
    Transform unstructured documents into structured data. Parse, extract,
    split, and edit documents at scale.
servers:
  - url: https://platform.aifano.com
    description: Production
security:
  - BearerAuth: []
paths:
  /parse:
    post:
      tags:
        - Document Processing
      summary: Parse Document
      description: >-
        Convert a document into structured JSON with text, tables, and figures.
        Returns chunks with content, bounding boxes, and block-level detail.
      operationId: parse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ParseRequest'
      responses:
        '200':
          description: Successful parse response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ParseResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    ParseRequest:
      type: object
      required:
        - input
      properties:
        input:
          $ref: '#/components/schemas/DocumentInput'
        enhance:
          $ref: '#/components/schemas/Enhance'
        retrieval:
          $ref: '#/components/schemas/Retrieval'
        formatting:
          $ref: '#/components/schemas/Formatting'
        spreadsheet:
          $ref: '#/components/schemas/Spreadsheet'
        settings:
          $ref: '#/components/schemas/Settings'
    ParseResponse:
      type: object
      required:
        - job_id
        - duration
        - usage
        - result
      properties:
        job_id:
          type: string
          description: Unique job identifier.
        duration:
          type: number
          description: Processing time in seconds.
        usage:
          $ref: '#/components/schemas/Usage'
        result:
          description: Parse result — either inline (full) or as a URL for large responses.
          oneOf:
            - $ref: '#/components/schemas/FullResult'
            - $ref: '#/components/schemas/UrlResult'
    DocumentInput:
      description: >-
        The document to process. Accepts: (1) a public URL, (2) a presigned S3
        URL, (3) an `aifano://file_id` from /upload, or (4) a `jobid://job_id`
        from a previous /parse call.
      oneOf:
        - type: string
          description: URL or aifano:// reference
        - $ref: '#/components/schemas/UploadResponse'
    Enhance:
      type: object
      properties:
        agentic:
          type: array
          items:
            type: object
            properties:
              scope:
                type: string
                enum:
                  - table
                  - figure
                  - text
              prompt:
                type: string
                nullable: true
            required:
              - scope
          default: []
          description: >-
            Use vision language models to enhance accuracy for specific block
            types.
        summarize_figures:
          type: boolean
          default: true
          description: Summarize figures using a vision model.
    Retrieval:
      type: object
      properties:
        chunking:
          type: object
          properties:
            chunk_mode:
              type: string
              enum:
                - variable
                - section
                - page
                - disabled
                - block
                - page_sections
              default: disabled
            chunk_size:
              type: integer
              nullable: true
        filter_blocks:
          type: array
          items:
            type: string
          default: []
        embedding_optimized:
          type: boolean
          default: false
    Formatting:
      type: object
      properties:
        add_page_markers:
          type: boolean
          default: false
        table_output_format:
          type: string
          enum:
            - html
            - json
            - md
            - jsonbbox
            - dynamic
            - csv
          default: dynamic
        merge_tables:
          type: boolean
          default: false
        include:
          type: array
          items:
            type: string
            enum:
              - change_tracking
              - highlight
              - comments
              - hyperlinks
              - signatures
          default: []
    Spreadsheet:
      type: object
      properties:
        split_large_tables:
          type: object
          properties:
            enabled:
              type: boolean
              default: true
            size:
              type: integer
              default: 50
        clustering:
          type: string
          enum:
            - accurate
            - fast
            - disabled
          default: accurate
    Settings:
      type: object
      properties:
        ocr_system:
          type: string
          enum:
            - standard
            - legacy
          default: standard
          description: >-
            Standard is the best multilingual OCR. Legacy supports only Germanic
            languages.
        extraction_mode:
          type: string
          enum:
            - ocr
            - hybrid
          default: hybrid
          description: Hybrid combines OCR with embedded PDF text for best accuracy.
        force_url_result:
          type: boolean
          default: false
        return_ocr_data:
          type: boolean
          default: false
        return_images:
          type: array
          items:
            type: string
            enum:
              - figure
              - table
          default: []
        page_range:
          type: object
          nullable: true
          properties:
            start:
              type: integer
            end:
              type: integer
        timeout:
          type: number
          nullable: true
        document_password:
          type: string
          nullable: true
    Usage:
      type: object
      properties:
        num_pages:
          type: integer
          description: Number of pages processed.
        credits:
          type: number
          nullable: true
          description: Credits consumed.
    FullResult:
      type: object
      required:
        - type
        - chunks
      properties:
        type:
          type: string
          enum:
            - full
        chunks:
          type: array
          items:
            $ref: '#/components/schemas/Chunk'
    UrlResult:
      type: object
      required:
        - type
        - url
        - result_id
      properties:
        type:
          type: string
          enum:
            - url
        url:
          type: string
          description: Presigned URL to download the full result.
        result_id:
          type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message.
    ValidationErrorResponse:
      type: object
      properties:
        detail:
          type: array
          items:
            type: object
            properties:
              loc:
                type: array
                items: {}
              msg:
                type: string
              type:
                type: string
    UploadResponse:
      type: object
      required:
        - file_id
      properties:
        file_id:
          type: string
          description: File reference in `aifano://file_id` format.
        presigned_url:
          type: string
          nullable: true
          description: Presigned URL for direct access.
    Chunk:
      type: object
      required:
        - content
        - embed
        - blocks
      properties:
        content:
          type: string
          description: Extracted text content.
        embed:
          type: string
          description: Content optimized for embedding/retrieval.
        enriched:
          type: string
          nullable: true
        blocks:
          type: array
          items:
            $ref: '#/components/schemas/Block'
    Block:
      type: object
      required:
        - type
        - bbox
        - content
      properties:
        type:
          type: string
          enum:
            - Header
            - Footer
            - Title
            - Section Header
            - Page Number
            - List Item
            - Figure
            - Table
            - Key Value
            - Text
            - Comment
            - Signature
        bbox:
          $ref: '#/components/schemas/BoundingBox'
        content:
          type: string
        confidence:
          type: string
          enum:
            - low
            - high
          nullable: true
    BoundingBox:
      type: object
      required:
        - left
        - top
        - width
        - height
        - page
      properties:
        left:
          type: number
        top:
          type: number
        width:
          type: number
        height:
          type: number
        page:
          type: integer
          description: Page number (1-indexed).
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized - invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Use your Aifano API key (starts with `ak_live_`)
        as the Bearer token.

````