[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fshipment-items\u002Fbatch":3,"docs-tabs-entities\u002Fshipment-items\u002Fbatch":6},{"content":4,"lastmod":5},"## Batch operations on shipment items\n\n`POST \u002Fv1\u002Fshipment-items\u002Fbatch`\n\nCreate, update, delete or read shipment items in bulk with one request — up to 500 items per write and up to 50 calls per read. This is a dedicated endpoint for this entity, not to be confused with the [universal batch](\u002Fdocs\u002Fbatch), which combines operations on different entities and is limited to 50 calls.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `action` | string | yes | Batch operation: `create`, `update`, `delete` for writes, `list`, `get` for reads. One request performs one operation |\n| `items` | array | yes for `create` and `update` | List of items, up to 500 |\n| `items[].orderDeliveryId` | number | yes for `create` | Shipment ID. List: [`GET \u002Fv1\u002Fshipments`](\u002Fdocs\u002Fentities\u002Fshipments\u002Flist). Not passed in `update` — the field is read-only |\n| `items[].basketId` | number | yes for `create` | ID of a basket item of the same order. List: [`GET \u002Fv1\u002Fbasket-items`](\u002Fdocs\u002Fentities\u002Fbasket-items\u002Flist). Not passed in `update` — the field is read-only |\n| `items[].quantity` | number | yes | Product quantity in the shipment; a fractional value is stored without rounding. Required both in `create` and in every `update` item. An `update` item without `quantity` does not reject the batch — it fails inside a `200` response |\n| `items[].xmlId` | string | no | External code |\n| `items[].id` | number | yes for `update` | Shipment item ID. List: [`GET \u002Fv1\u002Fshipment-items`](.\u002Flist.md) |\n| `ids` | number[] | yes for `delete` | IDs of the shipment items to delete, up to 500. List: [`GET \u002Fv1\u002Fshipment-items`](.\u002Flist.md) |\n| `calls` | array | yes for `list` and `get` | List of read calls, up to 50. Each call is an object `{ \"params\": { … } }` |\n| `calls[].params` | object | yes | For `list` — the [item list](.\u002Flist.md) parameters: `filter`, `select`, `limit`, `offset`. For `get` — `{ \"id\": 1363 }` |\n\nThe field set of an `items` element matches the body of [`POST \u002Fv1\u002Fshipment-items`](.\u002Fcreate.md) and [`PATCH \u002Fv1\u002Fshipment-items\u002F:id`](.\u002Fupdate.md). The full list of item fields is in [`GET \u002Fv1\u002Fshipment-items\u002Ffields`](.\u002Ffields.md).\n\nThe `create` body is in the \"Examples\" section. Bodies of the other operations:\n\n- `update` — `{ \"action\": \"update\", \"items\": [{ \"id\": 1363, \"quantity\": 0.75 }] }`\n- `delete` — `{ \"action\": \"delete\", \"ids\": [1363] }`\n- `list` — `{ \"action\": \"list\", \"calls\": [{ \"params\": { \"filter\": { \"orderDeliveryId\": 985 }, \"limit\": 50 } }] }`\n- `get` — `{ \"action\": \"get\", \"calls\": [{ \"params\": { \"id\": 1363 } }] }`\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fshipment-items\u002Fbatch\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"action\": \"create\",\n    \"items\": [\n      { \"orderDeliveryId\": 1215, \"basketId\": 1387, \"quantity\": 0.5 }\n    ]\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fshipment-items\u002Fbatch\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"action\": \"create\",\n    \"items\": [\n      { \"orderDeliveryId\": 1215, \"basketId\": 1387, \"quantity\": 0.5 }\n    ]\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fshipment-items\u002Fbatch', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    action: 'create',\n    items: [\n      { orderDeliveryId: 1215, basketId: 1387, quantity: 0.5 },\n    ],\n  }),\n})\n\nconst { data } = await res.json()\ndata.results.forEach((item) => {\n  if (item.success) console.log(`#${item.index} → id=${item.id}`)\n  else console.log(`#${item.index} → error: ${item.error} ${item.message}`)\n})\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fshipment-items\u002Fbatch', {\n  method: 'POST',\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    action: 'create',\n    items: [\n      { orderDeliveryId: 1215, basketId: 1387, quantity: 0.5 },\n    ],\n  }),\n})\n\nconst { data } = await res.json()\n```\n\n## Response fields\n\nThe shape of `data` depends on the operation. For `create`, `update` and `delete`:\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` if the request passed validation as a whole. The result of each item is in `data.results[i].success` |\n| `data.results` | array | Array of results in the same order as the request's `items` or `ids` |\n| `data.results[].index` | number | Item index, starting from `0` |\n| `data.results[].success` | boolean | Result of this operation |\n| `data.results[].id` | number | ID of the shipment item — created, updated or deleted. Absent in a failed item |\n| `data.results[].error` | string | Error code of a failed item, for example `201250000001` for a repeated `basketId` + `orderDeliveryId` pair |\n| `data.results[].message` | string | Error text of a failed item |\n| `data.summary.total` | number | Total items processed |\n| `data.summary.succeeded` | number | How many succeeded |\n| `data.summary.failed` | number | How many failed |\n\nFor `list` and `get`, the `data` field is an array of results in the order of `calls`, not an object with `results`. Each element carries either `data` or `error`. Here the error code is in the `error` object as `error.code`, while for writes it is a string in `data.results[].error`:\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` if the request passed validation as a whole |\n| `data[].data` | array \\| object \\| null | For `list` — an array of items, for `get` — an item object or `null`. Item fields — [Shipment item fields](.\u002Ffields.md). With `select`, an item contains only the listed fields |\n| `data[].total` | number | `list` only — number of items matching the call's filter |\n| `data[].hasMore` | boolean | `list` only — whether there are items beyond `limit` and `offset` |\n| `data[].error.code` | string | Error code of a failed call: `CALL_FAILED` for a non-existent `id`, `INVALID_PARAMS` for a non-integer `id`, a filter validation code for an invalid `filter`, for example `UNKNOWN_FILTER_FIELD` |\n| `data[].error.message` | string | Error text of a failed call |\n\n## Response example\n\n`action: create` — the item is created:\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"results\": [\n      { \"index\": 0, \"success\": true, \"id\": 1363 }\n    ],\n    \"summary\": { \"total\": 1, \"succeeded\": 1, \"failed\": 0 }\n  }\n}\n```\n\n`action: create` — the second item repeated the `basketId` + `orderDeliveryId` pair of the first one and failed, while the top-level `success` stayed `true`:\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"results\": [\n      { \"index\": 0, \"success\": true, \"id\": 1361 },\n      {\n        \"index\": 1,\n        \"success\": false,\n        \"error\": \"201250000001\",\n        \"message\": \"Duplicate entry for key [basketId, orderDeliveryId]\"\n      }\n    ],\n    \"summary\": { \"total\": 2, \"succeeded\": 1, \"failed\": 1 }\n  }\n}\n```\n\n`action: list` — two calls for shipments `975` and `985` with the filter `{ \"orderDeliveryId\": { \"$in\": [975, 985] } }`: the first with `select: [\"id\", \"orderDeliveryId\", \"quantity\"]`, the second with `limit: 1` and `offset: 1`:\n\n```json\n{\n  \"success\": true,\n  \"data\": [\n    {\n      \"data\": [\n        { \"id\": 875, \"orderDeliveryId\": 975, \"quantity\": 1 },\n        { \"id\": 885, \"orderDeliveryId\": 985, \"quantity\": 10 },\n        { \"id\": 887, \"orderDeliveryId\": 985, \"quantity\": 5 }\n      ],\n      \"total\": 3,\n      \"hasMore\": false\n    },\n    {\n      \"data\": [\n        {\n          \"basketId\": 953,\n          \"dateInsert\": \"2025-03-03T22:02:39.000Z\",\n          \"id\": 885,\n          \"orderDeliveryId\": 985,\n          \"quantity\": 10,\n          \"reservedQuantity\": 0,\n          \"xmlId\": \"bx_67c618efc3256\"\n        }\n      ],\n      \"total\": 3,\n      \"hasMore\": true\n    }\n  ]\n}\n```\n\n## Error response example\n\n400 — a `create` item lacks a required field, so the whole batch is rejected:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BATCH_ITEM_VALIDATION\",\n    \"message\": \"Item at index 0: field 'basketId' is required to create shipmentItem\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_BATCH_ACTION` | `action` is not passed or is not one of the allowed operations — the list comes in the error text |\n| 400 | `BATCH_ITEM_VALIDATION` | `items`, `ids` or `calls` is empty or not an array, or an `items` element is not an object |\n| 400 | `BATCH_ITEM_VALIDATION` | A `create` item lacks `orderDeliveryId`, `basketId` or `quantity`, or a read-only field is passed: `id`, `dateInsert`, `reservedQuantity` |\n| 400 | `BATCH_ITEM_VALIDATION` | An `update` item lacks `id`, has no field other than `id`, or a read-only field is passed: `orderDeliveryId`, `basketId` |\n| 400 | `BATCH_ITEM_VALIDATION` | A field value has the wrong type, for example an object in `quantity` — the message names the field and the expected type |\n| 400 | `BATCH_ITEM_VALIDATION` | An item contains an object under `fields`; the message carries the item index and `NESTED_FIELDS_ENVELOPE`. Pass shipment item fields flat at the item's root |\n| 400 | `BATCH_ITEM_VALIDATION` | An ID in `ids` or `items[].id` is not a non-negative integer, for example `\"1.5\"` |\n| 400 | `BATCH_LIMIT_EXCEEDED` | More than 500 elements in `items` or `ids`, or more than 50 calls in `calls` |\n| 403 | `SCOPE_DENIED` | The API key lacks the `sale` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | `create`, `update` or `delete` with a read-only key — the batch is not executed |\n| 403 | `MANAGEMENT_KEY_NO_ENTITY_ACCESS` | Management key: entity sections are not available to it. A personal key or an OAuth application key is required |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is not passed |\n| 401 | `TOKEN_MISSING` | The API key has no configured tokens |\n| 429 | `RATE_LIMITED` | Rate limit exceeded: 30 requests per minute per portal (a batch costs more than a plain read). All API keys of the portal share one limit. The current limit is returned in the `x-ratelimit-limit` header. Retry after the delay in the `Retry-After` header |\n\nA `400` response means the whole batch is rejected before any write. Errors of individual items come inside a `200` response: for writes — in `data.results[i]` as the `error` and `message` fields, for reads — in `data[i].error`. This is how, for example, an `update` item without `quantity` fails — with the error \"Required fields: quantity\".\n\nFor the full list of common API errors, see [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**An item of a system shipment is returned as `null` by `get`, and `update` on it fails.** Unlike the single [`GET \u002Fv1\u002Fshipment-items\u002F:id`](.\u002Fget.md), which responds with `404`, a `get` call in the batch returns `{ \"data\": null }` without an error. An `update` element for such an item fails, just like the single [`PATCH`](.\u002Fupdate.md), while the other items of the batch continue to be processed. For an explanation of system shipments, see [Shipment items](\u002Fdocs\u002Fentities\u002Fshipment-items).\n\n## See also\n\n- [Create a shipment item](.\u002Fcreate.md)\n- [Update a shipment item](.\u002Fupdate.md)\n- [Delete a shipment item](.\u002Fdelete.md)\n- [List shipment items](.\u002Flist.md)\n- [Shipment items](\u002Fdocs\u002Fentities\u002Fshipment-items)\n- [Universal batch](\u002Fdocs\u002Fbatch)\n","2026-10-23",{},1795415294247]