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

# Get the knowledge document tree

> Returns a lazy, depth-bounded tree of knowledge documents starting at `parentId`
(root documents when omitted). Each node reports `hasChildren` so you can decide
whether to fetch further levels via `GET /api/knowledge/{id}/children`.




## OpenAPI

````yaml /openapi.yaml get /api/knowledge/tree
openapi: 3.0.3
info:
  title: Aptly API
  version: '1.0'
  description: |
    The Aptly API lets external systems work with boards, contacts, inboxes,
    tasks, files, and other Aptly resources.

    Most endpoints accept an API key in the `x-token` header. Some endpoints
    also accept a delegate token or partner bearer token, as shown in each
    operation's security requirements, and explicitly public endpoints require
    no credential. API keys are scoped to a company and may be restricted to
    specific boards and read, insert, or update permissions; requests outside
    those restrictions receive a 403 `FORBIDDEN` response.
servers:
  - url: https://core-api.getaptly.com
    description: Production
security:
  - ApiKeyHeader: []
paths:
  /api/knowledge/tree:
    get:
      tags:
        - Knowledge
      summary: Get the knowledge document tree
      description: >
        Returns a lazy, depth-bounded tree of knowledge documents starting at
        `parentId`

        (root documents when omitted). Each node reports `hasChildren` so you
        can decide

        whether to fetch further levels via `GET /api/knowledge/{id}/children`.
      operationId: getKnowledgeTree
      parameters:
        - name: parentId
          in: query
          schema:
            type: string
          description: Omit, or pass "" / "null", for the root level.
        - name: depth
          in: query
          schema:
            type: integer
            default: 1
            maximum: 3
          description: How many levels to expand eagerly.
      responses:
        '200':
          description: Tree of knowledge document nodes.
          content:
            application/json:
              schema:
                type: object
                properties:
                  nodes:
                    type: array
                    items:
                      $ref: '#/components/schemas/KnowledgeTreeNode'
        '401':
          description: Invalid or missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyHeader: []
        - DelegateToken: []
        - PartnerBearer: []
components:
  schemas:
    KnowledgeTreeNode:
      allOf:
        - $ref: '#/components/schemas/KnowledgeDocSummary'
        - type: object
          properties:
            hasChildren:
              type: boolean
              description: >-
                Whether this document has at least one child, whether or not it
                was expanded.
            children:
              type: array
              items:
                $ref: '#/components/schemas/KnowledgeTreeNode'
              description: Nested nodes, present up to the requested `depth`.
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    KnowledgeDocSummary:
      type: object
      description: >-
        Lite shape returned by the list/tree/children knowledge endpoints (no
        rendered HTML).
      properties:
        _id:
          type: string
          description: Document ID.
        name:
          type: string
          description: Document title.
        emoji:
          type: string
          nullable: true
        iconUrl:
          type: string
          nullable: true
        accessType:
          type: string
          enum:
            - public
            - publicReadonly
            - private
        parentId:
          type: string
          nullable: true
          description: Parent document ID, or null for a root document.
        rank:
          type: integer
          nullable: true
          description: Sort order among siblings. May be null.
        archived:
          type: boolean
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-token
    DelegateToken:
      type: apiKey
      in: header
      name: Authorization
      description: 'Delegate token issued by the platform. Format: `DelegateToken <token>`'
    PartnerBearer:
      type: http
      scheme: bearer
      description: 'Partner token. Format: `Authorization: Bearer <token>`'

````