Skip to content

Create Cart

About

The createCart mutation creates a new shopping cart session. Use this mutation to:

  • Initialize a new shopping cart for checkout flows
  • Generate a unique cart token for session tracking
  • Start the shopping and checkout process
  • Create guest carts without customer authentication
  • Reset or recover abandoned carts
  • Manage multiple concurrent cart sessions

This mutation returns a unique cart token that identifies the cart session. This token must be used in subsequent cart operations (add items, update, checkout).

Note: This mutation is primarily intended for guest (non-logged-in) users. It generates a sessionToken that must be passed as the Authorization header in all subsequent cart operations (e.g. add to cart, get cart). Authenticated customers already have a cart session tied to their account, so they do not need to call this mutation.

Authentication

This query requires a valid customer authentication token in the Authorization header. Use the Customer Login API to retrieve the token.

For guest users, no authentication is required. The mutation returns a unique cart token that must be used as the Authorization header in subsequent cart operations.

Authorization: Bearer <accessToken>

Possible Returns

FieldTypeDescription
cartTokenString!Unique cart session token. Use this in all subsequent cart operations.
idString!Unique cart identifier.
messageString!Success or error message.
successBoolean!Indicates if cart creation was successful.
isGuestBoolean!Indicates whether the cart is for a guest user (true) or an authenticated customer (false).
formattedGrandTotalStringCurrent cart grand total with currency symbol.
errors[ErrorMessage!]Array of validation or processing errors if applicable.

Released under the MIT License.