Skip to main content
POST
Add, update, or remove a cart item

Authorizations

Authorization
string
header
required

Access token

Path Parameters

id
string
required

cart id

Required string length: 1 - 128
Pattern: ^[A-Za-z0-9_-]{1,128}$

Body

application/json

Identify a line by SKU or by product and optional variant. A non-null variant requires product_id and cannot be combined with SKU. Use quantity 0 to remove it.

quantity
integer
required

The quantity of the product to add to or update in the cart. Use 0 to remove the item from the cart.

Required range: x >= 0
Example:

1

sku
string
required
Minimum string length: 1
Pattern: \S
product_id
string

The ID of the product to update in the cart.

Minimum string length: 1
Pattern: \S
Example:

"01H9XYZ12345ABCDE"

variant_id
null

Omit or send null when identifying the line by SKU.

on_subscription
boolean
subscription_plan
string | null
Minimum string length: 1
Pattern: \S

Response

OK

message
string
required
success
boolean
required
content
object
required
events
(CartLifecycleEvent · object | CartLineChangeEvent · object | CartCouponEvent · object | OrderCreatedEvent · object | OrderCancelledEvent · object | WishlistChangeEvent · object)[]
required

Analytics events to emit for the change this request made, each with a server-issued event_id. Replay them to your analytics destinations so your client-side and server-side copies of the same action dedupe. Empty when the request produced no analytics event.

Emitted when a cart is created or deleted, or when checkout begins. Checkout Started is sent each time an address is set on the cart, even an unchanged one, matching Commerce Engine's own server-side copy.