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

# Synchronous Extraction

> Extract structured data from a document synchronously as JSON or CSV.

Provide a `file://<uuid>` URI or public URL. Optionally specify fields to extract via `json_options` or reference a saved config.

> **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/sync
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/sync:
    post:
      tags:
        - Document Extraction
      summary: Synchronous Extraction
      description: >-
        Extract structured data from a document synchronously as JSON or CSV.


        Provide a `file://<uuid>` URI or public URL. Optionally specify fields
        to extract via `json_options` or reference a saved config.


        > **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_sync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
            examples:
              json_fields:
                summary: Extract specific fields as JSON
                value:
                  input: file://a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  extraction_config:
                    output_format: json
                    json_options:
                      - invoice_number
                      - date
                      - total
                      - vendor
              csv_table:
                summary: Extract tables as CSV
                value:
                  input: https://example.com/report.pdf
                  extraction_config:
                    output_format: csv
                    csv_options: table
              with_metadata:
                summary: JSON with confidence scores and bounding boxes
                value:
                  input: file://a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  extraction_config:
                    output_format: json
                    json_options:
                      - invoice_number
                      - total
                    include_metadata: confidence_score,bounding_boxes
      responses:
        '200':
          description: Extraction completed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2Response'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '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
    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
    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'
    NotFound:
      description: Resource not found
      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`'

````