Edit Document Text note.document.content.edit
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
Scope:
noteWho can execute the method: a user with access to the Knowledge base module and "Edit" permissions for the required document or document knowledge base
This method belongs to REST 3.0. The call specifics and response format of the new API version are described in the REST 3.0 overview.
The note.document.content.edit method modifies document text using targeted replacements or replaces the entire Markdown content.
Before making replacements, retrieve the current text using note.document.content.get: the old values are compared against this exact text. Open editors receive the change as a co-author's edit. All replacements are applied atomically: if one is rejected, the document remains unchanged.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
id* |
Document identifier |
|
edits* |
Array of Pass either |
|
markdown* |
New full document text in Markdown, no more than 1 048 576 bytes. Blocks from Pass either |
Edits Parameter
|
Name |
Description |
|
old* |
Fragment of the current Markdown to replace. It cannot be empty or consist only of whitespace. Trailing spaces and tabs are ignored during comparison, and line breaks are normalized to If multiple matches are found and |
|
new* |
New Markdown fragment |
|
replaceAll |
Replace all occurrences of Default: |
Code Examples
How to Use Examples in Documentation
The new API call differs by adding the /api/ segment to the request URL:
https://{installation_address}/rest/api/{user_id}/{webhook_token}/note.document.content.edit
curl -X POST \
-H "Content-Type: application/json" \
-d '{"id":42,"edits":[{"old":"Old text","new":"New text","replaceAll":false}]}' \
https://**put_your_bitrix24_address**/rest/api/**put_your_user_id_here**/**put_your_webhook_here**/note.document.content.edit
curl -X POST \
-H "Content-Type: application/json" \
-d '{"id":42,"edits":[{"old":"Old text","new":"New text","replaceAll":false}],"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/api/note.document.content.edit
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
try {
const response = await $b24.actions.v3.call.make({
method: 'note.document.content.edit',
params: {
id: 42,
edits: [{ old: 'Old text', new: 'New text', replaceAll: false }]
},
requestId: Text.getUuidRfc4122()
})
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
console.info(response.getData()!.result)
}
} catch (error) {
console.error(error)
}
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function editContent() {
try {
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v3.call.make({
method: 'note.document.content.edit',
params: {
id: 42,
edits: [{ old: 'Old text', new: 'New text', replaceAll: false }]
},
requestId: B24Js.Text.getUuidRfc4122()
})
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
console.info(response.getData().result)
} catch (error) {
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', editContent)
</script>
There is no ready-made wrapper for this method in b24pysdk yet, and it is not included in the SDK's REST 3.0 method list. Add the method to Config().api_v3_methods and call it via bitrix_token.call_method with prefer_version=3.
from b24pysdk import Config
from b24pysdk.errors import BitrixSDKException
from b24pysdk.errors.v3 import BitrixAPIError
method = "note.document.content.edit"
Config().configure(api_v3_methods=Config().api_v3_methods | {method})
try:
response = bitrix_token.call_method(
api_method=method,
params={
"id": 42,
"edits": [
{"old": "Old text", "new": "New text", "replaceAll": False},
],
},
prefer_version=3,
)
item = response["result"]["item"]
print(item["changed"], item["markdown"])
except BitrixAPIError as error:
print(f"code: {error.code}", f"message: {error.error.message}", sep="\n")
except BitrixSDKException as error:
print(f"Bitrix SDK error: {error.message}")
The SDK does not yet support calls to the /rest/api/ address. Use direct HTTP requests, for example, via curl or fetch.
The JS API does not yet support calls to the /rest/api/ address. Use direct HTTP requests, for example, via fetch.
CRest does not yet support calls to the /rest/api/ address. Use direct HTTP requests, for example, via curl.
The SDK does not yet support calls to the /rest/api/ address. Use a direct HTTP request.
Response Handling
HTTP status: 200
{
"result": {
"item": {
"id": 42,
"changed": true,
"markdown": "# Chapter 1\n\nNew text",
"lossless": true,
"opaqueBlocks": [],
"warnings": []
}
},
"time": {
"start": 1795591533,
"finish": 1795591533.411631,
"duration": 0.41163110733032227,
"processing": 0,
"date_start": "2026-11-25T10:25:33+03:00",
"date_finish": "2026-11-25T10:25:33+03:00",
"operating_reset_at": 1795592100,
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
item |
Document modification result. Object structure description |
|
time |
Information about the request execution time |
Item Object
|
Name |
Description |
|
id |
Document identifier |
|
changed |
|
|
markdown |
Current document text after the edit, including concurrent co-author changes |
|
lossless |
|
|
opaqueBlocks |
Blocks that Markdown cannot fully represent. The field format is described in note.document.content.get |
|
warnings |
Warnings about Markdown transformations when applying the edit. Object structure description |
Warnings Object
|
Name |
Description |
|
editIndex |
Replacement index in the |
|
code |
Warning code:
|
|
message |
Description of the transformation in English |
Error Handling
HTTP status: 409
{
"error": {
"code": "NOTE_CONTENT_MATCH_NOT_FOUND",
"message": "The old fragment was not found in the article. Use note.document.content.get to get the current text and try the edit again.",
"details": {
"editIndex": 0
}
}
}
|
Name |
Description |
|
error.code |
String error code. Use it to identify the type of exception |
|
error.message |
Text description of the error |
|
error.validation |
Array with error details. Present only in data validation errors |
|
error.validation[].field |
Name of the field where the validation error occurred |
|
error.validation[].message |
Description of the error related to the specified field |
Possible Error Codes
|
HTTP Status |
Code |
Description |
|
|
|
The request is malformed:
The field with the error is passed in |
|
|
|
The |
|
|
|
Multiple occurrences of |
|
|
|
The ranges of multiple replacements overlap. The replacement indexes are passed in the |
|
|
|
A replacement or the new |
|
|
|
The document content is stored in a legacy format that the method does not support |
|
|
|
The text exceeds 1 048 576 bytes: the |
|
|
|
The text is too complex to process. The reason is passed in
|
|
|
|
The change is too large to send to open document editors: more than 921 600 bytes. Split the edit into several calls. The size and limit are passed in |
|
|
|
The current document content on the server is too large for the method to process. Open the document in the editor and repeat the call |
|
|
|
The current state of the document could not be read |
|
|
|
The document is locked by another operation, and the lock could not be acquired within the allotted time |
|
|
|
The document does not exist, is archived or in the Recycle Bin, cannot be viewed by the user, or a template or a knowledge base system document was specified |
|
|
|
The user can view the document but does not have "Edit" permission |
Statuses and System Error Codes
HTTP Status: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The SQL query inside the method ran longer than the SQL query time limit. The |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block lasts 5 minutes, after which the accumulated execution time of the method is counted from zero |
|
|
|
The same block in REST 3.0 methods. The |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
The Bitrix24 Market application is blocked because the number of installed applications exceeds the plan limit. Events are not delivered to such an application. Applications exempt from the limit are not blocked |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |