Cart endpoint v2

This page describes the v2 cart endpoint, which can be used to interact with your external e-commerce solution’s REST shopping cart service.

In v2, cartId is a path parameter instead of form parameter in the REST calls. For example the v1 /carts/items becomes in v2 /carts/{cartId}/items. The other parts of the call are unchanged.

With this endpoint, you can:

  • Create a cart anonymously or as an authenticated user.

  • Add an item to a cart.

  • Change the quantity of items in a cart.

  • Remove an item from a cart.

Magento is now Adobe Commerce, powered by Magento. In the examples and configuration below, we may refer to Adobe Commerce as Magento.
  • Adobe Commerce

  • commercetools

  • Salesforce Commerce Cloud

  • SAP Commerce Cloud

POST

Post cart as an anonymous or authenticated user

Creates a cart as an anonymous or authenticated user.

If accessToken parameters are provided, a cart for an authenticated user is created. See https://devdocs.magento.com/guides/v2.4/rest/tutorials/orders/order-create-customer.html for information about generating an accessToken.

Request URL

/.rest/ecommerce/v2/carts/

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

accessToken

required for authenticated users

The user’s access token.

header

string

GET

Get a cart by ID

Returns a cart by its ID.

Request URL

/.rest/ecommerce/v2/carts/{cartId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

cartId

required for anonymous users

The Magento quote ID.

path

string

GET

Get a cart by user ID

Returns a cart by user ID.

Request URL

/.rest/ecommerce/v2/carts/user/{userId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

userId

required

The user’s access token.

path

string

accessToken

required

The user’s access token.

header

string

POST

Post an item to cart

Adds an item to a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

productId

required

The Magento SKU of the product.

form

string

cartId

required

The unique ID of the cart.

path

string

quantity

required, default is 1

Quantity of products added to the cart.

form

string

quoteId

required

The Magento quote id.

form

string

accessToken

required for authenticated users

The access token.

header

string

POST

Post the quantity of items

Updates the quantity of items in a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

The ID of an item in a cart.

path

string

cartId

required

The unique ID of the cart.

path

string

quantity

required

New quantity of products in the cart.

form

string

quoteId

required

The Magento quote ID.

form

string

accessToken

required for authenticated users

The access token.

header

string

DELETE

Delete an item from a cart

Removes an item from a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

ID of an item in the cart.

path

string

cartId

required

The unique ID of the cart.

path

string

accessToken

required for authenticated users

The access token.

header

string

POST

Post cart as an anonymous or authenticated user

Creates a cart as an anonymous or authenticated user.

If neither the userId nor accessToken parameters are provided, a cart for an anonymous user is created.

Request URL

/.rest/ecommerce/v2/carts/

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

userId

required

The user ID.

header

string

accessToken

required

The user’s access token.

header

string

anonymousId

required

Identifies the cart belonging to an anonymous user.

header

string

currencyCode

required

A three-digit currency code as per ↗ ISO 4217.

form

string

GET

Get a cart by ID

Returns a cart by its ID.

Request URL

/.rest/ecommerce/v2/carts/{cartId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

cartId

required

The unique ID of the cart.

path

string

GET

Get a cart by user ID

Returns a cart by user ID.

Request URL

/.rest/ecommerce/v2/carts/user

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

userIdEncodingDisabled

optional

Default is false and the userId must be Base64-encoded.

NOTE: When set to true the userId is not encoded and may contain sensitive information. This should not be used in a production environment.

query

string

accessToken

required

The user’s access token.

header

string

POST

Post an item to cart

Adds an item to a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

productId

required

The unique ID of the product.

form

string

cartId

required

The unique ID of the cart.

path

string

quantity

required, default is 1

Quantity of products added to the cart.

form

string

quoteId

required

The quote id.

form

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

accessToken

required

The access token.

header

string

POST

Post the quantity of items

Updates the quantity of items in a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

The ID of an item in a cart.

path

string

cartId

required

The unique ID of the cart.

path

string

quantity

required

New quantity of products in the cart.

form

string

quoteId

required

The quote ID.

form

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

accessToken

required for authenticated users

The access token.

header

string

DELETE

Delete an item from a cart

Removes an item from a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

ID of an item in the cart.

path

string

cartId

required

The unique ID of the cart.

path

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

accessToken

required

The access token.

header

string

Prerequisite token

In the case of Salesforce Commerce, before creating a cart, you must prepare a token from Salesforce Commerce. A guest token is required for anonymous users. For logged in users, a token is also required.

Query example: https://magnolia1-tech-prtnr-eu02-dw.demandware.net/s/RefArchGlobal/dw/shop/v20_3/customers/auth?client_id=0a0dddf0-aaf0-0000-b000-000000c00a0e

In both cases, in the response header, you have an item named Authorization with a value such as Bearer xyzabc, xyzabc is your token (exclude Bearer).

POST

Post cart as an anonymous or authenticated user

Creates a cart as an anonymous or authenticated user.

Request URL

/.rest/ecommerce/v2/carts/

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

accessToken

required

Your Salesforce Commerce token mentioned above. In the response, you have a basket_id value, which is used as the cartId.

header

string

GET

Get a cart by ID

Returns a cart by its ID.

Request URL

/.rest/ecommerce/v2/carts/{cartId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

cartId

required

The Salesforce Commerce basket_id.

path

string

POST

Post an item to cart

Adds an item to a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

productId

required

The ID of the product you want to add to your cart.

form

data

cartId

required

The Salesforce Commerce basket_id.

form

data

quantity

required, default is 1

Quantity of products added to the cart.

form

string

accessToken

required

The Salesforce Commerce token.

header

string

POST

Post the quantity of items

Updates the quantity of items in a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

Product ID of an item in a cart.

path

string

cartId

required

The Salesforce Commerce basket_id.

path

string

quantity

required

New quantity of products in the cart.

form

string

accessToken

required

Your Salesforce Commerce token.

header

string

DELETE

Delete an item from a cart

Removes an item from a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

Product ID of an item in the cart.

path

string

cartId

required

The Salesforce Commerce basket_id.

path

string

accessToken

required

The Salesforce Commerce token.

header

string

POST

Post cart as an anonymous or authenticated user

Creates a cart as an anonymous or authenticated user.

If neither the userId nor userToken parameters are provided, a cart for an anonymous user is created.

Request URL

/.rest/ecommerce/v2/carts/

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

userId

required

The user ID.

header

string

userToken

required

The user’s access token.

header

string

anonymousId

required

Identifies the cart belonging to an anonymous user.

header

string

currencyCode

required

A three-digit currency code as per ISO 4217.

form

string

GET

Get a cart by ID

Returns a cart by its ID.

Request URL

/.rest/ecommerce/v2/carts/{cartId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

cartId

required

The SAP cart identifier.

path

string

GET

Get a cart by user ID

Returns a cart by user ID.

Request URL

/.rest/ecommerce/v2/carts/user

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

userId

required

The userId must be Base64-encoded.

The SAP user identifier.

header

string

userIdEncodingDisabled

optional

Default is false and the userId must be Base64-encoded.

NOTE: When set to true the userId is not encoded and may contain sensitive information. This should not be used in a production environment.

query

string

accessToken

required

The user’s access token.

header

string

POST

Post an item to cart

Adds an item to a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

productId

required

The unique ID of the product.

form

string

cartId

required

The unique ID of the cart.

path

string

quantity

required, default is 1

Quantity of products added to the cart.

form

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

POST

Post the quantity of items

Updates the quantity of items in a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

The SAP entry number of an item in a cart.

Each entry in a cart has an entry number. Cart entries are numbered in ascending order, starting with zero (0).

path

string

cartId

required

The unique ID of the cart.

path

string

quantity

required

New quantity of products in the cart.

form

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

DELETE

Delete an item from a cart

Removes an item from a cart.

Request URL

/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}

Parameters

Parameter Description Type Data Type

definitionName

required

The definition name.

query

string

connectionName

required

The connection name.

query

string

itemId

required

The SAP entry number of an item in a cart.

Each entry in a cart has an entry number. Cart entries are numbered in ascending order, starting with zero (0).

path

string

cartId

required

The unique ID of the cart.

path

string

userId

required

The userId must be Base64-encoded.

The unique ID of the user.

header

string

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the E-commerce module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules