For AI agents: markdown of this page — /docs-content-en/note/collections/tree.md documentation index — /llms.txt
Knowledge base document tree
GET /v1/note/collections/:collectionId/documents
Returns the document tree of a knowledge base: top-level documents and the child documents nested within them. Use it to traverse the knowledge base structure or to obtain its document identifiers.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
collectionId (path) |
number | yes | Knowledge base identifier. List: GET /v1/note/collections |
Examples
curl — personal key
curl https://vibecode.bitrix24.com/v1/note/collections/9/documents \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl https://vibecode.bitrix24.com/v1/note/collections/9/documents \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/note/collections/9/documents', {
headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})
const { data } = await res.json()
console.log('Document tree:', data)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/note/collections/9/documents', {
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data |
array | Top-level documents of the knowledge base |
data[].id |
number | Document identifier |
data[].collectionId |
number | Identifier of the knowledge base the document belongs to. List: GET /v1/note/collections |
data[].parentId |
number or null | Identifier of the parent document. null for a top-level document |
data[].title |
string | Document title |
data[].position |
number | Numeric position of the document among its siblings |
data[].children |
array | Nested documents of the same structure |
meta.truncated |
boolean | true if the tree is not shown in full |
Response example
{
"success": true,
"data": [
{
"id": 11,
"collectionId": 9,
"parentId": null,
"title": "Chapter 1",
"position": 1000,
"children": []
}
],
"meta": { "truncated": false }
}
Error response example
404 — knowledge base not found:
{
"success": false,
"error": {
"code": "ENTITY_NOT_FOUND",
"message": "Record with ID = `999999` not found"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
collectionId is not a positive integer |
| 404 | ENTITY_NOT_FOUND |
Knowledge base with the specified collectionId not found |
| 403 | SCOPE_DENIED |
The key lacks the note scope |
| 401 | TOKEN_MISSING |
The key has no configured tokens |
Full list of common API errors — Errors.
Known specifics
Archived documents are not included in the tree. Only active documents of the knowledge base are returned.
The meta.truncated field comes back true when the tree reaches the internal limit of 5000 nodes. In this case only part of the structure is shown.