## Update a basket item property

`PATCH /v1/basket-item-properties/:id`

Updates the value and other writable fields of an existing basket item property by its ID.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Property ID. Source: [`GET /v1/basket-item-properties`](./list.md) |

## Request body fields

Pass fields at the root of the JSON body, without a `fields` wrapper.

| Field | Type | Required | Description |
|------|------|------|------|
| `name` | string | no | Property name |
| `value` | string \| null | no | Property value |
| `code` | string \| null | no | Property symbolic code |
| `sort` | number | no | Sort order |
| `xmlId` | string \| null | no | External ID |
| `id` | number | no | Property ID. Source: [`GET /v1/basket-item-properties`](./list.md). `RO`. Read-only, assigned by the server. |
| `basketId` | number | no | Basket item ID. Source: [`GET /v1/basket-items`](/docs/entities/basket-items/list). Create-only. Do not send in PATCH. |

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/basket-item-properties/1037" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Color",
  "code": "COLOR",
  "value": "Red",
  "sort": 200,
  "xmlId": "color-red"
}'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/basket-item-properties/1037" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Color",
  "code": "COLOR",
  "value": "Red",
  "sort": 200,
  "xmlId": "color-red"
}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/basket-item-properties/1037', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Color",
    "code": "COLOR",
    "value": "Red",
    "sort": 200,
    "xmlId": "color-red"
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/basket-item-properties/1037', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Color",
    "code": "COLOR",
    "value": "Red",
    "sort": 200,
    "xmlId": "color-red"
  }),
})

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

## Response fields

| Field | Type | Description |
|------|------|------|
| `success` | boolean | `true` on success. HTTP status: `200` |
| `data` | object | Updated basket item property |
| `data.id` | number | Property ID. Source: [`GET /v1/basket-item-properties`](./list.md) |
| `data.basketId` | number | Basket item ID. Source: [`GET /v1/basket-items`](/docs/entities/basket-items/list) |
| `data.name` | string | Property name |
| `data.value` | string \| null | Property value |
| `data.code` | string \| null | Property symbolic code |
| `data.sort` | number | Sort order |
| `data.xmlId` | string \| null | External ID |

## Response example

```json
{
  "success": true,
  "data": {
    "basketId": 1001,
    "code": "COLOR",
    "id": 1037,
    "name": "Color",
    "sort": 200,
    "value": "Red",
    "xmlId": "color-red"
  }
}
```

## Error response example

404 — property not found:

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

## Errors

| HTTP | Code | Description |
|------|------|------|
| 400 | `READONLY_FIELD` | The request contains `id` or `basketId`, which cannot be updated |
| 400 | `EMPTY_UPDATE_BODY` | The request body is empty |
| 400 | `NO_RECOGNIZED_UPDATE_FIELDS` | The body contains no recognized writable field |
| 400 | `INVALID_PARAMS` | The path `id` is not a non-negative integer |
| 404 | `ENTITY_NOT_FOUND` | No property exists with this `id`, or it has already been deleted |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the operation. The reason is in `message` |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 429 | `RATE_LIMITED` | The request limit was exceeded |

For the full list of shared API errors, see [Error codes](/docs/errors).

## Known specifics

If `name`, `code` or `value` is omitted, Vibecode reads their current values and supplies them before the write. Updating only `value` preserves the other fields.

## See also

- [List basket item properties](./list.md)
- [Get a basket item property](./get.md)
- [Create a basket item property](./create.md)
- [Delete a basket item property](./delete.md)
- [Basket item property fields](./fields.md)
- [Basket item properties](/docs/entities/basket-item-properties)
- [List basket items](/docs/entities/basket-items/list)
- [Batch calls](/docs/batch)
- [Entity API contract](/docs/entity-api)
