[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fdocuments\u002Fcrm-update":3,"docs-tabs-entities\u002Fdocuments\u002Fcrm-update":6},{"content":4,"lastmod":5},"## Update a CRM document\n\n`PATCH \u002Fv1\u002Fcrm-documents\u002F:id`\n\nChanges 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.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Document ID, a positive integer. Documents of a record: [`GET \u002Fv1\u002Fcrm-documents`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-list) |\n\n## Request fields (body)\n\nPass at least one of the fields.\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `values` | object | no | Template field values. Keys are merged into the saved ones: keys missing from the request are kept. For example, `DocumentNumber` sets the document number |\n| `stampsEnabled` | boolean | no | Turns 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 |\n\nThe request does not accept other fields, such as `title` or `templateId`. The stamps flag goes only at the body root, not inside `values`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PATCH \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-documents\u002F1961\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"values\": { \"DocumentNumber\": \"VIBE-1\" },\n    \"stampsEnabled\": false\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PATCH \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-documents\u002F1961\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"values\": { \"DocumentNumber\": \"VIBE-1\" },\n    \"stampsEnabled\": false\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-documents\u002F1961', {\n  method: 'PATCH',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    values: { DocumentNumber: 'VIBE-1' },\n    stampsEnabled: false,\n  }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('New number:', data.number)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-documents\u002F1961', {\n  method: 'PATCH',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    values: { DocumentNumber: 'VIBE-1' },\n    stampsEnabled: false,\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\nReturns the updated document. The full description of document fields is on the [Get a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get) page.\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.id` | string | Document ID |\n| `data.number` | string | Document number after the update |\n| `data.values` | object | Template field values after the update, together with service keys |\n| `data.stampsEnabled` | boolean | Stamps flag the document was generated with |\n| `data.updateTime` | string | Update time in ISO 8601 format |\n| `data.updatedBy` | number | ID of the employee who updated the document. List: [`GET \u002Fv1\u002Fusers`](\u002Fdocs\u002Fentities\u002Fusers) |\n| `data.createTime` | string | In this method's response, the time the file was regenerated. The document creation date is returned by [`GET \u002Fv1\u002Fcrm-documents\u002F:id`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get) |\n| `data.createdBy` | null | `null` in this method's response. The creator is returned by [`GET \u002Fv1\u002Fcrm-documents\u002F:id`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get) |\n| `data.downloadUrlMachine` | string | [`\u002Fv1\u002Fcrm-documents\u002F:id\u002Fdownload`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fdownload) URL for downloading the new DOCX. Requires `X-Api-Key` with the `crm` scope |\n\n## Response example\n\nOnly the main fields are shown. Full list: [Get a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get).\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"changeStampsEnabled\": false,\n    \"downloadUrl\": \"https:\u002F\u002Fexample.bitrix24.com\u002Fbitrix\u002Fservices\u002Fmain\u002Fajax.php?action=crm.documentgenerator.document.download&SITE_ID=s1&id=1961\",\n    \"publicUrl\": null,\n    \"title\": \"Addresses A463\u002F\u002F10\u002F2026\",\n    \"number\": \"VIBE-1\",\n    \"id\": \"1961\",\n    \"createTime\": \"2026-10-08T17:57:43+00:00\",\n    \"createdBy\": null,\n    \"updateTime\": \"2026-10-08T17:57:42+00:00\",\n    \"updatedBy\": 1317,\n    \"stampsEnabled\": false,\n    \"values\": {\n      \"productsTableVariant\": \"\",\n      \"stampsEnabled\": false,\n      \"_creationMethod\": \"rest\",\n      \"DocumentNumber\": \"VIBE-1\"\n    },\n    \"templateId\": \"87\",\n    \"entityId\": \"8781\",\n    \"entityTypeId\": \"2\",\n    \"downloadUrlMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-documents\u002F1961\u002Fdownload\"\n  }\n}\n```\n\n## Error response example\n\n400 — the body has neither `values` nor `stampsEnabled`:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"MISSING_REQUIRED_FIELDS\",\n    \"message\": \"values or stampsEnabled is required\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `id` is not a positive integer. Message: `id must be a positive integer` |\n| 400 | `MISSING_REQUIRED_FIELDS` | The body is `{}` or not a JSON object, for example an array. Message: `values or stampsEnabled is required` |\n| 400 | `READONLY_FIELD` | The body has a field other than `values` and `stampsEnabled`, for example `title` |\n| 400 | `INVALID_PARAMS` | `values` is not an object, `values` contains `stampsEnabled`, or `stampsEnabled` is not a boolean |\n| 404 | `ENTITY_NOT_FOUND` | No document with this `id` exists, or it was deleted |\n| 502 | `BITRIX_INVALID_RESPONSE` | Bitrix24 responded without the document or without the stamps flag |\n| 403 | `BITRIX_ACCESS_DENIED` | No access to the CRM record the document is attached to, including when the record does not exist. Message: `Access denied` |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |\n| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |\n| 401 | `TOKEN_MISSING` | The key has no tokens mapped to it — an OAuth application key was called without a user session |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The PDF and image are regenerated.** After an update, the DOCX, PDF and image are regenerated. Until they are ready, the [PDF](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fpdf) download responds with `409 DOCUMENT_NOT_READY`.\n\n**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 \u002Fv1\u002Fcrm-documents\u002F:id`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get) is not reliable for checking this. For details, see \"Known specifics\" on the [Get a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get) page.\n\n## See also\n\n- [Get a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get)\n- [Create a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-create)\n- [Delete a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-delete)\n- [Documents by CRM record](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-list)\n- [Documents](\u002Fdocs\u002Fentities\u002Fdocuments)\n","2026-10-08",{},1794739374363]