> ## 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.

# Extract Data

> Extract structured data from a document using a JSON schema. Combines parsing and schema-based extraction in one call.



## OpenAPI

````yaml api-reference/openapi.json post /extract
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:
  /extract:
    post:
      tags:
        - Document Processing
      summary: Extract Data
      description: >-
        Extract structured data from a document using a JSON schema. Combines
        parsing and schema-based extraction in one call.
      operationId: extract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
      responses:
        '200':
          description: Successful extraction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    ExtractRequest:
      type: object
      required:
        - input
        - schema
      properties:
        input:
          $ref: '#/components/schemas/DocumentInput'
        schema:
          type: object
          description: JSON Schema defining the data to extract from the document.
        system_prompt:
          type: string
          description: Custom system prompt for the extraction model.
        parsing:
          $ref: '#/components/schemas/ParseOptions'
    ExtractResponse:
      type: object
      required:
        - job_id
        - result
      properties:
        job_id:
          type: string
        duration:
          type: number
        usage:
          $ref: '#/components/schemas/Usage'
        result:
          type: object
          description: Extracted data matching the provided schema.
    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'
    ParseOptions:
      type: object
      description: Configuration for the parsing step. Ignored when using jobid:// input.
      properties:
        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'
    Usage:
      type: object
      properties:
        num_pages:
          type: integer
          description: Number of pages processed.
        credits:
          type: number
          nullable: true
          description: Credits consumed.
    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.
    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
  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'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Use your Aifano API key (starts with `ak_live_`)
        as the Bearer token.

````