List file tree
Interface Description
Browse the currently readable knowledge-base files and directories.
Endpoint
| Field | Value |
|---|---|
| Method | GET |
| Path | /openapi/v2/knowledge-bases/{knowledgeBaseId}/tree |
| Operation ID | listKnowledgeBaseTree |
| Authentication | Bearer OpenAPI key |
Parameters
| Name | Location | Required | Type | Example | Description |
|---|---|---|---|---|---|
knowledgeBaseId | path | Yes | string | knowledge-base-11111111-1111-4111-8111-111111111111 | Knowledge-base identifier returned by knowledge-base APIs. |
parentPath | query | No | string | pages | Directory path to browse, or root for the bundle root. Parent traversal, file paths, and storage paths are rejected. |
entryType | query | No | file | directory | file | Optional tree node type filter. |
limit | query | No | integer | 50 | Maximum number of records to return. The deployment can enforce a lower limit. |
cursor | query | No | string | cursor_123 | Pagination token returned by the same endpoint for reading the next page. |
Request Body
This operation has no request body.
Request Example
bash
curl -X GET "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/tree?parentPath=pages&entryType=file&limit=50" \
-H "Authorization: Bearer <openapi-key>"Successful Responses
200
Requested page of direct readable files and directories under the selected parent path.
| Field | Required | Type | Description |
|---|---|---|---|
activeContentRevision | Yes | object | Current readable knowledge-base content revision. |
items | Yes | array<GeneratedTreeEntry> | Records returned on this page. |
nextCursor | Yes | string | null | Pagination token returned by this endpoint. Reuse it only with the same endpoint and readable knowledge-base version. If it is rejected, restart without a cursor. |
Success Response Example
json
{
"activeContentRevision": 1,
"items": [
{
"activeContentRevision": 1,
"id": "tree-file-11111111111111111111111111111111",
"fileId": "source-file-11111111-1111-4111-8111-111111111111",
"sourceFileId": "source-file-11111111-1111-4111-8111-111111111111",
"directoryId": null,
"parentPath": "pages",
"name": "guide.md",
"path": "pages/guide.md",
"sortKey": "1:guide.md",
"entryType": "file",
"fileKind": "page",
"directEntryCount": 0,
"directDirectoryCount": 0,
"directFileCount": 0,
"descendantFileCount": 0,
"resourceRevision": 1,
"deletable": true,
"contentAvailable": true,
"readActions": {
"fileDetailById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111",
"fileContentById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111/content",
"fileContentByPath": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/content?path=pages%2Fguide.md",
"relatedFilesById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111/related",
"graphExpansionByFileId": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/graph/expand?fileId=source-file-11111111-1111-4111-8111-111111111111",
"sourceFileStatusById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files/source-file-11111111-1111-4111-8111-111111111111"
}
}
],
"nextCursor": null
}Error Codes
The table below lists every error response documented for this operation.
| HTTP Status | Error Code | Explanation |
|---|---|---|
| 401 | UNAUTHORIZED | The Bearer API key is missing, malformed, unknown, revoked, or deleted. |
| 404 | NOT_FOUND | The requested resource was not found. |
| 422 | VALIDATION_ERROR | The request failed validation. |
| 429 | RATE_LIMITED | The request exceeded the configured rate limits. |
| 500 | INTERNAL_ERROR | The API encountered an internal error. |
| 503 | DATABASE_REPOSITORY_UNAVAILABLE | The data required by this operation is temporarily unavailable. |