Skip to main content
POST
Update Cart Item

Overview

Updates the quantity of an existing product in the user’s shopping cart. This endpoint uses the cart synchronization mechanism to modify item quantities.

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 all cart items with updated quantities
string
required
The product ID (as a string)
number
required
The new quantity for the product (must be greater than 0)

Cart Item Structure

Each cart item contains:
  • id: Product identifier (string format)
  • quantity: Number of units (positive integer)

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 all cart items with updated quantities
number
Unique identifier for the cart item
number
The product ID for this cart item
number
Updated quantity of the product
object
Complete product details
string
Error message if the request fails

Example Request

Update Single Item Quantity

Update Multiple Items

Example Response

Success Response

Error Response

Error Codes

Important Notes

The sync endpoint replaces ALL cart items. To update an item’s quantity, you must include ALL cart items in the request with their current or updated quantities.
To effectively increase or decrease quantity:
  1. First, fetch the current cart using GET /api/cart/:userId
  2. Modify the quantity of the desired item(s)
  3. Send all items back with the updated quantities

Quantity Updates

  • Quantities must be positive integers (greater than 0)
  • To remove an item, omit it from the items array (see Remove Item documentation)
  • Setting quantity to 0 will not remove the item; you must exclude it from the array
  • The abandonedEmailSent flag is reset to false when quantities are updated
  • Invalid product IDs are automatically filtered out during sync