Skip to main content
POST
Remove Item from Cart

Overview

Removes a product from the user’s shopping cart. This endpoint uses the cart synchronization mechanism - to remove an item, simply exclude it from the items array.

Authentication

This endpoint requires authentication. Ensure the user is authorized to modify the cart.

Request Body

number
required
The unique identifier of the user whose cart you want to modify
array
required
Array of cart items to keep. Exclude the item(s) you want to remove.
string
required
The product ID (as a string)
number
required
The quantity of the product

Response

boolean
required
Indicates whether the request was successful
object
The complete updated cart object
number
Unique identifier for the cart
number
The ID of the user who owns this cart
array
Array of remaining cart items (after removal)
number
Unique identifier for the cart item
number
The product ID for this cart item
number
Quantity of the product
object
Complete product details
string
Error message if the request fails

Example Request

Remove Single Item

If the cart currently has items with IDs “789” and “456”, and you want to remove item “456”:

Remove Multiple Items

To remove multiple items, simply exclude them from the array:

Clear Entire Cart

To remove all items from the cart, send an empty items array:

Example Response

Success Response

Empty Cart Response

Error Response

Error Codes

Important Notes

The sync endpoint replaces ALL cart items. To remove an item, send a request with all items you want to KEEP, excluding the one(s) you want to remove.
Removal workflow:
  1. Fetch the current cart using GET /api/cart/:userId
  2. Filter out the item(s) you want to remove from the items array
  3. Send the remaining items back to the sync endpoint

Removal Strategies

Remove by exclusion: The recommended approach is to exclude items you want to remove from the items array Clear cart: Send an empty items array to remove all items at once Validation: Only valid, non-deleted products are kept in the cart. Invalid product IDs are automatically filtered out Side effects: The abandonedEmailSent flag is reset to false when cart contents change