Migrate your app
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:
To make requests to this API, you'll need to include an X-Shopify-Storefront-Access-Token
. Refer to our getting started documentation for guidance on getting set up to make requests.
Anchor to Create a CartCreate 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.
Anchor to Deprecated: Checkout API's ,[object Object]Deprecated: Checkout API's checkoutCreate
checkoutCreate
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Checkout API
Input
Anchor to New: Storefront Cart API's ,[object Object]New: Storefront Cart API's cartCreate
cartCreate
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Storefront Cart API
Input
Anchor to Deprecated: Checkout API error handlingDeprecated: Checkout API error handling
In the Checkout API, to handle errors you requested checkoutUserErrors
:
Errors
Anchor to New: Storefront Cart API error handlingNew: 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:
Errors
Anchor to Update a cartUpdate 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:
The cartLinesUpdate
mutation behaves similarly to 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.
Anchor to Deprecated: Checkout API's ,[object Object]Deprecated: Checkout API's checkoutLineItemsReplace
checkoutLineItemsReplace
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Checkout API
Input
Anchor to New: Storefront Cart API's ,[object Object]New: Storefront Cart API's cartLinesUpdate
cartLinesUpdate
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Storefront Cart API
Input
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.
Anchor to Deprecated: Checkout API's ,[object Object]Deprecated: Checkout API's checkoutDiscountCodeApplyV2
checkoutDiscountCodeApplyV2
With the Checkout API, discount codes aren't stackable:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Checkout API
Input
Anchor to New: Storefront Cart API's ,[object Object]New: Storefront Cart API's cartDiscountCodesUpdate
cartDiscountCodesUpdate
The Storefront Cart API supports stackable discount codes. The discountCodes
field in the cartDiscountCodesUpdate
mutation is an array, which enables you to apply multiple discount codes to the cart:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Storefront Cart API
Input
Anchor to Associate a customerAssociate a customer
The Storefont Cart API provides a straightforward way to attach both anonymous and authenticated buyer information to the cart using the cartBuyerIdentityUpdate
mutation. The following examples compare updating a shipping address using the Checkout API and the Storefront Cart API.
Anchor to Deprecated: Checkout API's ,[object Object]Deprecated: Checkout API's checkoutShippingAddressUpdateV2
checkoutShippingAddressUpdateV2
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Checkout API
Input
Anchor to New: Storefront Cart API's ,[object Object], and ,[object Object], mutationsNew: Storefront Cart API's cartBuyerIdentityUpdate
and cartDeliveryAddressesAdd
mutations
cartBuyerIdentityUpdate
and cartDeliveryAddressesAdd
mutationsThe Storefront Cart API enables you to update the buyer's identity and preferences using the cartBuyerIdentityUpdate
mutation. As of 2025-01
, delivery addresses can be managed using the new cart delivery mutations:
If addresses are provided, they will be prefilled at checkout if the shop is using Shopify Extensions in Checkout.
You can retrieve the access token using either the customerAccessTokenCreate
or customerAccessTokenCreateWithMultipass
mutations.
Anchor to Deprecated: Checkout API's ,[object Object]Deprecated: Checkout API's checkoutCustomerAssociateV2
checkoutCustomerAssociateV2
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Checkout API
Input
Anchor to New: Storefront Cart API's ,[object Object]New: Storefront Cart API's cartBuyerIdentityUpdate
cartBuyerIdentityUpdate
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Storefront Cart API
Input
Anchor to Complete the checkoutComplete the checkout
In the Checkout API, you complete the checkout by retrieving the checkout web URL from the Checkout
object's webUrl
field. In the Storefront Cart API, you can retrieve the checkoutUrl
from the Cart
object at any point in the flow to send the buyer to the Shopify web checkout.
Anchor to Deprecated: Checkout API's ,[object Object]Deprecated: Checkout API's webURL
webURL
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Anchor to New: Storefront Cart API's checkoutURLNew: Storefront Cart API's checkout URL
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
Anchor to Next stepsNext steps
Learn more about building with the Storefront Cart API, and how you can extend a cart's functionality.
Consult the Storefront API reference documentation to learn more about the Cart object.