## Update a shipment item

`PATCH /v1/shipment-items/:id`

Changes the product quantity and the external code of a shipment item in an online store order.

Fields are passed flat at the JSON root, without a `fields` wrapper. How a quantity change affects the free quantity of the basket item is described in [Shipment items](/docs/entities/shipment-items).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Shipment item ID, a non-negative integer. List: [`GET /v1/shipment-items`](./list.md) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `quantity` | number | yes | New product quantity in the shipment. Pass it in every request, including when only `xmlId` changes. A fractional value is stored without rounding. A numeric string with a decimal point is also accepted, for example `"0.5"`. An increase is limited by the free quantity of the basket item |
| `xmlId` | string | no | External code |
| `orderDeliveryId` | number | no | RO. Set only on [creation](./create.md). To move the item to another shipment, delete it and create it again |
| `basketId` | number | no | RO. Set only on [creation](./create.md) |
| `reservedQuantity` | number | no | RO. Reserved quantity |

Full list of fields: [`GET /v1/shipment-items/fields`](./fields.md).

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/shipment-items/1353" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": 0.75,
    "xmlId": "vibe-doc-si-1"
  }'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/shipment-items/1353" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": 0.75,
    "xmlId": "vibe-doc-si-1"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/shipment-items/1353', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    quantity: 0.75,
    xmlId: 'vibe-doc-si-1',
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/shipment-items/1353', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    quantity: 0.75,
    xmlId: 'vibe-doc-si-1',
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` on success |
| `data` | object | The updated shipment item with all fields |
| `data.id` | number | Shipment item ID |
| `data.orderDeliveryId` | number | Shipment ID |
| `data.basketId` | number | Basket item ID |
| `data.quantity` | number | Product quantity in the shipment after the change |
| `data.reservedQuantity` | number | Reserved quantity |
| `data.xmlId` | string | External code |
| `data.dateInsert` | datetime | Creation date, ISO 8601 |

## Response example

```json
{
  "success": true,
  "data": {
    "basketId": 1387,
    "dateInsert": "2026-10-07T09:55:27.000Z",
    "id": 1353,
    "orderDeliveryId": 1207,
    "quantity": 0.75,
    "reservedQuantity": 0,
    "xmlId": "vibe-doc-si-1"
  }
}
```

## Error response example

404 — no shipment item with this `id`:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "shipment item is not exists"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `READONLY_FIELD` | The body contains a read-only field: `orderDeliveryId`, `basketId`, `reservedQuantity`, `id` and others. The field name is in `message` |
| 400 | `EMPTY_UPDATE_BODY` | The request body is empty or is not a JSON object |
| 400 | `INVALID_PARAMS` | A field value does not match its type, for example the string `"abc"` in the numeric `quantity`. The field name is in `message` |
| 400 | `INVALID_PARAMS` | `id` in the path is not a non-negative integer |
| 404 | `ENTITY_NOT_FOUND` | No shipment item with this `id`: `shipment item is not exists` |
| 404 | `ENTITY_NOT_FOUND` | The item belongs to the system shipment, and the passed `quantity` equals the current one. The change is not saved: `shipmentItem <id> not found` |
| 422 | `BITRIX_ERROR` | The item belongs to the system shipment, and a new `quantity` is passed. The change is not saved: `System shipment cannot be modified`, `b24Code` is `150` |
| 422 | `BITRIX_ERROR` | The body has no `quantity`, for example only `xmlId` or only a field with an unknown name is passed: `Required fields: quantity` |
| 422 | `BITRIX_ERROR` | The new `quantity` exceeds the quantity available to the basket item, `b24Code` is `SALE_SHIPMENT_ITEM_LESS_AVAILABLE_QUANTITY` |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the change for another reason. The reason is in `message` |
| 403 | `BITRIX_ACCESS_DENIED` | The key's user has no permission to modify orders in Bitrix24 |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key works in read-only mode |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 403 | `MANAGEMENT_KEY_NO_ENTITY_ACCESS` | The request is made with a management key. Entities require an application key or a personal key with the `sale` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is not passed |
| 401 | `INVALID_API_KEY` | The passed API key is not found |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

Full list of common API errors: [Errors](/docs/errors).

## See also

- [Shipment items](/docs/entities/shipment-items)
- [Get a shipment item](./get.md)
- [Create a shipment item](./create.md)
- [Delete a shipment item](./delete.md)
- [Shipment item fields](./fields.md)
- [Shipments](/docs/entities/shipments)
- [Basket items](/docs/entities/basket-items)
