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

# Add an item to the cart

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

## `POST /cart/lines`

**Add an item to the cart**

Adds `quantity` of a product variant to the caller's cart. The first add creates the
cart, with `locale` as its language; later adds ignore `locale`. A variant already in
the cart has its quantity increased, up to 999.

A guest's first add returns `cartToken` once: send it in `X-Lynkow-Cart-Token` on
later guest calls.

The add also removes the lines that can no longer be sold and reports them in
`removedLines`.

Errors: 422 `OUT_OF_STOCK` past the stock on a site that refuses overselling, 422
`CART_LINES_LIMIT_REACHED` on a full cart, 404 `CART_NOT_FOUND` for a variant not for
sale.

> **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 |
| `locale` | string | No | BCP 47 locale code (e.g. "en", "fr") |


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


### SDK

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

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

const cart = await lynkow.cart.addLine({ variantId: 'var_9f2c...', quantity: 2 })
if (cart.cartToken) sessionStorage.setItem('lynkow_cart', cart.cartToken)
```

---