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

# Add Sources

> Add Sources to Knowledge Base.

### Authorizations

<ParamField header="X-Api-Key" type="string" required>
  Your Agni API key used to authenticate the request. Pass it in the `X-Api-Key` header. Find or rotate it from your Ravan AI account settings.
</ParamField>

***

### Path Parameters

<ParamField path="kb_id" type="string" required>
  The unique knowledge base ID. Use the ID returned by the knowledge base create or list endpoint.
</ParamField>

***

### Body (JSON)

For adding text and URL sources, use `Content-Type: application/json`:

<ParamField body="knowledge_base_texts" type="array">
  Inline text sources to add to the knowledge base. Each item should include a title and the text content.

  <Expandable title="text item">
    <ParamField body="title" type="string">
      The title for the text source. Use a concise label that helps you identify the source later.
    </ParamField>

    <ParamField body="text" type="string">
      The text content to ingest into the knowledge base.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="knowledge_base_urls" type="string[]">
  A list of URLs to crawl and add as knowledge base sources. Each URL must be publicly reachable.
</ParamField>

### Body (File Upload)

For uploading files, use `Content-Type: multipart/form-data`:

<ParamField body="file" type="file">
  The file to upload as a knowledge base source. Use multipart form data for file uploads.
</ParamField>

***

### Response

<ResponseField name="success" type="boolean">
  Whether the request succeeded.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable status message.
</ResponseField>

<ResponseField name="data" type="object">
  Returned data.

  <Expandable title="data">
    <ResponseField name="knowledge_base" type="object">
      Updated knowledge base object with sources

      <Expandable title="knowledge_base">
        <ResponseField name="knowledge_base_id" type="string">
          Knowledge base UUID
        </ResponseField>

        <ResponseField name="knowledge_base_name" type="string">
          Knowledge base name
        </ResponseField>

        <ResponseField name="status" type="string">
          Status (will be `in_progress` while indexing)
        </ResponseField>

        <ResponseField name="knowledge_base_sources" type="array">
          Array of source objects with indexing status
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="url_sources" type="array">
      URL source crawl status details
    </ResponseField>
  </Expandable>
</ResponseField>


## OpenAPI

````yaml POST /api/v1/rag/knowledge-base/{kb_id}/add-sources
openapi: 3.0.1
info:
  title: Agni API
  version: 1.0.0
  description: >-
    Agni API for managing agents, tools, widget settings, telephony, and
    integrations.
servers:
  - url: https://api.ravan.ai
security:
  - X-Api-Key: []
tags:
  - name: AgentService
  - name: AgentToolService
  - name: WidgetSettingsService
  - name: PhoneService
  - name: AppointmentService
  - name: GHLService
  - name: CalComService
  - name: CampaignService
  - name: ContactService
  - name: CallingService
  - name: RAGService
  - name: ModelService
  - name: HealthService
paths:
  /api/v1/rag/knowledge-base/{kb_id}/add-sources:
    post:
      tags:
        - RAGService
      summary: Add Sources
      operationId: AddSourcesToKnowledgeBase
      parameters:
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
          description: Knowledge Base ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddSourcesRequest'
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: File to upload (PDF, TXT, DOCX, MD)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddSourcesResponse'
components:
  schemas:
    AddSourcesRequest:
      type: object
      properties:
        knowledge_base_texts:
          type: array
          items:
            type: object
            properties:
              title:
                type: string
                description: Title for the text source
              text:
                type: string
                description: Text content to index
          description: Array of text sources
        knowledge_base_urls:
          type: array
          items:
            type: string
          description: Array of URLs to crawl
    AddSourcesResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
        data:
          type: object
          properties:
            knowledge_base:
              $ref: '#/components/schemas/KnowledgeBaseDetail'
            url_sources:
              type: array
              items:
                type: object
                properties:
                  source_id:
                    type: string
                  url:
                    type: string
                  pages_found:
                    type: integer
                  status:
                    type: string
    KnowledgeBaseDetail:
      type: object
      properties:
        knowledge_base_id:
          type: string
          description: Knowledge base UUID
        knowledge_base_name:
          type: string
          description: Knowledge base name
        status:
          type: string
          description: 'Status: complete, in_progress, or error'
        enable_auto_refresh:
          type: boolean
          description: Whether auto-refresh is enabled
        knowledge_base_sources:
          type: array
          items:
            $ref: '#/components/schemas/KnowledgeBaseSource'
        created_timestamp:
          type: integer
          description: Creation timestamp (Unix ms)
        last_updated_timestamp:
          type: integer
          description: Last updated timestamp (Unix ms)
    KnowledgeBaseSource:
      type: object
      properties:
        source_id:
          type: string
          description: Source UUID
        source_type:
          type: string
          description: 'Type: text, url, or document'
        source_name:
          type: string
          description: Source name or title
        source_url:
          type: string
          description: Source URL (for url type)
        source_status:
          type: string
          description: 'Status: complete, indexing, or error'
        created_timestamp:
          type: integer
          description: Creation timestamp (Unix ms)
  securitySchemes:
    X-Api-Key:
      type: apiKey
      in: header
      name: X-Api-Key

````