Skip to content

Create Cart

Create a new shopping cart. A new cart is typically created at the start of a shopping session.

Endpoint

POST /api/shop/cart

Request Headers

HeaderRequiredDescription
Content-TypeYesapplication/json
X-STOREFRONT-KEYYesYour 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)

FieldTypeDescription
idintegerCart ID
itemsarrayItems in cart (empty if newly created)
subtotaldecimalItems subtotal
taxdecimalCalculated tax
shippingCostdecimalShipping cost
totaldecimalGrand total
itemCountintegerTotal items in cart
couponCodestringApplied coupon code (if any)
createdAtstringCart 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

Released under the MIT License.