The Storefront Cart API is part of the Storefront API, which is a GraphQL API. It's used for building buyer experiences, such as custom storefronts, mobile apps, apps that interact with Cart and Storefront and more. You can access the Storefront Cart API at the following endpoint:
> Note:
> To make requests to this API, you'll need to include an `X-Shopify-Storefront-Access-Token`. Refer to our [getting started documentation](/docs/storefronts/headless/building-with-the-storefront-api/getting-started) for guidance on getting set up to make requests.
## Create a Cart
The Storefront Cart API enables you to assemble a buyer's purchase, providing all relevant details back to the buyer before transitioning into the checkout process. This means you can add, remove, or update items in the cart, apply discounts, and more, before you create the checkout. Modifying a cart instead of a checkout provides your application a more feature-rich and performant way of assembly.
### Deprecated: Checkout API's `checkoutCreate`
### New: Storefront Cart API's `cartCreate`
### Deprecated: Checkout API error handling
In the Checkout API, to handle errors you requested `checkoutUserErrors`:
### New: Storefront Cart API error handling
With the Storefront Cart API, you request `userErrors` to receive information about errors that are related to the entire API surface:
## Update a cart
Updating the cart enables you to adjust the line items, discounts, attributes, notes, and more, before finalizing the cart and sending the buyer to checkout. The Storefront Cart API provides the following main methods for updating line items in the cart:
- [`cartLinesUpdate`](/docs/api/storefront/latest/mutations/cartLinesUpdate)
- [`cartLinesAdd`](/docs/api/storefront/latest/mutations/cartLinesAdd)
- [`cartLinesRemove`](/docs/api/storefront/latest/mutations/cartLinesRemove)
The `cartLinesUpdate` mutation behaves similarly to [`checkoutLineItemsReplace`](/docs/api/storefront/latest/mutations/checkoutLineItemsReplace) in the Checkout API. It replaces the existing line items in the cart with the new line items provided in the lines argument. This is useful when you want to completely refresh the cart contents.
### Deprecated: Checkout API's `checkoutLineItemsReplace`
### New: Storefront Cart API's `cartLinesUpdate`
If you want to add new line items to the existing ones in the cart, you should use `cartLinesAdd`. This enables you to build up the cart contents incrementally, without discarding the current lines.
### Deprecated: Checkout API's `checkoutDiscountCodeApplyV2`
With the Checkout API, discount codes aren't stackable:
### New: Storefront Cart API's `cartDiscountCodesUpdate`
The Storefront Cart API supports stackable discount codes. The [`discountCodes`](/docs/api/storefront/2024-04/mutations/cartDiscountCodesUpdate#argument-discountcodes) field in the `cartDiscountCodesUpdate` mutation is an array, which enables you to apply multiple discount codes to the cart:
## Associate a customer
The Storefont Cart API provides a straightforward way to attach both anonymous and authenticated buyer information to the cart using the [`cartBuyerIdentityUpdate`](/docs/api/storefront/latest/mutations/cartBuyerIdentityUpdate) mutation. The following examples compare updating a shipping address using the Checkout API and the Storefront Cart API.
### Deprecated: Checkout API's `checkoutShippingAddressUpdateV2`
### New: Storefront Cart API's `cartBuyerIdentityUpdate` and `cartDeliveryAddressesAdd` mutations
The Storefront Cart API enables you to update the buyer's identity and preferences using the [`cartBuyerIdentityUpdate`](/docs/api/storefront/latest/mutations/cartBuyerIdentityUpdate) mutation. As of `2025-01`, delivery addresses can be managed using the new cart delivery mutations:
- [`cartDeliveryAddressesAdd`](/docs/api/storefront/latest/mutations/cartDeliveryAddressesAdd)
- [`cartDeliveryAddressesUpdate`](/docs/api/storefront/latest/mutations/cartDeliveryAddressesUpdate)
- [`cartDeliveryAddressesRemove`](/docs/api/storefront/latest/mutations/cartDeliveryAddressesRemove)
> Note:
> If addresses are provided, they will be prefilled at checkout if the shop is using [Checkout Extensibility](/docs/apps/build/checkout).
You can retrieve the access token using either the [`customerAccessTokenCreate`](/docs/api/storefront/2024-04/mutations/customerAccessTokenCreate) or [`customerAccessTokenCreateWithMultipass`](/docs/api/storefront/latest/mutations/customerAccessTokenCreateWithMultipass) mutations.
### Deprecated: Checkout API's `checkoutCustomerAssociateV2`
### New: Storefront Cart API's `cartBuyerIdentityUpdate`
## Complete the checkout
In the Checkout API, you complete the checkout by retrieving the checkout web URL from the `Checkout` object's [`webUrl`](/docs/api/storefront/latest/objects/Checkout#field-checkout-weburl) field. In the Storefront Cart API, you can retrieve the [`checkoutUrl`](/docs/api/storefront/2024-01/objects/Cart#field-cart-checkouturl) from the `Cart` object at any point in the flow to send the buyer to the Shopify web checkout.
### Deprecated: Checkout API's `webURL`
### New: Storefront Cart API's checkoutURL
## Next steps