Skip to navigation

Create Cart

Creates a Cart.

Required Fields

FieldDetails
line_itemSpecifies a line item.
custom_itemsSpecifies a custom item. Only required if adding a custom item to the cart.
gift_certificatesSpecifies a gift certificate. Only required if adding a gift certificate to the cart.

Usage Notes

  • A cart id (UUID) is returned in the response.
  • A cart id is the same as a checkout id.
  • A cart can be created by adding an existing catalog item or a custom item.
  • Images are not supported for custom items. The image_url field is accepted but does not render on the storefront.
  • Carts are valid for 30 days from the last modification (this includes creating the cart or editing the cart).
  • If a product has modifiers, use the option_selections array to describe the modifier selection(s).
  • The format and data type of a cart’s option_value are defined by the value_data object of a product’s variant option value, modifier value, or a combination of both.
  • Redirect URLs can only be generated from carts that were created using the REST Management API.
  • To get cart redirect_urls in the response, append the following query parameter to the request URL: include=redirect_urls. Redirect URLs point to either a shared checkout domain or a channel-specific domain, depending on the storefront configuration.
  • To restore a cart that was created by a shopper or through a Storefront API, first recreate the cart using the REST Management API.
  • To get cart promotions in the response, append the following query parameter to the request URL: include=promotions.banners.

Overridable fields

When creating a cart, you can override the following catalog values on each line item:

FieldDescription
list_priceOverride the product’s price. By default, overriding a product’s list_price makes it ineligible for V3 product-level promotions. In Store Settings under Promotions and Coupons in the control panel, you can change this behavior to allow promotions on overridden prices.
nameOverride the product name. Useful for locale-specific product names.
option_selections.nameOverride the name of an option or modifier selection. Useful for locale-specific option labels.
option_selections.valueOverride the value of an option or modifier selection. Useful for locale-specific option values.

Authentication

X-Auth-Tokenstring

OAuth scopes

UI NamePermissionParameter
Cartsmodifystore_cart
Cartsread-onlystore_cart_read_only
Information & Settingsmodifystore_v2_information
Information & Settingsread-onlystore_v2_information

Authentication header

HeaderArgumentDescription
X-Auth-Tokenaccess_tokenFor more about API accounts that generate access_tokens, see our Guide to API Accounts.

Further reading

For example requests and more information about authenticating BigCommerce APIs, see Authentication and Example Requests.

For more about BigCommerce OAuth scopes, see our Guide to API Accounts.

For a list of API status codes, see API Status Codes.

Path parameters

store_hashstringRequired
Permanent ID of the BigCommerce store.

Headers

AcceptstringRequiredDefaults to application/json

The MIME type of the response body.

Query parameters

includelist of enumsOptional
  • redirect_urls: Create a direct link to a cart. This can be used for the /POST request for carts.
  • line_items.physical_items.options: The cart returns an abbreviated result. Use this to return physical items product options. To return the extended cart object, use in a /POST request.
  • line_items.digital_items.options: The cart returns an abbreviated result. Use this to return digital items product options. To return the extended cart object, use in a /POST request.
  • line_items.physical_items.stock_position: Returns backorder and stock availability details for physical items.
  • line_items.digital_items.stock_position: Returns backorder and stock availability details for digital items. Since digital products cannot be backordered, backorder values are always zero.
  • promotions.banners: Returns a list of eligible banners.

Request

Examples:

  1. Creating a cart by adding a simple product (a product without option selections).
  2. Creating a cart with a variant. This works when a product can be specified purely by a variant, without any other required options.
  3. Creating a cart using a date option. The API supports timestamps, “option_value”: 1743570000, and dates as an object literal, “option_value”: {“day”:”01”, “month”:”02”, “year”:”2020”}.
  4. Creating a cart with a variant, a checkbox, and a picklist modifier added.
  5. Creating a cart using a custom item.
customer_idintegerOptional
line_itemslist of objectsOptional
custom_itemslist of objectsOptional
gift_certificateslist of objectsOptional
channel_idintegerOptional
The Channel ID. If no channel is specified, defaults to 1.
currencyobjectOptional
localestringOptionalformat: "ISO-639"

The locale of the cart. Accepts strings of format xx or xx-YY. Uses the ISO-639 standard format.

Response

The requested cart.
dataobjectOptional

A cart contains a collection of items, prices, discounts, etc. It does not contain customer-related data.

metaobjectOptional
Response metadata.