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

# List a document's topics

> List a document's topic tree — the sections an LLM extracted from it.

The list is flat and already in depth-first order; build the tree from each item's `parent_id`.

- It includes one synthetic document-root item (`type` "root"), so it returns exactly one more item than the document's `topic_count`, which counts real topics only.
- Bodies are omitted by default. Ask for `content` in `include` to hydrate every item — that can enlarge the response by orders of magnitude.



## OpenAPI

````yaml /api-reference/openapi.json get /api/v2/knowledge_bases/{kb_id}/documents/{doc_id}/topics
openapi: 3.1.0
info:
  title: EverOS Cloud Memory API
  version: 2.0.0
  license:
    name: Apache-2.0
    identifier: Apache-2.0
  contact:
    name: EverMind AI
    email: service@evermind.ai
    url: https://github.com/EverMind-AI/everos-cloud-sdk-python
  description: >-
    Official Python client for the EverOS Cloud Memory API. Add, search,
    retrieve, and manage long-term memory for your AI applications over a typed
    interface (pydantic v2, with full type hints). Install and usage guides:
    https://github.com/EverMind-AI/everos-cloud-sdk-python
servers:
  - url: https://api.evermind.ai
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v2/knowledge_bases/{kb_id}/documents/{doc_id}/topics:
    get:
      tags:
        - Knowledge
      summary: List a document's topics
      description: >-
        List a document's topic tree — the sections an LLM extracted from it.


        The list is flat and already in depth-first order; build the tree from
        each item's `parent_id`.


        - It includes one synthetic document-root item (`type` "root"), so it
        returns exactly one more item than the document's `topic_count`, which
        counts real topics only.

        - Bodies are omitted by default. Ask for `content` in `include` to
        hydrate every item — that can enlarge the response by orders of
        magnitude.
      operationId: listTopics
      parameters:
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
            title: Kb Id
        - name: doc_id
          in: path
          required: true
          schema:
            type: string
            title: Doc Id
        - name: include
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            description: Extra fields to hydrate, e.g. `include=content` for full bodies
            title: Include
          description: Extra fields to hydrate, e.g. `include=content` for full bodies
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessEnvelope_TopicListData_'
        '401':
          description: Missing or invalid bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '403':
          description: >-
            Authenticated but not permitted — either rejected by the auth
            service, or the account's memory API version does not match the
            interface version implied by the path (a v1 account calling an
            /api/v2 route).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit or quota exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '503':
          description: >-
            The gateway could not reach the authentication service. Transient —
            retry with backoff.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
components:
  schemas:
    SuccessEnvelope_TopicListData_:
      properties:
        request_id:
          type: string
          title: Request Id
          description: Request trace id (peer to data)
        data:
          $ref: '#/components/schemas/TopicListData'
          description: Endpoint-defined business result
      type: object
      required:
        - request_id
        - data
      title: SuccessEnvelope[TopicListData]
    GatewayError:
      type: object
      additionalProperties: true
      description: >-
        Gateway error body. NOTE: shape is not yet uniform across auth/quota/
        rate-limit paths — treat fields as best-effort. Commonly includes a
        `code`/`message` (flat) or an `error` object/string with a `message`.
      title: GatewayError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          description: One entry per field that failed validation.
      type: object
      title: HTTPValidationError
    TopicListData:
      properties:
        topics:
          items:
            $ref: '#/components/schemas/TopicListItem'
          type: array
          title: Topics
          description: >-
            The document's topics, flat and depth-first ordered — build the tree
            from `parent_id`. Includes the synthetic document-root item, so this
            list holds exactly one more entry than the document's `topic_count`.
      type: object
      title: TopicListData
      description: >-
        A document's topic tree, DFS-ordered (flat list; build the tree from
        `parent_id`).


        The list INCLUDES the synthetic document-root item (`type=root`), so

        ``len(topics) == document.topic_count + 1`` — the document's
        ``topic_count`` counts real

        topics only. Two consumer recipes:


        * **Full tree** — root at the item whose ``parent_id`` is null, link the
        rest by
          ``parent_id``. Returned order is already DFS, so children keep document order.
        * **Real topics only** (to match ``topic_count``) — drop the
        ``type=root`` item AND
          null out the ``parent_id`` of its direct children, otherwise those now point at an id
          that is no longer in the set.

        Robust root test for either recipe: ``parent_id is null OR parent_id not
        in the returned

        ids`` — that also survives an orphan row left behind by a partial
        cascade delete.


        ``include=content`` hydrates every item's body, which can grow the
        response by orders of

        magnitude. Ask for it to render a whole document, not to draw the tree.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: Path to the offending field, from the body root.
        msg:
          type: string
          title: Message
          description: What is wrong with it.
        type:
          type: string
          title: Error Type
          description: Machine-readable validation-error kind.
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    TopicListItem:
      properties:
        id:
          type: string
          title: Id
          description: Topic (node) id
        doc_id:
          type: string
          title: Doc Id
          description: Owning document id
          default: ''
        kb_id:
          type: string
          title: Kb Id
          description: Owning knowledge base id
          default: ''
        name:
          type: string
          title: Name
          description: >-
            Node title. For the document-root item (`type=root`) this is the
            document title, i.e. the same value as the document's `title`
        type:
          type: string
          title: Type
          description: >-
            Structural role: `root` = the document-root container (exactly one
            per document, `depth=0`, `parent_id=null`, empty body), `section` =
            a real topic, `element` = rich media (reserved, not produced yet).
            Filter on this rather than on `depth==0` to tell the root apart from
            real topics
          default: section
        depth:
          type: integer
          title: Depth
          description: 'Tree depth: 0 = document root, 1 = a top-level topic'
          default: 0
        seq:
          type: integer
          title: Seq
          description: >-
            DFS position within the document (0 = the root). Items are already
            returned in this order — use the order, do not do arithmetic on the
            value
          default: 0
        parent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Id
          description: Parent topic id; null only on the document root
        summary:
          type: string
          title: Summary
          description: >-
            Retrieval-oriented summary covering this node AND its subtree. On
            the root item it is the document-level summary
          default: ''
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
          description: >-
            Full markdown body — populated ONLY when the request passes
            `include=content`, else null. Always the complete body, never a
            stored excerpt. Null on the document-root item, which has no body of
            its own
        tag_ids:
          items:
            type: string
            maxLength: 128
            minLength: 1
            description: Opaque semantic tag id
          type: array
          maxItems: 50
          title: Tag Ids
          description: Opaque final materialized semantic tag ids (maximum 50)
        version:
          type: integer
          minimum: 0
          title: Version
          description: Current topic tag CAS version
          default: 0
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
          description: When the topic was extracted.
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
          description: When it last changed.
      type: object
      required:
        - id
        - name
      title: TopicListItem
      description: Node-tree overview item. ``content`` only when the caller asks for it.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'API key issued by EverOS, sent as `Authorization: Bearer <api_key>`.'

````