> ## 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 Base Documents

> Get paginated list of documents in a knowledge base

Retrieve all documents stored in a specific knowledge base with pagination support. This endpoint returns document metadata including IDs and URLs.

## Path Parameters

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

## 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 document objects

  <Expandable title="Document Object">
    <ResponseField name="kb_id" type="string">
      Knowledge base ID this document belongs to
    </ResponseField>

    <ResponseField name="id" type="string">
      Unique identifier for the document (UUID)
    </ResponseField>

    <ResponseField name="name" type="string">
      Document name (nullable)
    </ResponseField>

    <ResponseField name="document_url" type="string">
      URL to access the document file
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of documents in the knowledge base
</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/<kb-id>/documents?page=1&per_page=10"
```

## Example Response

```json theme={"dark"}
{
  "items": [
    {
      "kb_id": "<kb-id>",
      "id": "<document-id>",
      "name": "https://docs.example.com/quickstart",
      "document_url": "https://docs.example.com/quickstart"
    }
  ],
  "total": 1,
  "page": 1,
  "per_page": 10,
  "total_pages": 1
}
```

## Notes

* Documents are returned in the order they were added to the knowledge base
* The `document_url` field contains the full URL to access the document file
* Use this endpoint to audit what documents are in a knowledge base
* Combine with [Get Document](/api-reference/v1/knowledge/get-document) to retrieve full document details


## OpenAPI

````yaml GET /v1/knowledge/{kb_id}/documents
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}/documents:
    get:
      tags:
        - API v1
        - Knowledge
        - Knowledge CRUD
        - Knowledge Documents
      summary: Get Knowledge Base Documents
      description: Get knowledge base documents
      operationId: Get_knowledge_base_documents_v1_knowledge__kb_id__documents_get
      parameters:
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
            title: Kb Id
        - 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_KnowledgeBaseDocumentItem_
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    PaginatedResponse_KnowledgeBaseDocumentItem_:
      properties:
        items:
          items:
            $ref: >-
              #/components/schemas/src__models__knowledge__documents__KnowledgeBaseDocumentItem
          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[KnowledgeBaseDocumentItem]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    src__models__knowledge__documents__KnowledgeBaseDocumentItem:
      properties:
        kb_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Kb Id
          description: KB identifier
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Document unique identifier
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Document name
        document_url:
          type: string
          title: Document Url
          description: Document URL
      type: object
      required:
        - document_url
      title: KnowledgeBaseDocumentItem
      description: Knowledge base document metadata model.
    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

````