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

# Ingest

> Process documents with OCR and ingest them into Unstructured.

This endpoint performs optical character recognition on documents and stores the extracted data.

## Request Body

| Field                   | Type           | Description                                                |
|-------------------------|----------------|------------------------------------------------------------|
| `data_connector_name`   | `str`          | Name of the data connector to use.                         |
| `file_names`            | `List[str]`    | Specific files to process. If omitted, processes all.      |
| `job_id`                | `str`          | Custom job ID for tracking. Auto-generated if not provided.|
| `clean_up_out_of_sync`  | `bool`         | Remove files from VDB not in source. Default: `true`.      |
| `file_count_to_run`     | `int`          | Limit number of files to process.                          |
| `use_llm`               | `bool`         | Use LLM for enhanced extraction. Default: `false`.         |

## Response

- **200**: OCR job started successfully  
    - Returns: Job tracking information
- **400**: Bad Request (e.g., invalid data connector, unsupported VDB type)
- **500**: Internal Server Error

## Example

```json
{
  "data_connector_name": "my-documents",
  "use_llm": true,
  "clean_up_out_of_sync": true,
  "file_count_to_run": 100
}
```



## OpenAPI

````yaml /deasy-openapi-stainless.yml post /ocr/ingest
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: /rest/unstructured
security: []
paths:
  /ocr/ingest:
    post:
      tags:
        - Data Connectors
      summary: Ingest
      description: >-
        Process documents with OCR and ingest them into Unstructured.


        This endpoint performs optical character recognition on documents and
        stores the extracted data.


        ## Request Body


        | Field                   | Type           |
        Description                                                |

        |-------------------------|----------------|------------------------------------------------------------|

        | `data_connector_name`   | `str`          | Name of the data connector
        to use.                         |

        | `file_names`            | `List[str]`    | Specific files to process.
        If omitted, processes all.      |

        | `job_id`                | `str`          | Custom job ID for tracking.
        Auto-generated if not provided.|

        | `clean_up_out_of_sync`  | `bool`         | Remove files from VDB not
        in source. Default: `true`.      |

        | `file_count_to_run`     | `int`          | Limit number of files to
        process.                          |

        | `use_llm`               | `bool`         | Use LLM for enhanced
        extraction. Default: `false`.         |


        ## Response


        - **200**: OCR job started successfully  
            - Returns: Job tracking information
        - **400**: Bad Request (e.g., invalid data connector, unsupported VDB
        type)

        - **500**: Internal Server Error


        ## Example


        ```json

        {
          "data_connector_name": "my-documents",
          "use_llm": true,
          "clean_up_out_of_sync": true,
          "file_count_to_run": 100
        }

        ```
      operationId: ocr_ingest_route_ocr_ingest_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OCRIngestRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '403':
          description: Missing token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '500':
          description: >-
            Internal Server Error. An unexpected error occurred while processing
            the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
      security:
        - BasicAuth: []
        - BearerAuth: []
          UserIdAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from unstructured import UnstructuredClient

            client = UnstructuredClient(
                username=os.environ.get("UNSTRUCTURED_USERNAME"),  # This is the default and can be omitted
                password=os.environ.get("UNSTRUCTURED_PASSWORD"),  # This is the default and can be omitted
            )
            response = client.data_source.ingest(
                data_connector_name="data_connector_name",
            )
            print(response)
        - lang: JavaScript
          source: >-
            import UnstructuredClient from 'unstructured-sdk';


            const client = new UnstructuredClient({
              authMethod: 'My Auth Method',
              username: process.env['UNSTRUCTURED_USERNAME'], // This is the default and can be omitted
              password: process.env['UNSTRUCTURED_PASSWORD'], // This is the default and can be omitted
            });


            const response = await client.dataSource.ingest({
            data_connector_name: 'data_connector_name' });


            console.log(response);
components:
  schemas:
    OCRIngestRequest:
      properties:
        data_connector_name:
          type: string
          title: Data Connector Name
        file_names:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: File Names
        job_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Job Id
        clean_up_out_of_sync:
          type: boolean
          title: Clean Up Out Of Sync
          default: true
        file_count_to_run:
          anyOf:
            - type: integer
            - type: 'null'
          title: File Count To Run
        use_llm:
          type: boolean
          title: Use Llm
          default: false
      type: object
      required:
        - data_connector_name
      title: OCRIngestRequest
    HTTPError:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: HTTPError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    UserIdAuth:
      type: apiKey
      in: header
      name: X-User-ID

````