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

# Update Knowledge Base

> Updates a knowledge base

Modify a knowledge base's configuration. Only provided fields will be updated.

## Path Parameters

<ParamField path="kb_id" type="string" required>
  Unique identifier of the knowledge base to update (UUID format)
</ParamField>

## Request Body

<ParamField body="name" type="string">
  Display name for the knowledge base
</ParamField>

<ParamField body="description" type="string">
  Optional description of the knowledge base purpose
</ParamField>

<ParamField body="agent_id" type="string">
  UUID of the agent to attach this knowledge base to
</ParamField>

## Response

Returns the updated knowledge base object with the structure matching [Get Knowledge Base](/api-reference/v1/knowledge/get-knowledge-base).

## Example Request

```bash theme={"dark"}
curl -X PATCH -H "x-api-key: <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Product Catalog",
    "description": "Revised product information and specifications"
  }' \
  https://api.xpander.ai/v1/knowledge/<kb-id>
```

## Example Response

```json theme={"dark"}
{
  "id": "<kb-id>",
  "name": "Product Catalog v2",
  "description": "Updated product information and pricing details",
  "type": "managed",
  "organization_id": "<org-id>",
  "agent_id": null,
  "total_documents": 0
}
```

## Notes

* All fields in the request body are optional
* Fields not provided in the request will retain their existing values
* Returns 404 if the knowledge base is not found


## OpenAPI

````yaml PATCH /v1/knowledge/{kb_id}
openapi: 3.1.0
info:
  title: xpander.ai API Service
  description: |2-

        The xpander.ai API Service provides a unified REST API for managing AI agents,
        executing tasks, managing knowledge bases, and integrating with external systems.
        
        Features:
        - Agent Management: Create, update, deploy, and delete AI agents
        - Task Execution: Invoke agents with support for sync, async, and streaming modes
        - Knowledge Bases: Manage knowledge bases and documents for RAG workflows
        - Tools: Discover, connect, and attach tools (connectors, custom functions, MCP servers, sub-agents, workflows) to agents and workflows
        - MCP Integration: Model Context Protocol support for standardized AI interactions
        
        Authentication: All endpoints require authentication via either an API key (`x-api-key`) or an OAuth2 JWT (`Authorization: Bearer <jwt>`).
        
  version: '0.001'
servers:
  - url: https://api.xpander.ai
security: []
paths:
  /v1/knowledge/{kb_id}:
    patch:
      tags:
        - API v1
        - Knowledge
        - Knowledge CRUD
      summary: Update Knowledge Base
      description: Updates a knowledge base
      operationId: Update_knowledge_base_v1_knowledge__kb_id__patch
      parameters:
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
            title: Kb Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateManagedKnowledgeBaseRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeBaseItem'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    CreateManagedKnowledgeBaseRequest:
      properties:
        name:
          type: string
          title: Name
          description: KB name specified by the user
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: KB description specified by the user
      type: object
      required:
        - name
      title: CreateManagedKnowledgeBaseRequest
    KnowledgeBaseItem:
      properties:
        id:
          type: string
          title: Id
          description: KB unique identifier
        name:
          type: string
          title: Name
          description: KB name specified by the user
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: KB description specified by the user
        type:
          $ref: '#/components/schemas/KnowledgeBaseType'
          description: KB type, managed / external
        organization_id:
          type: string
          title: Organization Id
          description: Organization ID
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: Agent ID
        total_documents:
          type: integer
          title: Total Documents
          description: Total count of embedded documents
          default: 0
      type: object
      required:
        - id
        - name
        - type
        - organization_id
      title: KnowledgeBaseItem
      description: |-
        Represents a Knowledge Base item.

        Attributes:
            id (str): KB unique identifier.
            name (str): KB name specified by the user.
            description (str): KB description specified by the user.
            type (KnowledgeBaseType): KB type, either managed or external.
            organization_id (str): Organization ID associated with the KB.
            total_documents (int): Total count of embedded documents. Defaults to 0.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    KnowledgeBaseType:
      type: string
      enum:
        - managed
        - external
      title: KnowledgeBaseType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: API Key for authentication
      in: header
      name: x-api-key

````