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

> Generates presigned URLs and creates upload records for one or more files. Use this endpoint to prepare files for upload to the knowledge base.  **Workflow:** After receiving the presigned URLs, uploa

# Initiate File Uploads

For the complete error reference, see [Error Guide](/rest-api/ai-agents-apis/error-codes).


## OpenAPI

````yaml post /ai-agents/agent-builder/knowledge-base/uploads/initiate
openapi: 3.0.0
info:
  title: AI Agents APIs
  description: API reference for CometChat AI Agents service
  version: '1.0'
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security: []
tags:
  - name: ai-agent
    description: ''
paths:
  /ai-agents/agent-builder/knowledge-base/uploads/initiate:
    post:
      tags:
        - knowledge-base
      summary: Initiate File Uploads
      description: >-
        Generates presigned URLs and creates upload records for one or more
        files. Use this endpoint to prepare files for upload to the knowledge
        base.


        **Workflow:** After receiving the presigned URLs, upload the files
        directly to the provided URLs, then use the Add Knowledge Base Files
        endpoint to associate them with an agent.
      operationId: RagController_initiateUpload
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateUploadDto'
            examples:
              example1:
                summary: Upload multiple files
                value:
                  files:
                    - fileName: document.pdf
                      mimeType: application/pdf
                      fileSize: 1024000
                    - fileName: document_2.pdf
                      mimeType: application/pdf
                      fileSize: 512000
      responses:
        '201':
          description: Presigned URLs generated and upload records created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  uploads:
                    type: array
                    items:
                      type: object
                      properties:
                        uploadId:
                          type: string
                          description: Unique upload session ID
                        fileName:
                          type: string
                          description: Original file name
                        mimeType:
                          type: string
                          description: MIME type of the file
                        fileSize:
                          type: number
                          description: File size in bytes
                        s3Key:
                          type: string
                          description: S3 object key for the upload
                        presignedUrl:
                          type: string
                          description: Presigned URL for direct S3 upload
              example:
                uploads:
                  - uploadId: 550e8400-e29b-41d4-a716-446655440000
                    fileName: document.pdf
                    mimeType: application/pdf
                    fileSize: 1024000
                    s3Key: my-app-id/uploads/550e8400/document.pdf
                    presignedUrl: https://s3.amazonaws.com/bucket/...
      security:
        - apiKey: []
components:
  schemas:
    InitiateUploadDto:
      type: object
      properties:
        files:
          description: List of files to upload
          type: array
          items:
            $ref: '#/components/schemas/FileDescriptorDto'
      required:
        - files
    FileDescriptorDto:
      type: object
      properties:
        fileName:
          type: string
          description: Name of the file
          example: document.pdf
        mimeType:
          type: string
          description: MIME type of the file
          example: application/pdf
        fileSize:
          type: number
          description: Size of the file in bytes
          example: 1024000
      required:
        - fileName
        - mimeType
        - fileSize
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key (i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````