Skip to main content
DELETE
https://api.firmly.work
/
api
/
v2
/
domains
/
{domain}
/
cart
/
line-items
Clear Cart
curl --request DELETE \
  --url https://api.firmly.work/api/v2/domains/{domain}/cart/line-items \
  --header 'Authorization: Bearer <token>'
{
  "cart_id": "cart_01H2XVBR8C8JS5MQSFPJ8HF9SA",
  "platform_id": "shopify",
  "shop_id": "staging.luma.gift",
  "display_name": "Luma Store",
  "cart_status": "active",
  "line_items": [],
  "shipments": [],
  "sub_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "shipping_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "tax_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "addons": {
    "offers": [],
    "selections": []
  },
  "addon_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "shipping_info": {
    "first_name": "John",
    "last_name": "Doe",
    "email": "[email protected]",
    "phone": "555-123-4567",
    "company": "",
    "address_line_1": "123 Main Street",
    "address_line_2": "Apt 4B",
    "city": "Anytown",
    "state_code": "CA",
    "zip": "12345",
    "country_code": "US"
  },
  "payment_method_options": [
    {
      "type": "CreditCard",
      "wallet": "user"
    },
    {
      "type": "PayPal",
      "wallet": "paypal"
    }
  ],
  "coupons": [],
  "schema_version": "2.0"
}

Overview

The Clear Cart endpoint removes all items from the shopping cart while maintaining the session. This operation:
  • Complete Reset: Removes all line items, shipments, and addon selections
  • Session Continuity: Cart ID and authentication remain active
  • Preserved Settings: Maintains shipping info, payment methods, and cart-level preferences
  • Zero Totals: Returns empty cart with all monetary values reset to zero

Authentication

x-firmly-authorization
string
required
Device authentication token to identify and map the session

Path Parameters

domain
string
required
Domain of the merchant website (e.g., staging.luma.gift)

Response

Returns an empty shopping cart. All arrays are empty and monetary values are zero.

What Gets Cleared:

  • Line Items: All products removed from cart
  • Shipments: All shipment groups deleted
  • Addons: All addon selections removed (offers may remain available)
  • Totals: All monetary totals reset to zero
  • Promo Codes: Applied coupons are cleared

What Gets Preserved:

  • Cart ID: Session continues with same cart identifier
  • Shipping Info: Customer address information retained
  • Payment Methods: Available payment options maintained
  • Shipping Options: Available shipping methods preserved
  • Session State: Authentication and device binding remain active

Code Examples

curl --request DELETE \
  --url https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/line-items \
  --header 'x-firmly-authorization: YOUR_TOKEN'
{
  "cart_id": "cart_01H2XVBR8C8JS5MQSFPJ8HF9SA",
  "platform_id": "shopify",
  "shop_id": "staging.luma.gift",
  "display_name": "Luma Store",
  "cart_status": "active",
  "line_items": [],
  "shipments": [],
  "sub_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "shipping_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "tax_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "addons": {
    "offers": [],
    "selections": []
  },
  "addon_total": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  },
  "shipping_info": {
    "first_name": "John",
    "last_name": "Doe",
    "email": "[email protected]",
    "phone": "555-123-4567",
    "company": "",
    "address_line_1": "123 Main Street",
    "address_line_2": "Apt 4B",
    "city": "Anytown",
    "state_code": "CA",
    "zip": "12345",
    "country_code": "US"
  },
  "payment_method_options": [
    {
      "type": "CreditCard",
      "wallet": "user"
    },
    {
      "type": "PayPal",
      "wallet": "paypal"
    }
  ],
  "coupons": [],
  "schema_version": "2.0"
}

Error Responses

Missing or invalid authentication header
{
  "code": 400,
  "error": "MissingAuthHeader",
  "description": "x-firmly-authorization header is missing or invalid"
}
Invalid JWT token
{
  "code": 401,
  "error": "InvalidJWTToken",
  "description": "The JWT token is invalid"
}
Cart not found for the given domain
{
  "code": 404,
  "error": "ErrorCartNotFound",
  "description": "Cart was not found"
}

Use Cases

Start Fresh

Customer wants to completely restart their shopping session:
DELETE /api/v2/domains/staging.luma.gift/cart/line-items
# Returns empty cart, ready for new items

Bulk Item Management

Before adding a new product set, clear existing items:
# Step 1: Clear cart
DELETE /api/v2/domains/staging.luma.gift/cart/line-items

# Step 2: Add new items
POST /api/v2/domains/staging.luma.gift/cart/line-items

Session Reset

After checkout completion or session timeout:
DELETE /api/v2/domains/staging.luma.gift/cart/line-items
# Maintains session but clears all cart data

Implementation Details

The clear cart operation removes all items from the cart while maintaining the session and cart identifier. Depending on the merchant’s platform, this may either:
  • Use a native clear cart operation for optimal performance
  • Remove items individually to ensure compatibility
Both approaches result in the same empty cart state.