curl --location --request POST 'https://api.stateset.com/v1/carts/cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30/clear' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data-raw '{
"preserve_coupons": false,
"reason": "customer_requested"
}'
{
"id": "cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
"object": "cart",
"customer_id": "cust_abc123",
"session_id": "sess_xyz789",
"channel": "web",
"currency": "USD",
"locale": "en-US",
"status": "active",
"items": [],
"item_count": 0,
"unique_item_count": 0,
"subtotal": 0,
"tax_amount": 0,
"shipping_amount": 0,
"discount_amount": 0,
"total": 0,
"shipping_address": {
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"applied_coupons": [],
"applied_promotions": [],
"expires_at": "2024-07-20T10:00:00Z",
"created_at": "2024-06-20T10:00:00Z",
"updated_at": "2024-06-20T17:30:00Z",
"last_activity": "2024-06-20T17:30:00Z",
"cleared_at": "2024-06-20T17:30:00Z",
"metadata": {
"clear_reason": "customer_requested",
"items_cleared": 3
},
"messages": [
{
"type": "info",
"message": "Cart has been cleared"
}
]
}
Clear Cart
Remove all items from a cart
POST
/
v1
/
carts
/
:id
/
clear
curl --location --request POST 'https://api.stateset.com/v1/carts/cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30/clear' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data-raw '{
"preserve_coupons": false,
"reason": "customer_requested"
}'
{
"id": "cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
"object": "cart",
"customer_id": "cust_abc123",
"session_id": "sess_xyz789",
"channel": "web",
"currency": "USD",
"locale": "en-US",
"status": "active",
"items": [],
"item_count": 0,
"unique_item_count": 0,
"subtotal": 0,
"tax_amount": 0,
"shipping_amount": 0,
"discount_amount": 0,
"total": 0,
"shipping_address": {
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"applied_coupons": [],
"applied_promotions": [],
"expires_at": "2024-07-20T10:00:00Z",
"created_at": "2024-06-20T10:00:00Z",
"updated_at": "2024-06-20T17:30:00Z",
"last_activity": "2024-06-20T17:30:00Z",
"cleared_at": "2024-06-20T17:30:00Z",
"metadata": {
"clear_reason": "customer_requested",
"items_cleared": 3
},
"messages": [
{
"type": "info",
"message": "Cart has been cleared"
}
]
}
This endpoint removes all items from a cart while preserving the cart itself, customer information, and applied settings. Useful for “Clear Cart” functionality.
Authentication
This endpoint requires a valid API key withcarts:write permissions.
Authorization: Bearer YOUR_API_KEY
Path Parameters
The unique identifier of the cart to clear
Request Body
Keep applied coupon codes
Reason for clearing the cart (for analytics)
Response
Returns the cleared cart object.curl --location --request POST 'https://api.stateset.com/v1/carts/cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30/clear' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data-raw '{
"preserve_coupons": false,
"reason": "customer_requested"
}'
{
"id": "cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
"object": "cart",
"customer_id": "cust_abc123",
"session_id": "sess_xyz789",
"channel": "web",
"currency": "USD",
"locale": "en-US",
"status": "active",
"items": [],
"item_count": 0,
"unique_item_count": 0,
"subtotal": 0,
"tax_amount": 0,
"shipping_amount": 0,
"discount_amount": 0,
"total": 0,
"shipping_address": {
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"applied_coupons": [],
"applied_promotions": [],
"expires_at": "2024-07-20T10:00:00Z",
"created_at": "2024-06-20T10:00:00Z",
"updated_at": "2024-06-20T17:30:00Z",
"last_activity": "2024-06-20T17:30:00Z",
"cleared_at": "2024-06-20T17:30:00Z",
"metadata": {
"clear_reason": "customer_requested",
"items_cleared": 3
},
"messages": [
{
"type": "info",
"message": "Cart has been cleared"
}
]
}
⌘I