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

# Edit Knowledge Base

> Edits an existing knowledge base by adding or removing files, URLs, and FAQs. Rate limit: 20 requests per hour per workspace. File size limit: 2 MB per file, 5 MB total.

## Edit Knowledge Base

Update an existing knowledge base by adding new content or removing existing files, URLs, and FAQs. This endpoint allows you to maintain and refine your knowledge base over time.

<Warning>
  **Rate Limits**:

  * Maximum 20 requests per hour per workspace
  * File size limit: 2 MB per file, 5 MB total
</Warning>

## Adding Content

Add new files, URLs, or FAQs to expand your knowledge base:

* `new_files`: Upload additional documents
* `new_urls`: Index new web pages
* `new_faqs`: Add more question-answer pairs

## Removing Content

Remove outdated or incorrect content using IDs:

* `files_to_remove`: JSON array of file IDs
* `urls_to_remove`: JSON array of URLs
* `faqs_to_remove`: JSON array of FAQ IDs

### Example Removal

```json theme={null}
{
  "files_to_remove": "[\"7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d\"]",
  "urls_to_remove": "[\"https://example.com/old-page\"]",
  "faqs_to_remove": "[\"9c0d1e2f-3a4b-5c6d-7e8f-9a0b1c2d3e4f\"]"
}
```

<Note>
  **Get Content IDs**: Use [Get Knowledge Base by ID](/api-reference/endpoint/kb/get-knowledge-base-by-id) to retrieve file IDs, URLs, and FAQ IDs before removing them.
</Note>

## Response Details

The response includes:

* `items_removed`: Count of items successfully removed
* `new_files_queued`: Count of new files being processed
* `new_files`: Array of newly added files with their IDs and processing status

## Important Notes

* **Atomic Operations**: Additions and removals are processed together
* **Processing Time**: New content is processed asynchronously
* **No Rollback**: Removals are permanent - ensure you have the correct IDs


## OpenAPI

````yaml patch /external/kb
openapi: 3.0.0
info:
  title: Ringg AI API Documentation
  description: >-
    This is the documentation for the Ringg AI APIs. The Ringg AI API follows
    RESTful principles, making it intuitive and easy to integrate with your
    applications. All API requests should be made to the base URL. The API
    accepts and returns data in JSON format. Ensure your requests include the
    appropriate Content-Type header for POST and PATCH requests.
  version: 2.0.0
servers:
  - url: https://prod-api.ringg.ai/ca/api/v0
security: []
tags:
  - name: workspace
    description: Endpoints for managing your workspace.
  - name: agent
    description: Endpoints for managing assistants (agents).
  - name: calling
    description: Endpoints for making and managing calls.
  - name: campaign
    description: Endpoints for managing campaigns.
  - name: analytics
    description: Endpoints for accessing call analytics and performance metrics.
  - name: termination
    description: Endpoints for terminating active calls using different methods.
  - name: knowledgebase
    description: Endpoints for managing knowledge bases.
paths:
  /external/kb:
    patch:
      tags:
        - knowledgebase
      summary: Edit Knowledge Base
      description: >-
        Edits an existing knowledge base by adding or removing files, URLs, and
        FAQs. Rate limit: 20 requests per hour per workspace. File size limit: 2
        MB per file, 5 MB total.
      operationId: editKnowledgeBase
      parameters:
        - name: X-API-KEY
          in: header
          description: (Required) Your Ringg AI API key.
          required: true
          schema:
            type: string
            example: 7251cb4b-3373-43a4-844c-b27a1d45e0c9
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - kb_id
              properties:
                kb_id:
                  type: string
                  description: (Required) ID of the knowledge base to edit
                  example: 550e8400-e29b-41d4-a716-446655440000
                files_to_remove:
                  type: string
                  description: (Optional) JSON string array of file IDs to remove
                  example: >-
                    ["7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d",
                    "8b9c0d1e-2f3a-4b5c-6d7e-8f9a0b1c2d3e"]
                urls_to_remove:
                  type: string
                  description: (Optional) JSON string array of URLs to remove
                  example: '["https://example.com/old-page"]'
                faqs_to_remove:
                  type: string
                  description: (Optional) JSON string array of FAQ IDs to remove
                  example: >-
                    ["9c0d1e2f-3a4b-5c6d-7e8f-9a0b1c2d3e4f",
                    "0d1e2f3a-4b5c-6d7e-8f9a-0b1c2d3e4f5a"]
                new_files:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: (Optional) Array of new files to upload
                new_urls:
                  type: string
                  description: (Optional) JSON string array of new URLs to add
                  example: '["https://example.com/new-docs"]'
                new_faqs:
                  type: string
                  description: (Optional) JSON string array of new FAQ objects
                  example: >-
                    [{"question": "Do you ship internationally?", "answer":
                    "Yes, worldwide shipping available"}]
                new_files_metadata:
                  type: string
                  description: (Optional) JSON string object with metadata for new files
                  example: '{}'
      responses:
        '200':
          description: Knowledge base updated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Knowledge Base edit initiated
                  kb_id:
                    type: string
                    example: 550e8400-e29b-41d4-a716-446655440000
                  items_removed:
                    type: integer
                    example: 2
                  new_files_queued:
                    type: integer
                    example: 1
                  new_files:
                    type: array
                    items:
                      type: object
                      properties:
                        filename:
                          type: string
                          example: document.pdf
                        file_id:
                          type: string
                          example: 1e2f3a4b-5c6d-7e8f-9a0b-1c2d3e4f5a6b
                        processing_status:
                          type: string
                          example: pending
        '400':
          description: Bad Request - Invalid parameters.
        '401':
          description: Unauthorized - Invalid or missing API key.
        '404':
          description: Knowledge base not found.
        '429':
          description: Rate limit exceeded - Maximum 20 requests per hour.

````