[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Finvoices\u002Fupdate":3,"docs-tabs-entities\u002Finvoices\u002Fupdate":6},{"content":4,"lastmod":5},"\n## Update invoice\n\n`PATCH \u002Fv1\u002Finvoices\u002F:id`\n\nUpdates invoice fields. Pass only the fields being changed.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Invoice ID |\n\n## Request fields (body)\n\n| Field | Type | Description |\n|------|-----|---------|\n| `title` | string | Invoice title |\n| `stageId` | string | Stage. Format: `DT31_{categoryId}:{stage}`. Stage list: `GET \u002Fv1\u002Fstatuses?filter[entityId]=SMART_INVOICE_STAGE_{categoryId}` — categoryId depends on the Bitrix24 account. To find it: `GET \u002Fv1\u002Finvoices?limit=1&select=categoryId` or ask your Bitrix24 account administrator |\n| `categoryId` | number | Pipeline ID |\n| `contactId` | number | Payer contact ID. Lookup: `GET \u002Fv1\u002Fcontacts` |\n| `companyId` | number | Payer company ID. Lookup: `GET \u002Fv1\u002Fcompanies` |\n| `mycompanyId` | number | ID of your own company (the seller) issuing the invoice. Lookup: `GET \u002Fv1\u002Fcompanies` |\n| `opportunity` | number | Amount |\n| `currencyId` | string | Currency. List: `GET \u002Fv1\u002Fcurrencies` |\n| `assignedById` | number | Assignee. List: `GET \u002Fv1\u002Fusers` |\n| `begindate` | datetime | Invoice start date |\n| `closedate` | datetime | Invoice payment date |\n| `accountNumber` | string | Printable invoice number |\n| `comments` | string | Comment |\n\nPass only the fields being changed, but at least one: an empty body is rejected with `400 EMPTY_UPDATE_BODY`.\n\nFull list of fields: [GET \u002Fv1\u002Finvoices\u002Ffields](\u002Fdocs\u002Fentities\u002Finvoices\u002Ffields). User fields (`ufCrm_*`) are also accepted.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PATCH https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Finvoices\u002F129 \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"opportunity\": 200000,\n    \"stageId\": \"DT31_5:P\"\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PATCH https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Finvoices\u002F129 \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"opportunity\": 200000,\n    \"stageId\": \"DT31_5:P\"\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Finvoices\u002F129', {\n  method: 'PATCH',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    opportunity: 200000,\n    stageId: 'DT31_5:P',\n  }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Updated:', data.id)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Finvoices\u002F129', {\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    opportunity: 200000,\n    stageId: 'DT31_5:P',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data` | object | The invoice in full after the update. For every field see [Invoice fields](\u002Fdocs\u002Fentities\u002Finvoices\u002Ffields) |\n\n## Response example\n\nKey fields are shown. For the full record see [Invoice fields](\u002Fdocs\u002Fentities\u002Finvoices\u002Ffields).\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": 129,\n    \"title\": \"Invoice for services\",\n    \"stageId\": \"DT31_5:P\",\n    \"categoryId\": 5,\n    \"contactId\": 42,\n    \"companyId\": 15,\n    \"opportunity\": 200000,\n    \"currencyId\": \"USD\",\n    \"assignedById\": 1,\n    \"createdBy\": 1,\n    \"createdTime\": \"2026-08-25T08:13:37.000Z\",\n    \"updatedTime\": \"2026-08-25T08:13:56.000Z\"\n  }\n}\n```\n\n## Error response example\n\n404 — invoice not found:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"Item not found\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 404 | `ENTITY_NOT_FOUND` | Invoice with the specified ID not found |\n| 400 | `EMPTY_UPDATE_BODY` | The request body is empty — at least one field is needed |\n| 400 | `READONLY_FIELD` | The body carries a read-only field — `id`, `createdBy`, `createdTime` or any other field marked so in [`GET \u002Fv1\u002Finvoices\u002Ffields`](\u002Fdocs\u002Fentities\u002Finvoices\u002Ffields) |\n| 400 | `INVALID_PARAMS` | The `id` in the URL is not a non-negative integer |\n| 403 | `SCOPE_DENIED` | API key lacks the `crm` scope |\n| 401 | `TOKEN_MISSING` | API key has no configured tokens |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**An unknown scalar field name is never stored.** It raises no error: the response comes back with `200`, the other fields passed are written, and the unknown one simply does not reach the record. An object under `fields` is rejected with `400 NESTED_FIELDS_ENVELOPE` before the update — pass invoice fields at the JSON root. A typo in a field name cannot be caught by the response code — check names against the [`GET \u002Fv1\u002Finvoices\u002Ffields`](\u002Fdocs\u002Fentities\u002Finvoices\u002Ffields) schema.\n\n## See also\n\n- [Working with files in CRM fields](\u002Fdocs\u002Frecipes\u002Fcrm-files)\n- [Get invoice](\u002Fdocs\u002Fentities\u002Finvoices\u002Fget)\n- [Invoice fields](\u002Fdocs\u002Fentities\u002Finvoices\u002Ffields)\n- [Create invoice](\u002Fdocs\u002Fentities\u002Finvoices\u002Fcreate)\n- [Entity API](\u002Fdocs\u002Fentity-api)\n","2026-10-15",{},1794739382428]