[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fdeals\u002Fproducts-set":3,"docs-tabs-entities\u002Fdeals\u002Fproducts-set":6},{"content":4,"lastmod":5},"## Set deal products\n\n`PUT \u002Fv1\u002Fdeals\u002F:id\u002Fproducts`\n\nSets the deal product rows. Replaces the current list as a whole — pass all the rows you need.\n\n> **Field names are validated.** A field name that is not in the writable set is not dropped silently: the request is rejected with `400 INVALID_PARAMS` and the error text lists the writable names. Read-only fields that appear in product-row responses — `priceAccount`, `ownerId`, `storeId` and others — are accepted and ignored, so an object read via `GET` can be sent back as is.\n\n> **Row identifiers do not carry over.** A row whose fields are unchanged keeps its `id`. A modified one comes back with a new `id` even when the previous identifier is sent in the body. To edit a row and keep its `id`, use [`PATCH \u002Fv1\u002Fdeals\u002F:id\u002Fproducts\u002F:rowId`](\u002Fdocs\u002Fentities\u002Fdeals\u002Fproducts-update).\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Deal ID. List: [`GET \u002Fv1\u002Fdeals`](\u002Fdocs\u002Fentities\u002Fdeals\u002Flist) |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `items` | array | yes | Array of product rows. An empty array deletes every row of the deal |\n| `items[].productId` | number | no | Catalog product ID. Catalog: [`GET \u002Fv1\u002Fproducts`](\u002Fdocs\u002Fentities\u002Fproducts\u002Flist). With neither `productId` nor `productName`, the row is created with no product and an empty name |\n| `items[].productName` | string | no | Row name — for a free-text row with no catalog product |\n| `items[].price` | number | no | Unit price. Without it the row is created with a zero price |\n| `items[].quantity` | number | no | Quantity. Without it the row is created with a quantity of `1` |\n| `items[].discountTypeId` | number | no | How the discount is set: `1` — as an amount in `discount`, `2` — as a percentage in `discountRate`. Defaults to `2` |\n| `items[].discount` | number | no | Discount amount. Applied only when `discountTypeId` is `1` |\n| `items[].discountRate` | number | no | Discount percentage. Applied only when `items[].discountTypeId` is `2` |\n| `items[].taxRate` | number | no | Tax rate (%) |\n| `items[].taxIncluded` | boolean | no | Tax included in the price |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdeals\u002F8815\u002Fproducts\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"items\": [\n      { \"productId\": 6967, \"price\": 25000, \"quantity\": 2 },\n      { \"productId\": 6969, \"price\": 5000, \"quantity\": 1, \"discountTypeId\": 1, \"discount\": 500 }\n    ]\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdeals\u002F8815\u002Fproducts\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"items\": [\n      { \"productId\": 6967, \"price\": 25000, \"quantity\": 2 },\n      { \"productId\": 6969, \"price\": 5000, \"quantity\": 1, \"discountTypeId\": 1, \"discount\": 500 }\n    ]\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdeals\u002F8815\u002Fproducts', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    items: [\n      { productId: 6967, price: 25000, quantity: 2 },\n      { productId: 6969, price: 5000, quantity: 1, discountTypeId: 1, discount: 500 },\n    ],\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdeals\u002F8815\u002Fproducts', {\n  method: 'PUT',\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    items: [\n      { productId: 6967, price: 25000, quantity: 2 },\n      { productId: 6969, price: 5000, quantity: 1, discountTypeId: 1, discount: 500 },\n    ],\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` | array | Every deal row after the replacement, each in full. Row fields — see [Product fields](\u002Fdocs\u002Fentities\u002Fdeals\u002Fproducts-fields) |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": [\n    {\n      \"id\": 2369,\n      \"ownerId\": 8815,\n      \"ownerType\": \"D\",\n      \"productId\": 6967,\n      \"productName\": \"Parent product\",\n      \"price\": 25000,\n      \"priceAccount\": 25000,\n      \"priceExclusive\": 25000,\n      \"priceNetto\": 25000,\n      \"priceBrutto\": 25000,\n      \"quantity\": 2,\n      \"discountTypeId\": 2,\n      \"discountRate\": 0,\n      \"discount\": 0,\n      \"taxRate\": null,\n      \"taxIncluded\": false,\n      \"customized\": \"Y\",\n      \"measureCode\": 796,\n      \"measureName\": \"pcs\",\n      \"sort\": 0,\n      \"xmlId\": \"sale_basket_1399\",\n      \"type\": 3,\n      \"storeId\": null\n    },\n    {\n      \"id\": 2371,\n      \"ownerId\": 8815,\n      \"ownerType\": \"D\",\n      \"productId\": 6969,\n      \"productName\": \"Service\",\n      \"price\": 5000,\n      \"priceAccount\": 5000,\n      \"priceExclusive\": 5000,\n      \"priceNetto\": 5500,\n      \"priceBrutto\": 5500,\n      \"quantity\": 1,\n      \"discountTypeId\": 1,\n      \"discountRate\": 0,\n      \"discount\": 500,\n      \"taxRate\": null,\n      \"taxIncluded\": false,\n      \"customized\": \"Y\",\n      \"measureCode\": 796,\n      \"measureName\": \"pcs\",\n      \"sort\": 0,\n      \"xmlId\": \"sale_basket_1401\",\n      \"type\": 7,\n      \"storeId\": null\n    }\n  ]\n}\n```\n\n## Error response example\n\n400 — invalid format:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"items must be an array\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | The body contains a field name that is not among the writable fields — see [Product fields](\u002Fdocs\u002Fentities\u002Fdeals\u002Fproducts-fields) |\n| 400 | `INVALID_PARAMS` | `items` is not an array |\n| 400 | `INVALID_PARAMS` | An entry in the `items` array carries no writable product-row field — an empty object, or read-only fields only. The error text lists the writable names |\n| 404 | `ENTITY_NOT_FOUND` | Deal not found. The message is `Owner was not found` |\n| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 401 | `TOKEN_MISSING` | The API key has no configured tokens |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Full replacement:** PUT replaces the entire product list. To add a row, first get the current ones (`GET`), add the new one to the array, and send everything back (`PUT`). Fetch the whole list: without `limit`, [`GET`](.\u002Fproducts-get.md) returns only the first page, so pass `limit=5000` or page through with `offset` until `meta.hasMore` is `false`. Sending back an incomplete list erases everything it omits.\n\n**A fixed-amount discount requires `discountTypeId: 1`.** The discount type defaults to `2`, a percentage, and in that mode the `discount` field is not stored: the row comes back with `discount: 0` and no error is raised. To set a discount as an amount, send `discountTypeId: 1` together with `discount`. To set it as a percentage, send `discountRate` with type `2`.\n\n## See also\n\n- [Product rows](\u002Fdocs\u002Fentities\u002Fdeals\u002Fproducts-get)\n- [Get a deal](\u002Fdocs\u002Fentities\u002Fdeals\u002Fget)\n- [CRM products](\u002Fdocs\u002Fentities\u002Fproducts)\n- [Limits and optimization](\u002Fdocs\u002Foptimization)\n","2026-10-14",{},1794739369382]