> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# Set an item quantity

**Published**: 2026-11-30
**Category**: Commerce

## `PATCH /cart/lines`

**Set an item quantity**

Sets the quantity of one variant's line in the caller's cart and returns the cart. To
remove a line, call `DELETE /cart/lines/{variantId}`. The line takes the current
catalogue price.

The call first removes the lines that can no longer be sold, the requested one
included, and reports them in `removedLines`.

Errors: 422 `OUT_OF_STOCK` above the variant's stock on a site that refuses
overselling, with nothing changed, and 404 `CART_NOT_FOUND` when there is no cart or
the variant is not in it.

> **Note:** Available only on sites with e-commerce enabled.

### Request Body

Content-Type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `variantId` | string | Yes | Required. Product variant identifier (var_ prefixed id) |
| `quantity` | integer (1 to 999) | Yes | Required |


### Responses

| Status | Description |
| --- | --- |
| `200` | Successful response |
| `401` | Missing or invalid storefront publishable key |
| `402` | The site subscription does not currently permit this operation |
| `403` | The storefront key origin is not allowed |
| `404` | Site, resource, or commerce feature not found |
| `422` | Validation error |


### SDK

```typescript
import { createClient } from 'lynkow'

const lynkow = createClient({
  siteId: process.env.LYNKOW_SITE_ID!,
  publishableKey: process.env.LYNKOW_PK,
})

// The buyer typed 3 into the quantity box: set the line to exactly 3.
const cart = await lynkow.cart.updateLine({ variantId: 'var_9f2c...', quantity: 3 })
console.log(cart.subtotalCents)
```

---