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: note

Who 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
type

Description

id*
integer

Document identifier

edits*
array

Array of 1 to 50 replacements. Object structure description.

Pass either edits or markdown

markdown*
string

New full document text in Markdown, no more than 1 048 576 bytes.

Blocks from opaqueBlocks that the new text retains unchanged and in the same order remain as they are. Blocks missing from the new text are deleted. Such a block cannot be modified: the method returns NOTE_CONTENT_BLOCK_UNSUPPORTED.

Pass either edits or markdown

Edits Parameter

Name
type

Description

old*
string

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 \n.

If multiple matches are found and replaceAll is not passed or is false, the method returns NOTE_CONTENT_MATCH_AMBIGUOUS. Replacement ranges must not overlap, including passing the same old in two replacements

new*
string

New Markdown fragment

replaceAll
boolean

Replace all occurrences of old.

Default: false

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
type

Description

item
object

Document modification result. Object structure description

time
time

Information about the request execution time

Item Object

Name
type

Description

id
integer

Document identifier

changed
boolean

true if the document changed; false if the edit resulted in the same text and no write was performed

markdown
string

Current document text after the edit, including concurrent co-author changes

lossless
boolean

true if Markdown fully represents the document content

opaqueBlocks
array

Blocks that Markdown cannot fully represent. The field format is described in note.document.content.get

warnings
array

Warnings about Markdown transformations when applying the edit. Object structure description

Warnings Object

Name
type

Description

editIndex
integer

Replacement index in the edits array, starting from 0. null if the full markdown was passed

code
string

Warning code:

  • DEGRADED_TO_PARAGRAPH — the block does not match the document schema and became a paragraph with its text
  • BLOCK_DROPPED — the block does not match the document schema and contains no text, so it was skipped
  • INVALID_UTF8 — the text was not in UTF-8, and invalid bytes were replaced
  • PARTIALLY_PARSED — part of the text was too long or complex to parse as Markdown and was retained as plain text
  • LINK_DROPPED — the link to an invalid address was removed, and its text was retained
  • FILE_NOT_ACCESSIBLE — the file from the [[file fileId=…]] token is unavailable to the user, and the token was retained as text

message
string

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
type

Description

error.code
string

String error code. Use it to identify the type of exception

error.message
string

Text description of the error

error.validation
array

Array with error details. Present only in data validation errors BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION

error.validation[].field
string

Name of the field where the validation error occurred

error.validation[].message
string

Description of the error related to the specified field

Possible Error Codes

HTTP Status

Code

Description

400

NOTE_CONTENT_EDIT_INVALID

The request is malformed:

  • both edits and markdown were passed, or neither was passed
  • edits is empty or contains more than 50 elements
  • a replacement has an empty old, is missing new, has a non-Boolean replaceAll, contains an extra field, or the text is not in UTF-8
  • the replacement Markdown does not match the document schema

The field with the error is passed in details.field, and the replacement index is passed in details.editIndex

409

NOTE_CONTENT_MATCH_NOT_FOUND

The old fragment was not found in the current Markdown. The replacement index is passed in details.editIndex

409

NOTE_CONTENT_MATCH_AMBIGUOUS

Multiple occurrences of old were found, and replaceAll was not passed or is false. The number of matches is passed in details.matches, and the replacement index is passed in details.editIndex

400

NOTE_CONTENT_EDITS_OVERLAP

The ranges of multiple replacements overlap. The replacement indexes are passed in the details.editIndexes array

409

NOTE_CONTENT_BLOCK_UNSUPPORTED

A replacement or the new markdown modifies a block from opaqueBlocks, or an old boundary passes inside such a block. The block can be retained unchanged or deleted as a whole. The block index and type are passed in details.blockIndex and details.nodeType

409

NOTE_CONTENT_FORMAT_UNSUPPORTED

The document content is stored in a legacy format that the method does not support

400

NOTE_MARKDOWN_TOO_LARGE

The text exceeds 1 048 576 bytes: the markdown value, the total length of all old values, the total length of all new values, or the resulting document text. The limit is passed in details.limit, and the request field is passed in details.field: markdown, edits[].old, or edits[].new. No field is passed for the resulting text

400

NOTE_CONTENT_MARKDOWN_TOO_COMPLEX

The text is too complex to process. The reason is passed in details.reason:

  • PARSE_BUDGET — Markdown parsing exceeds the allowed processing budget
  • MATCH_LIMIT — replacements in a single request find more than 1000 matches; the limit is passed in details.limit

400

NOTE_CONTENT_PATCH_TOO_LARGE

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 details.size and details.limit

409

NOTE_CONTENT_TOO_LARGE

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

409

NOTE_CONTENT_UNREADABLE

The current state of the document could not be read

409

NOTE_CONTENT_LOCKED

The document is locked by another operation, and the lock could not be acquired within the allotted time

400

BITRIX_REST_V3_EXCEPTION_ENTITYNOTFOUNDEXCEPTION

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

403

BITRIX_REST_V3_EXCEPTION_ACCESSDENIEDEXCEPTION

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
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

503

BITRIX_REST_V3_EXCEPTION_LIMITER_QUERYTIMELIMITEXCEPTION
Request canceled: query time limit exceeded

The SQL query inside the method ran longer than the SQL query time limit. The Retry-After header contains the limit in seconds

429

OPERATION_TIME_LIMIT
Method is blocked due to operation time limit

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

429

BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION
Request was blocked because the limit was exceeded

The same block in REST 3.0 methods. The Retry-After header contains the remaining block time in seconds

401

NO_AUTH_FOUND
Wrong authorization data

The request contains no authorization data: neither an access token nor a webhook code was passed

401

INVALID_REQUEST
Https required

Methods are called over the HTTPS protocol only

401

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support

401

ACCESS_DENIED
REST is available only on commercial plans

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 — REST is available only by subscription

403

FEATURE_NOT_AVAILABLE_ON_CURRENT_PLAN
This feature is not available on your current plan.

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

401

INVALID_CREDENTIALS
Invalid request credentials

No active webhook with the specified user identifier and secret code was found

404

ERROR_METHOD_NOT_FOUND
Method not 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

401

insufficient_scope
The request requires higher privileges than provided by the webhook token

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 provided by the access token

401

expired_token
The access token provided has expired

The access token has expired

401

user_access_error
The user does not have access to the application

The application is installed, but the Bitrix24 administrator has granted access to it only to specific users

403

PORTAL_DELETED
Portal was deleted

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

Continue Learning