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

# List Knowledge Bases

> Returns a paginated list of knowledge bases

Retrieve all knowledge bases in your organization with document counts and metadata.

## Query Parameters

<ParamField query="page" type="integer" default={1}>
  Page number (starting from 1)
</ParamField>

<ParamField query="per_page" type="integer" default={20}>
  Items per page (maximum 50)
</ParamField>

## Response

<ResponseField name="items" type="array">
  Array of knowledge base objects

  <Expandable title="Knowledge Base Object">
    <ResponseField name="id" type="string">
      Unique identifier for the knowledge base (UUID format)
    </ResponseField>

    <ResponseField name="name" type="string">
      Display name of the knowledge base
    </ResponseField>

    <ResponseField name="description" type="string">
      Description of the knowledge base content (nullable)
    </ResponseField>

    <ResponseField name="type" type="string">
      Knowledge base type: `managed`
    </ResponseField>

    <ResponseField name="organization_id" type="string">
      Organization UUID this knowledge base belongs to
    </ResponseField>

    <ResponseField name="agent_id" type="string">
      Associated agent ID (nullable)
    </ResponseField>

    <ResponseField name="total_documents" type="integer">
      Number of documents in this knowledge base
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of knowledge bases
</ResponseField>

<ResponseField name="page" type="integer">
  Current page number
</ResponseField>

<ResponseField name="per_page" type="integer">
  Number of items per page
</ResponseField>

<ResponseField name="total_pages" type="integer">
  Total number of pages available
</ResponseField>

## Example Request

```bash theme={"dark"}
curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/knowledge?page=1&per_page=2"
```

## Example Response

```json theme={"dark"}
{
  "items": [
    {
      "id": "73dc30ca-bdbf-42f7-a39f-93aff4f8522e",
      "name": "Product Catalog",
      "description": "Complete product information and specifications",
      "type": "managed",
      "organization_id": "<org-id>",
      "agent_id": null,
      "total_documents": 12
    },
    {
      "id": "e21563bd-7c02-4f8f-9520-8c854f5c2ee6",
      "name": "Company Policies",
      "description": "Internal policies and procedures documentation",
      "type": "managed",
      "organization_id": "<org-id>",
      "agent_id": null,
      "total_documents": 8
    }
  ],
  "total": 5,
  "page": 1,
  "per_page": 2,
  "total_pages": 3
}
```

## Notes

* Knowledge bases are automatically filtered by your organization
* `total_documents` reflects the number of documents currently indexed
* Use pagination to retrieve large lists of knowledge bases


## OpenAPI

````yaml GET /v1/knowledge
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:
    get:
      tags:
        - API v1
        - Knowledge
        - Knowledge CRUD
      summary: List Knowledge Bases
      description: Returns a paginated list of Knowledge bases
      operationId: List_knowledge_bases_v1_knowledge_get
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            description: Page number (starting from 1)
            default: 1
            title: Page
          description: Page number (starting from 1)
        - name: per_page
          in: query
          required: false
          schema:
            type: integer
            maximum: 50
            minimum: 1
            description: Items per page (max 50)
            default: 20
            title: Per Page
          description: Items per page (max 50)
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponse_KnowledgeBaseItem_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    PaginatedResponse_KnowledgeBaseItem_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/KnowledgeBaseItem'
          type: array
          title: Items
        total:
          type: integer
          title: Total
        page:
          type: integer
          title: Page
        per_page:
          type: integer
          title: Per Page
        total_pages:
          type: integer
          title: Total Pages
      type: object
      required:
        - items
        - total
        - page
        - per_page
        - total_pages
      title: PaginatedResponse[KnowledgeBaseItem]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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.
    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
    KnowledgeBaseType:
      type: string
      enum:
        - managed
        - external
      title: KnowledgeBaseType
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: API Key for authentication
      in: header
      name: x-api-key

````