For AI agents: markdown of this page — /docs-content-en/note/documents/create.md documentation index — /llms.txt
Create a document
POST /v1/note/documents
Creates a document in a knowledge base. A non-empty markdown creates a document with ready-made content. Without it, an empty document is created for collaborative editing.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
FieldcollectionId |
Typeinteger | Requiredyes | DescriptionKnowledge base identifier. List: GET /v1/note/collections |
Fieldtitle |
Typestring | Requiredyes | DescriptionDocument title |
FieldparentId |
Typeinteger | Requiredno | DescriptionParent document for nesting. Belongs to the same knowledge base. Document tree: GET /v1/note/collections/:collectionId/documents |
Fieldmarkdown |
Typestring | Requiredno | DescriptionInitial content in Markdown. Maximum 1 048 576 bytes (1 MiB) |
Examples
curl — personal key
curl -X POST https://vibecode.bitrix24.com/v1/note/documents \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"collectionId": 42,
"title": "Chapter 1",
"parentId": 10,
"markdown": "# Chapter 1\n\nText"
}'
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/note/documents \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"collectionId": 42,
"title": "Chapter 1",
"parentId": 10,
"markdown": "# Chapter 1\n\nText"
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/note/documents', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
collectionId: 42,
title: 'Chapter 1',
parentId: 10,
markdown: '# Chapter 1\n\nText',
}),
})
const { success, data } = await res.json()
console.log(data.id)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/note/documents', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
collectionId: 42,
title: 'Chapter 1',
parentId: 10,
markdown: '# Chapter 1\n\nText',
}),
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata.id |
Typenumber | DescriptionIdentifier of the created document |
Response example
{
"success": true,
"data": { "id": 77 }
}
Error response example
400 — a required parameter is missing:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "`collectionId` is required and must be a positive integer"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptioncollectionId or title is missing, or a parameter has the wrong type |
| HTTP403 | CodeBITRIX_ACCESS_DENIED |
DescriptionNo permission to create documents in the knowledge base |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe access key is read-only |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe knowledge base or the parent document does not exist |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionparentId from a different knowledge base, or the markdown size exceeds the limit. Error text in error.message |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key lacks the note scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no tokens configured |
Full list of common API errors — Errors.