Skip to main content
POST
Add Item to Cart

Overview

Adds a new product to the user’s shopping cart. This endpoint uses the cart synchronization mechanism to add items while preserving existing cart contents.

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 sync. To add a new item, include all existing items plus the new one.
string
required
The product ID to add to the cart (as a string)
number
required
The quantity of the product to add (must be greater than 0)

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 including the newly added item
number
Unique identifier for the cart item
number
The product ID for this cart item
number
Quantity of the product in the cart
object
Complete product details
string
Error message if the request fails

Example Request

Adding First Item

Adding Item to Existing Cart

Example Response

Success Response

Error Response

Error Codes

Important Notes

The sync endpoint replaces ALL cart items. To add a new item, you must include all existing items in the request along with the new item.
  • Product IDs must be valid and reference non-deleted products
  • Invalid product IDs are automatically filtered out
  • The abandonedEmailSent flag is reset to false when items are added
  • If an empty items array is provided, the cart will be cleared
  • Product ID should be sent as a string in the request body