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

# Upload a document

> Endpoint to upload documents.

Documents are saved to the persistent storage, parsed, chunked and embedded.

The file is indexed as a document in the SQL database, with its chunks, and related to its owner, company and collection for permission application.

To specify a workspace, set `collection_type` to one of the following:
- `private` for a personal workspace
- `company` for a company workspace
- `workspace` for other workspaces

If `workspace` is specified, `workspace_id` must be provided.

If `collection_type` is not specified, it defaults to `company`.



## OpenAPI

````yaml /api-reference/openapi-v2.yaml post /api/v2/files
openapi: 3.0.3
info:
  title: Paradigm API
  version: xenial-xerus (v2)
  description: >-
    A versatile and adaptable tool designed to integrate Generative AI into your
    applications
servers:
  - url: https://paradigm.lighton.ai
security: []
tags:
  - name: Models
    description: Operations about AI models
  - name: Files Search
    description: Operations about files search
  - name: Files
    description: Operations about files
  - name: Upload Sessions
    description: Operations about upload sessions
  - name: Workspaces
    description: Operations about workspaces
  - name: Users
    description: Operations about users
  - name: Companies
    description: Operations about companies
  - name: SCIM
    description: Operations about SCIM
  - name: Feedbacks
    description: Operations about feedbacks
  - name: Reporting
    description: Operations about reporting
  - name: Monitoring
    description: Operations about monitoring
  - name: Platform Status
    description: Operations about platform status
paths:
  /api/v2/files:
    post:
      tags:
        - Files
      summary: Upload a document
      description: >-
        Endpoint to upload documents.


        Documents are saved to the persistent storage, parsed, chunked and
        embedded.


        The file is indexed as a document in the SQL database, with its chunks,
        and related to its owner, company and collection for permission
        application.


        To specify a workspace, set `collection_type` to one of the following:

        - `private` for a personal workspace

        - `company` for a company workspace

        - `workspace` for other workspaces


        If `workspace` is specified, `workspace_id` must be provided.


        If `collection_type` is not specified, it defaults to `company`.
      operationId: api_v2_files_create
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FileCreateRequestSerializerV2'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileCreateResponseSerializerV2'
              examples:
                FileUploadedSuccessfully:
                  value:
                    id: 1
                    object: list
                    bytes: 20032
                    created_at: 1631533200
                    filename: document.pdf
                    purpose: documents
                    status: embedded
                  summary: File uploaded successfully
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    FileCreateRequestSerializerV2:
      type: object
      description: Request serializer for file upload.
      properties:
        title:
          type: string
          nullable: true
          maxLength: 255
        filename:
          type: string
          nullable: true
          maxLength: 512
        file:
          type: string
          format: uri
        collection:
          type: integer
          nullable: true
        owner:
          type: integer
          writeOnly: true
          description: Owner of the file (optional)
        company:
          type: integer
          writeOnly: true
          description: Company to associate the file with (optional)
        content:
          type: string
          nullable: true
        file_type:
          type: string
          nullable: true
          maxLength: 30
        collection_type:
          allOf:
            - $ref: '#/components/schemas/CollectionTypeEnum'
          writeOnly: true
          description: >-
            Type of collection to store the file in (private, company, or
            workspace)


            * `private` - private

            * `company` - company

            * `workspace` - workspace
        workspace_id:
          type: integer
          writeOnly: true
          description: Workspace ID when collection_type is 'workspace'
        chunk_size:
          type: integer
          description: Size of chunks for document processing (optional)
        chunk_overlap:
          type: number
          format: double
          description: Overlap between chunks (optional)
        external_metadata:
          allOf:
            - $ref: '#/components/schemas/ExternalMetadata'
          nullable: true
          description: Additional external metadata for the document (optional)
        OCR_AGENT:
          type: string
          description: OCR agent to use for processing (optional)
        OCR_COMPLETE_DOC_TABLE_EXTRACTION:
          type: boolean
          nullable: true
          description: Enable complete document table extraction (optional)
        OCR_HI_RES_MODEL_NAME:
          type: string
          description: High resolution OCR model name (optional)
        OCR_STRATEGY:
          type: string
          description: OCR processing strategy (optional)
        OCR_TIMEOUT:
          type: integer
          description: OCR processing timeout in seconds (optional)
        OCR_URL:
          type: string
          description: OCR service URL (optional)
        IS_VISUAL_INGESTION_ON:
          type: boolean
          nullable: true
          description: Enable visual ingestion processing (optional)
        DEFAULT_PIPELINE:
          type: string
          description: Default processing pipeline to use (optional)
      required:
        - file
    FileCreateResponseSerializerV2:
      type: object
      description: Response serializer for file upload results.
      properties:
        id:
          type: integer
          description: Unique identifier for the uploaded file
        object:
          type: string
          readOnly: true
          description: Object type, always 'file'
        bytes:
          type: integer
          readOnly: true
          description: Size of the file in bytes
        created_at:
          type: integer
          readOnly: true
          description: Unix timestamp of when the file was created
        filename:
          type: string
          readOnly: true
          description: Original filename of the uploaded file
        purpose:
          type: string
          readOnly: true
          description: Purpose of the file, always 'documents'
        status:
          type: string
          readOnly: true
          description: Processing status of the file
      required:
        - bytes
        - created_at
        - filename
        - id
        - object
        - purpose
        - status
    CollectionTypeEnum:
      enum:
        - private
        - company
        - workspace
      type: string
      description: |-
        * `private` - private
        * `company` - company
        * `workspace` - workspace
    ExternalMetadata:
      type: object
      properties:
        doc_id:
          type: string
          description: External document ID
        doc_type:
          type: string
          description: External document type
        name:
          type: string
          description: External document name
        version:
          type: string
          description: External document version
        mime_type:
          type: string
          description: External document MIME type
        created_at:
          type: string
          format: date-time
          description: Creation time of the external document
        modified_at:
          type: string
          format: date-time
          description: Last modification time of the external document
        last_synced_at:
          type: string
          format: date-time
          description: Last synced time of the external document
        external_url:
          type: string
          format: uri
          description: External document URL
        external_full_path:
          type: string
          description: Full path of the external document
      required:
        - doc_id
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your auth token.

````