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

# Add an item to the cart

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

## `POST /cart/lines`

**Add an item to the cart**

Adds `quantity` of a product variant to the caller's cart, creating the cart
on first use. Adding a variant that is already in the cart INCREMENTS that
single line rather than creating a second one, and the resulting quantity is
clamped at the per-line cap instead of being rejected.

The unit price and the product/variant labels are captured SERVER-SIDE from
the catalogue at the moment of the add and are never read from the request; a
later catalogue price change does not re-price an existing line. Totals are
recomputed server-side on every mutation. A variant belonging to another site,
to an unpublished product, or to a bookable product, an unknown variant, and a
variant on a site whose product-variants slice is switched off all return the
same 404.

When this call creates a GUEST cart, the response carries `cartToken` once:
it is the per-cart secret the client must send back in `X-Lynkow-Cart-Token`
on every later guest cart call, and it is never returned again.

Adding to a cart also SELF-HEALS it: any OTHER line whose variant has since
stopped being sellable is auto-removed and reported in `removedLines`, so the
returned total is always over sellable lines only. The just-added variant is
checked for sale first, so it is never the pruned one.

> **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 |
| --- | --- |
| `201` | 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 |


---