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

# Get Knowledge Base Document

> Get detailed information about a specific document in a knowledge base

Retrieve complete details about a specific document including metadata, processing status, and content information.

## Path Parameters

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

<ParamField path="document_id" type="string" required>
  Unique identifier of the document (UUID format)
</ParamField>

## Response

<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="document_url" type="string">
  URL of the document
</ResponseField>

<ResponseField name="organization_id" type="string">
  UUID of the organization that owns this document
</ResponseField>

<ResponseField name="name" type="string">
  Document name (typically the document URL)
</ResponseField>

<ResponseField name="raw_data" type="string">
  The extracted text content of the document
</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/<document-id>"
```

## Example Response

```json theme={"dark"}
{
  "kb_id": "<kb-id>",
  "id": "<document-id>",
  "document_url": "https://example.com/product-guide.pdf",
  "organization_id": "<org-id>",
  "name": "https://example.com/product-guide.pdf",
  "raw_data": "The extracted text content of the document..."
}
```

## Notes

* The `raw_data` field contains the extracted text content of the document
* Returns 404 if the document or knowledge base is not found


## OpenAPI

````yaml GET /v1/knowledge/{kb_id}/documents/{document_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}/documents/{document_id}:
    get:
      tags:
        - API v1
        - Knowledge
        - Knowledge CRUD
        - Knowledge Documents
      summary: Get Knowledge Base Document By Id
      description: Get knowledge base document by id
      operationId: >-
        Get_knowledge_base_document_by_id_v1_knowledge__kb_id__documents__document_id__get
      parameters:
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
            title: Kb Id
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            title: Document Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/xpander_dev_utils__models__knowledge_bases__KnowledgeBaseDocumentItem
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    xpander_dev_utils__models__knowledge_bases__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
        document_url:
          type: string
          title: Document Url
          description: Document URL
        organization_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization Id
          description: Organization ID
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Doc name
        raw_data:
          anyOf:
            - type: string
            - type: 'null'
          title: Raw Data
          description: Raw data (textual)
        local_env:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Local Env
          description: Is local
          default: false
        sync:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Sync
          description: Is sync?
          default: false
      type: object
      required:
        - document_url
      title: KnowledgeBaseDocumentItem
      description: |-
        Represents a document item within a Knowledge Base.

        Attributes:
            kb_id (Optional[str]): KB identifier.
            id (str): Document unique identifier.
            document_url (str): URL of the document.
            raw_data (Optional[str]): Raw textual data of the document.
            local_env (Optional[bool]): Indicates if the document is in a local environment. Defaults to False.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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

````