Create Cart
Create a new shopping cart. A new cart is typically created at the start of a shopping session.
Endpoint
POST /api/shop/cartRequest Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | application/json |
X-STOREFRONT-KEY | Yes | Your storefront API key |
Request Body
Optional. Can be empty {} or include initial items:
json
{
"items": [
{
"productId": 1,
"quantity": 2,
"attributes": {
"color": "Black"
}
}
]
}Response Fields (201 Created)
| Field | Type | Description |
|---|---|---|
id | integer | Cart ID |
items | array | Items in cart (empty if newly created) |
subtotal | decimal | Items subtotal |
tax | decimal | Calculated tax |
shippingCost | decimal | Shipping cost |
total | decimal | Grand total |
itemCount | integer | Total items in cart |
couponCode | string | Applied coupon code (if any) |
createdAt | string | Cart creation timestamp |
Use Cases
- Create cart at start of shopping session
- Initialize empty cart for customer
- Set up cart for guest checkout
- Prepare cart for adding items
Notes
- Cart is typically created once per session
- Multiple carts can exist (for different users)
- Empty carts can expire after inactivity
- Cart ID is needed for subsequent operations

