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

# Asynchronous Extraction

> Queue one or more documents for extraction. Accepts a single input or a list of up to 50 inputs for batch processing.

Single input returns a `V2Response` with `record_id`. List input returns a `BatchResponse` with per-item status.

> **Tip:** You can save and reuse extraction settings by creating a config via [Create Config](/docs/api-reference-v2/configuration-management/create-config). Pass the returned `config_id` instead of repeating `extraction_config` each time.



## OpenAPI

````yaml /openapi-extraction-v2.json post /api/v2/extract/async
openapi: 3.1.0
info:
  title: Nanonets V2 API
  description: >-
    Stateful document processing API with file management, reusable configs, and
    JSON-body endpoints for parse, extract, and classify operations.


    **Key differences from V1:**

    - JSON request bodies instead of multipart/form-data

    - Upload files once via `POST /files`, then reference them with
    `file://<uuid>` URIs

    - Save and reuse processing configurations via `config://<uuid>` URIs

    - Batch processing via list inputs on async endpoints (up to 50 items)

    - Document classification with `document` and `split` modes
  version: 2.0.0
  contact:
    name: Nanonets Support
    email: info@nanonets.com
servers:
  - url: https://extraction-api.nanonets.com
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v2/extract/async:
    post:
      tags:
        - Document Extraction
      summary: Asynchronous Extraction
      description: >-
        Queue one or more documents for extraction. Accepts a single input or a
        list of up to 50 inputs for batch processing.


        Single input returns a `V2Response` with `record_id`. List input returns
        a `BatchResponse` with per-item status.


        > **Tip:** You can save and reuse extraction settings by creating a
        config via [Create
        Config](/docs/api-reference-v2/configuration-management/create-config).
        Pass the returned `config_id` instead of repeating `extraction_config`
        each time.
      operationId: v2_extract_async
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
            examples:
              single:
                summary: Single document
                value:
                  input: file://a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  extraction_config:
                    output_format: json
                    json_options:
                      - invoice_number
                      - date
                      - total
              batch:
                summary: Batch (up to 50)
                value:
                  input:
                    - file://a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    - file://c3d4e5f6-a7b8-9012-cdef-a12345678901
                  config_id: config://b2c3d4e5-f6a7-8901-bcde-f12345678901
      responses:
        '202':
          description: Job(s) queued
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/V2Response'
                  - $ref: '#/components/schemas/BatchResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    ExtractRequest:
      type: object
      required:
        - input
      properties:
        input:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
              maxItems: 50
          description: '`file://<uuid>` URI or public URL. Async accepts a list (max 50).'
        config_id:
          type: string
          description: '`config://<uuid>` of a saved extract config'
        extraction_config:
          $ref: '#/components/schemas/ExtractConfig'
    V2Response:
      type: object
      required:
        - success
        - message
      properties:
        success:
          type: boolean
        message:
          type: string
        record_id:
          type: string
          description: Job ID for retrieving results
        file_id:
          type: string
          description: '`file://<uuid>` reference'
        config_id:
          type: string
          description: '`config://<uuid>` reference'
        status:
          type: string
          enum:
            - completed
            - processing
            - failed
        result:
          $ref: '#/components/schemas/V2Result'
        processing_time:
          type: number
          description: Time in seconds
        filename:
          type: string
        output_format:
          type: string
        file_size:
          type: integer
          description: Size in bytes
    BatchResponse:
      type: object
      required:
        - success
        - message
        - total
        - items
      properties:
        success:
          type: boolean
        message:
          type: string
        batch_id:
          type: string
          format: uuid
        total:
          type: integer
        items:
          type: array
          items:
            $ref: '#/components/schemas/BatchItemStatus'
    ExtractConfig:
      type: object
      properties:
        output_format:
          type: string
          enum:
            - json
            - csv
          default: json
          description: Output format
        json_options:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
            - type: object
          description: >-
            Field list `["field1", "field2"]`, JSON schema `{...}`, or keyword
            (`hierarchy_output`, `table-of-contents`)
        csv_options:
          type: string
          description: 'CSV options: `table`, `toc`'
        custom_instructions:
          type: string
          maxLength: 8000
          description: Custom extraction instructions
        prompt_mode:
          type: string
          enum:
            - append
            - replace
          default: append
        include_metadata:
          type: string
          description: 'Comma-separated: `confidence_score`, `bounding_boxes`'
    V2Result:
      type: object
      properties:
        content:
          oneOf:
            - type: string
            - type: object
            - type: array
          description: Extracted or parsed content
        elements:
          type: array
          items:
            type: object
          description: >-
            Element-wise breakup with bounding boxes (parse only, when metadata
            requested)
        overall_confidence:
          type: integer
          minimum: 0
          maximum: 100
          description: Document-level confidence score
        page_confidence:
          type: object
          additionalProperties:
            type: integer
          description: Per-page confidence scores
        confidence_source:
          type: string
          description: Source of confidence scores
    BatchItemStatus:
      type: object
      required:
        - input
        - status
      properties:
        input:
          type: string
        record_id:
          type: string
        file_id:
          type: string
        status:
          type: string
          enum:
            - queued
            - completed
            - failed
        error:
          type: string
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    ValidationError:
      type: object
      required:
        - loc
        - msg
        - type
      properties:
        loc:
          type: array
          items:
            oneOf:
              - type: string
              - type: integer
        msg:
          type: string
        type:
          type: string
  responses:
    BadRequest:
      description: Invalid input
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HTTPValidationError'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'API key as Bearer token: `Authorization: Bearer YOUR_API_KEY`'

````