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

> Associates uploaded files or text entries with an agent's knowledge base. Use this endpoint after uploading files via the Initiate File Uploads endpoint to make them available to the agent.  **Source

# Add Files to Agent Knowledge Base

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


## OpenAPI

````yaml patch /ai-agents/agent-builder/agents/{uid}/knowledge-base/{sourceType}/add
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/agents/{uid}/knowledge-base/{sourceType}/add:
    patch:
      tags:
        - Agent Builder
      summary: Add Files to Agent Knowledge Base
      description: >-
        Associates uploaded files or text entries with an agent's knowledge
        base. Use this endpoint after uploading files via the Initiate File
        Uploads endpoint to make them available to the agent.


        **Source types:** Specify the source type (e.g., uploads, text) in the
        path.
      operationId: AgentBuilderController_addFilesToKnowledgeBase
      parameters:
        - name: uid
          required: true
          in: path
          description: Unique identifier of the agent
          schema:
            type: string
        - name: sourceType
          required: true
          in: path
          description: Source type (uploads, knowledge-base, etc.)
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ManageKnowledgeBaseFilesDto'
      responses:
        '200':
          description: Files added to knowledge base successfully
          content:
            application/json:
              schema:
                type: object
              example:
                success: true
      security:
        - apiKey: []
components:
  schemas:
    ManageKnowledgeBaseFilesDto:
      type: object
      properties:
        uniqueIds:
          description: Array of file IDs to be added to the knowledge base
          example:
            - 60f7b3b3b3b3b3b3b3b3b3b3
            - 60f7b3b3b3b3b3b3b3b3b3b4
          type: array
          items:
            type: string
      required:
        - uniqueIds
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key (i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````