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

# GET /v1/knowledge/tree

> Returns the full tree of folders and documents in your company's knowledge base.

Returns the full hierarchy of active folders and documents in the knowledge base. The response is a tree nested by `parent_id`, ordered by `position`. Nodes don't include content (`content_json` / `content_text`) to keep the response lightweight — to create documents use [`POST /v1/knowledge/documents`](/dev/endpoints/knowledge-document-create), and to search within their content use [`POST /v1/knowledge/search`](/dev/endpoints/knowledge-search).

## Endpoint

```
GET https://api.keebai.com/v1/knowledge/tree
```

## Required scope

`knowledge:read`

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.keebai.com/v1/knowledge/tree \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={null}
  const resp = await fetch("https://api.keebai.com/v1/knowledge/tree", {
    headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` },
  });
  const { items } = await resp.json();
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.get(
      "https://api.keebai.com/v1/knowledge/tree",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  resp.raise_for_status()
  tree = resp.json()["items"]
  ```
</CodeGroup>

## Response

### 200 OK

```json theme={null}
{
  "items": [
    {
      "id": "65f3a1b2c3d4e5f6a7b8c9d0",
      "title": "Soporte",
      "node_type": "folder",
      "parent_id": null,
      "position": 0,
      "path_cache": "/Soporte",
      "created_at": "2026-04-20T15:30:00.000Z",
      "updated_at": "2026-04-20T15:30:00.000Z",
      "children": [
        {
          "id": "65f3a1b2c3d4e5f6a7b8c9d1",
          "title": "Política de devolución",
          "node_type": "document",
          "parent_id": "65f3a1b2c3d4e5f6a7b8c9d0",
          "position": 0,
          "path_cache": "/Soporte/Política de devolución",
          "created_at": "2026-04-20T15:35:00.000Z",
          "updated_at": "2026-04-20T15:35:00.000Z",
          "children": []
        }
      ]
    }
  ]
}
```

| Field                | Type             | Description                                                 |
| -------------------- | ---------------- | ----------------------------------------------------------- |
| `items[].id`         | `string`         | `ObjectId` of the node.                                     |
| `items[].title`      | `string`         | Title as shown in the portal.                               |
| `items[].node_type`  | `string`         | `folder` or `document`.                                     |
| `items[].parent_id`  | `string \| null` | `ObjectId` of the parent folder. `null` if at the root.     |
| `items[].position`   | `number`         | Order within the parent (lowest first).                     |
| `items[].path_cache` | `string`         | Concatenated path (e.g. `/Soporte/Política de devolución`). |
| `items[].children`   | `array`          | Direct children of the node, with the same structure.       |

### 401 / 403 / 429

Standard auth, scope, and rate limit errors.


## OpenAPI

````yaml GET /v1/knowledge/tree
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/knowledge/tree:
    get:
      tags:
        - knowledge
      summary: >-
        Obtener el árbol completo de carpetas y documentos de la base de
        conocimientos.
      operationId: PublicKnowledgeController_getTree
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeTreeResponseDto'
      security:
        - PAT: []
components:
  schemas:
    KnowledgeTreeResponseDto:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/KnowledgeTreeNodeDto'
      required:
        - items
    KnowledgeTreeNodeDto:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        node_type:
          type: string
          enum:
            - folder
            - document
        parent_id:
          type: object
          nullable: true
        position:
          type: number
        path_cache:
          type: string
        created_at:
          type: string
        updated_at:
          type: string
        children:
          type: array
          items:
            $ref: '#/components/schemas/KnowledgeTreeNodeDto'
      required:
        - id
        - title
        - node_type
        - position
        - path_cache
        - children
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````