Add an item to a cart
POST
/cart/{cartId}/items
Adds a product (optionally a variant) to the cart. The unit price is resolved SERVER-SIDE (THE RULE: the variant's regular/sale pair, else the product pair, with the vendor price rule and any listing override — the same pricer checkout charges with); a client unitPrice is only a fallback for a line the server cannot price, and a line that cannot be priced at all is refused with 422. If the same product+variant already exists, its quantity is incremented and its price refreshed. Returns the updated cart. Soft auth.
Auth: Bearer JWT optional (guest-friendly).
Authorizations
bearerAuth
Jeton client obtenu par POST /auth/login (ou /auth/register), renouvelé par POST /auth/refresh.
Type
HTTP (bearer)
or
Parameters
Header Parameters
x-account-id
Type
string
Path Parameters
cartId*
Type
Requiredstring
Request Body
application/json
JSON "productId": "string", "variantId": "string", "quantity": 1, "unitPrice": 0
{
}
Responses
Updated cart
application/json
JSON "ok": true, "data": { "cartId": "123e4567-e89b-12d3-a456-426614174000", "accountId": "string", "customerId": "string", "sessionId": "string", "currency": "string", "notes": "string", "expiresAt": "2024-01-01T00:00:00Z", "createdAt": "2024-01-01T00:00:00Z", "updatedAt": "2024-01-01T00:00:00Z", "items": [ { "itemId": "string", "productId": "string", "variantId": "string", "quantity": 0, "unitPrice": 0, "addedAt": "2024-01-01T00:00:00Z" } ], "subtotal": 0 }
{
}