type: object
description: |
    A single ingested document in the knowledge base — one row per source-side
    artifact (a markdown file, a Discord message thread, a GitHub issue, etc.).
    Mirrors `kb_documents`. Documents are split into `kb_chunks` for retrieval;
    `chunkCount` and the chunk array are returned by
    `GET /admin/kb/document/{documentId}` and not by the listing endpoint.
required: [id, sourceType, sourceId, title]
properties:
    id: { type: string, description: KB document UUID. }
    sourceType:
        type: string
        description: "Where the doc came from — `discord`, `github`, `document`, etc."
    sourceId:
        type: string
        description: Source-side identifier (e.g. file path, message id).
    sourceUrl:
        type: string
        description: Optional URL pointing back to the source.
    title: { type: string }
    contentType:
        type: string
        description: "MIME-ish hint (e.g. `text/markdown`, `text/plain`)."
    visibility:
        type: string
        description: "Visibility class (e.g. `public`, `internal`)."
    allowedGroups:
        type: array
        items: { type: string }
        description: When set, only callers with at least one matching access policy can retrieve this doc.
    indexedAt:
        type: string
        format: date-time
        description: When the chunker / embedder last processed this document.
    sourceCreatedAt:
        type: [string, "null"]
        format: date-time
        description: Timestamp on the source side, when known.
    metadata:
        type: object
        additionalProperties: true
        description: Source-specific metadata.
example:
    id: "doc_01HZS67890ABC123DEF45GH678"
    sourceType: "document"
    sourceId: "docs/services/admin-api/shipping.md"
    sourceUrl: "https://github.com/bigscreenvr/cloud/blob/master/docs/services/admin-api/shipping.md"
    title: "Shipping module overview"
    contentType: "text/markdown"
    visibility: "internal"
    allowedGroups: []
    indexedAt: "2026-04-22T10:14:00.000Z"
    sourceCreatedAt: "2026-04-15T11:00:00.000Z"
    metadata: { path: "docs/services/admin-api/shipping.md" }
