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

# Set an item quantity

**Publié le** : 2026-08-19
**Catégorie** : Commerce

## `PATCH /cart/lines`

**Set an item quantity**

Sets the ABSOLUTE quantity (1 or more) of one variant's line in the caller's
cart and recomputes the totals. Removing an item is the DELETE route, not
quantity zero. The captured unit price is untouched: this changes how many,
never at what price.

The cart SELF-HEALS first (Phase 5): a line whose variant has stopped being
sellable is auto-removed before the update applies. When the pruned row still
carries the requested variant id (for example, its product was unpublished),
PATCH returns the healed cart with `removedLines`, not a bare 404. A hard-deleted
row cannot do so: `ON DELETE SET NULL` erased that correlation before this request,
so the heal and total recompute persist but PATCH returns the uniform 404 with no
report body. A variant NEVER in the cart, having no cart, and raising a quantity
while the site's product-variants surface is switched off all return that identical
404: the line routes never become a probe for whether a cart token resolves.

> **Note:** This endpoint requires the e-commerce feature to be enabled on your site.

### Request Body

Content-Type: `application/json`

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


### 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 |


---