لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/documents/crm-update.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Update a CRM document

PATCH /v1/crm-documents/:id

Changes template field values or the stamps flag of a CRM record document and regenerates the document file. Fields are passed at the JSON root, without a fields wrapper.

Parameters

Parameter Type Required Description
Parameterid (path) Typenumber Requiredyes DescriptionDocument ID, a positive integer. Documents of a record: GET /v1/crm-documents

Request fields (body)

Pass at least one of the fields.

Field Type Required Description
Fieldvalues Typeobject Requiredno DescriptionTemplate field values. Keys are merged into the saved ones: keys missing from the request are kept. For example, DocumentNumber sets the document number
FieldstampsEnabled Typeboolean Requiredno DescriptionTurns stamps and signatures on or off. If the field is omitted, stamps are turned on. To keep them off, pass stampsEnabled: false in every request

The request does not accept other fields, such as title or templateId. The stamps flag goes only at the body root, not inside values.

Examples

curl — personal key

Terminal
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-documents/1961" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "values": { "DocumentNumber": "VIBE-1" },
    "stampsEnabled": false
  }'

curl — OAuth application

Terminal
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-documents/1961" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "values": { "DocumentNumber": "VIBE-1" },
    "stampsEnabled": false
  }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-documents/1961', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    values: { DocumentNumber: 'VIBE-1' },
    stampsEnabled: false,
  }),
})

const { success, data } = await res.json()
console.log('New number:', data.number)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-documents/1961', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    values: { DocumentNumber: 'VIBE-1' },
    stampsEnabled: false,
  }),
})

const { success, data } = await res.json()

Response fields

Returns the updated document. The full description of document fields is on the Get a CRM document page.

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.id Typestring DescriptionDocument ID
Fielddata.number Typestring DescriptionDocument number after the update
Fielddata.values Typeobject DescriptionTemplate field values after the update, together with service keys
Fielddata.stampsEnabled Typeboolean DescriptionStamps flag the document was generated with
Fielddata.updateTime Typestring DescriptionUpdate time in ISO 8601 format
Fielddata.updatedBy Typenumber DescriptionID of the employee who updated the document. List: GET /v1/users
Fielddata.createTime Typestring DescriptionIn this method's response, the time the file was regenerated. The document creation date is returned by GET /v1/crm-documents/:id
Fielddata.createdBy Typenull Descriptionnull in this method's response. The creator is returned by GET /v1/crm-documents/:id
Fielddata.downloadUrlMachine Typestring Description/v1/crm-documents/:id/download URL for downloading the new DOCX. Requires X-Api-Key with the crm scope

Response example

Only the main fields are shown. Full list: Get a CRM document.

JSON
{
  "success": true,
  "data": {
    "changeStampsEnabled": false,
    "downloadUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=crm.documentgenerator.document.download&SITE_ID=s1&id=1961",
    "publicUrl": null,
    "title": "Addresses A463//10/2026",
    "number": "VIBE-1",
    "id": "1961",
    "createTime": "2026-10-08T17:57:43+00:00",
    "createdBy": null,
    "updateTime": "2026-10-08T17:57:42+00:00",
    "updatedBy": 1317,
    "stampsEnabled": false,
    "values": {
      "productsTableVariant": "",
      "stampsEnabled": false,
      "_creationMethod": "rest",
      "DocumentNumber": "VIBE-1"
    },
    "templateId": "87",
    "entityId": "8781",
    "entityTypeId": "2",
    "downloadUrlMachine": "https://vibecode.bitrix24.com/v1/crm-documents/1961/download"
  }
}

Error response example

400 — the body has neither values nor stampsEnabled:

JSON
{
  "success": false,
  "error": {
    "code": "MISSING_REQUIRED_FIELDS",
    "message": "values or stampsEnabled is required"
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS Descriptionid is not a positive integer. Message: id must be a positive integer
HTTP400 CodeMISSING_REQUIRED_FIELDS DescriptionThe body is {} or not a JSON object, for example an array. Message: values or stampsEnabled is required
HTTP400 CodeREADONLY_FIELD DescriptionThe body has a field other than values and stampsEnabled, for example title
HTTP400 CodeINVALID_PARAMS Descriptionvalues is not an object, values contains stampsEnabled, or stampsEnabled is not a boolean
HTTP404 CodeENTITY_NOT_FOUND DescriptionNo document with this id exists, or it was deleted
HTTP502 CodeBITRIX_INVALID_RESPONSE DescriptionBitrix24 responded without the document or without the stamps flag
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionNo access to the CRM record the document is attached to, including when the record does not exist. Message: Access denied
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is in read-only mode
HTTP403 CodeSCOPE_DENIED DescriptionThe key lacks the crm scope
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeTOKEN_MISSING DescriptionThe key has no tokens mapped to it — an OAuth application key was called without a user session

Full list of common API errors — Errors.

Known specifics

The PDF and image are regenerated. After an update, the DOCX, PDF and image are regenerated. Until they are ready, the PDF download responds with 409 DOCUMENT_NOT_READY.

The previous stamps value is not kept. A request with only values generates the file with stamps, even if the document was created or updated by a previous request with stampsEnabled: false. The flag in GET /v1/crm-documents/:id is not reliable for checking this. For details, see "Known specifics" on the Get a CRM document page.

See also