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.
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
checkoutCreatePOST 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
cartCreatePOST 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
checkoutLineItemsReplacePOST 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
cartLinesUpdatePOST 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
checkoutDiscountCodeApplyV2With 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
cartDiscountCodesUpdateThe 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
checkoutShippingAddressUpdateV2POST 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.
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
checkoutCustomerAssociateV2POST 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
cartBuyerIdentityUpdatePOST 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