Remove Cart Item
Remove one line from the cart, or several in a single call.
Endpoints
| Purpose | Method & Path | Body field |
|---|---|---|
| Remove one line | POST /api/shop/remove-cart-item | cartItemId (integer) |
| Remove several lines | POST /api/shop/remove-cart-items | itemIds (array of integers) |
The two endpoints use different body field names — cartItemId on the singular route, itemIds on the plural one. Sending the wrong one is read as a missing value and rejected with 400.
Request Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | application/json |
X-STOREFRONT-KEY | Yes | Your storefront API key |
Authorization | Yes | The cart's own token as a Bearer token, or a logged-in customer's token. |
Request Body
json
{
"cartItemId": 369
}| Field | Type | Required | Description |
|---|---|---|---|
cartItemId | integer | Yes | The cart line id, from items[].id on the cart payload — not the product id. |
For the bulk route:
json
{
"itemIds": [370, 371]
}| Field | Type | Required | Description |
|---|---|---|---|
itemIds | array | Yes | Cart line ids. An empty array is rejected. |
Response
201 Created carrying the whole recalculated cart — the same object Get Cart returns, plus success and message.
| Field | Type | Description |
|---|---|---|
success | boolean | true when the line or lines were removed. |
message | string | Item removed from cart successfully, or the plural form on the bulk route. |
items | array | The remaining lines. Empty once the last one is gone. |
grandTotal and the other totals | number | Recalculated after the removal. |
Removing the last line leaves an empty cart rather than deleting it — the same cartToken keeps working, so the shopper can carry on adding.
Use Cases
- "Remove" on a cart line — post the line id and re-render from the returned cart; no follow-up fetch is needed.
- "Clear cart" — collect every
items[].idand send them to the bulk route in one call instead of looping the singular one. - Remove out-of-stock lines before checkout — the bulk route takes exactly the ids a stock check flagged.
Best Practices
- Send the cart line id, not the product id — they differ, and a product id usually matches no line, so nothing is removed.
- Match the field name to the route —
cartItemIdsingular,itemIdsplural; mixing them produces a400that reads as a missing field. - Re-render from the response — it is the full recalculated cart, including totals and any coupon still applied.
- Do not recreate the cart after removing everything — the token stays valid on an empty cart.
Related Resources
- Get Cart — read the current items and recalculated totals
- Add to Cart — add a product of any type to the cart
- Update Cart Item — change a line's quantity

