# Add / update cart items (idempotent)

`PUT /api/v1/carts/{account}/lines` — Token required · cart:write · write · 2 pts

Carts

## Path parameters

| Name | Type | Description |
| --- | --- | --- |
| `account` **required** | string | Cart owner account (the OMS site login, e.g. 100470admin). (max length 64) |

## Request body (JSON)

| Field | Type | Description |
| --- | --- | --- |
| `lines` **required** | array<object> | Line array, each { sku, quantity }. At least one; quantity=0 removes the line when adjusting a reservation. (1–500) |
| `lines[].sku` **required** | string | SKU / barcode — the **colour + size** level, e.g. OB0021611. For the whole style use product_code instead. (max length 64) |
| `lines[].quantity` **required** | integer | Quantity, a positive integer, e.g. 2. In reservation adjustments / carts, 0 removes the line. (0–99999) |

## Response

The envelope is decided by the HTTP status alone: 2xx with `{ data: … }` (lists also carry `page / page_size / has_more` or `total_count`); 4xx / 5xx with `{ error: { code, message, hint, request_id, doc_url } }`.

```json
{
  "data": { … }
}
```

A success response carries no human-readable text — no `code / result / msg`. `error.code` is the only field your code should branch on; `message` follows `Accept-Language`.

> Send an `Idempotency-Key` header (any unique string, e.g. a UUID) on writes: a network retry never creates a second order. Orders are drafts by default until a person confirms them in the ERP.

## Examples

### curl

```bash
curl -X PUT "https://connect.everugg.net.au/api/v1/carts/{account}/lines" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <uuid>" \
  -d '{ "lines": [ { "sku": "OB0021611", "quantity": 2 } ] }'
```

### Python

```python
import requests

r = requests.put(
    "https://connect.everugg.net.au/api/v1/carts/{account}/lines",
    headers={"Authorization": "Bearer " + TOKEN, "Idempotency-Key": str(uuid.uuid4())},
    json={
      "lines": [
        {
          "sku": "OB0021611",
          "quantity": 2
        }
      ]
    },
)
data = r.json()
r.raise_for_status()  # 4xx/5xx: data["error"]["code"] / ["hint"]
```

### Node

```js
const res = await fetch("https://connect.everugg.net.au/api/v1/carts/{account}/lines", {
  method: "PUT",
  headers: { Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({
    "lines": [
      {
        "sku": "OB0021611",
        "quantity": 2
      }
    ]
  }),
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.error?.code}: ${data.error?.message}`)
```

### Java

```java
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://connect.everugg.net.au/api/v1/carts/{account}/lines"))
    .header("Authorization", "Bearer " + token)
    .header("Content-Type", "application/json")
    .header("Idempotency-Key", UUID.randomUUID().toString())
    .PUT(HttpRequest.BodyPublishers.ofString("{ \"lines\": [ { \"sku\": \"OB0021611\", \"quantity\": 2 } ] }"))
    .build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
```

---
Markdown source: https://connect.everugg.net.au/reference/put-api-v1-carts-account-lines.md?lang=en · Web page: https://connect.everugg.net.au/reference?op=put-api-v1-carts-account-lines&lang=en
