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. |
POST
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 |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required for authenticated users The user’s access token. |
|
|
GET
Returns a cart by its ID.
Request URL
/.rest/ecommerce/v2/carts/{cartId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required for anonymous users The Magento quote ID. |
|
|
GET
Returns a cart by user ID.
Request URL
/.rest/ecommerce/v2/carts/user/{userId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The user’s access token. |
|
|
|
required The user’s access token. |
|
|
POST
Adds an item to a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The Magento SKU of the product. |
|
|
|
required The unique ID of the cart. |
|
|
|
required, default is 1 Quantity of products added to the cart. |
|
|
|
required The Magento quote id. |
|
|
|
required for authenticated users The access token. |
|
|
POST
Updates the quantity of items in a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The ID of an item in a cart. |
|
|
|
required The unique ID of the cart. |
|
|
|
required New quantity of products in the cart. |
|
|
|
required The Magento quote ID. |
|
|
|
required for authenticated users The access token. |
|
|
DELETE
Removes an item from a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required ID of an item in the cart. |
|
|
|
required The unique ID of the cart. |
|
|
|
required for authenticated users The access token. |
|
|
POST
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 |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The user ID. |
|
|
|
required The user’s access token. |
|
|
|
required Identifies the cart belonging to an anonymous user. |
|
|
|
required A three-digit currency code as per ↗ ISO 4217. |
|
|
GET
Returns a cart by its ID.
Request URL
/.rest/ecommerce/v2/carts/{cartId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The unique ID of the cart. |
|
|
GET
Returns a cart by user ID.
Request URL
/.rest/ecommerce/v2/carts/user
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The The unique ID of the user. |
|
|
|
optional Default is NOTE: When set to |
|
|
|
required The user’s access token. |
|
|
POST
Adds an item to a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The unique ID of the product. |
|
|
|
required The unique ID of the cart. |
|
|
|
required, default is 1 Quantity of products added to the cart. |
|
|
|
required The quote id. |
|
|
|
required The The unique ID of the user. |
|
|
|
required The access token. |
|
|
POST
Updates the quantity of items in a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The ID of an item in a cart. |
|
|
|
required The unique ID of the cart. |
|
|
|
required New quantity of products in the cart. |
|
|
|
required The quote ID. |
|
|
|
required The The unique ID of the user. |
|
|
|
required for authenticated users The access token. |
|
|
DELETE
Removes an item from a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required ID of an item in the cart. |
|
|
|
required The unique ID of the cart. |
|
|
|
required The The unique ID of the user. |
|
|
|
required The access 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.
-
To obtain a guest token, you must have a Salesforce Commerce API
client_id
to use in the query parameters. -
To obtain a logged-in user token, you must have a Salesforce Commerce API
client_id
to use in the query parameters and pass valid user credentials as HTTP Basic in base 64 in the formusername:password
.
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
Creates a cart as an anonymous or authenticated user.
Request URL
/.rest/ecommerce/v2/carts/
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required Your Salesforce Commerce token mentioned above. In the response, you have a |
|
|
GET
Returns a cart by its ID.
Request URL
/.rest/ecommerce/v2/carts/{cartId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The Salesforce Commerce |
|
|
POST
Adds an item to a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The ID of the product you want to add to your cart. |
|
|
|
required The Salesforce Commerce |
|
|
|
required, default is 1 Quantity of products added to the cart. |
|
|
|
required The Salesforce Commerce token. |
|
|
POST
Updates the quantity of items in a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required Product ID of an item in a cart. |
|
|
|
required The Salesforce Commerce |
|
|
|
required New quantity of products in the cart. |
|
|
|
required Your Salesforce Commerce token. |
|
|
DELETE
Removes an item from a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required Product ID of an item in the cart. |
|
|
|
required The Salesforce Commerce |
|
|
|
required The Salesforce Commerce token. |
|
|
POST
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 |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The user ID. |
|
|
|
required The user’s access token. |
|
|
|
required Identifies the cart belonging to an anonymous user. |
|
|
|
required A three-digit currency code as per ISO 4217. |
|
|
GET
Returns a cart by its ID.
Request URL
/.rest/ecommerce/v2/carts/{cartId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The SAP cart identifier. |
|
|
GET
Returns a cart by user ID.
Request URL
/.rest/ecommerce/v2/carts/user
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The The SAP user identifier. |
|
|
|
optional Default is NOTE: When set to |
|
|
|
required The user’s access token. |
|
|
POST
Adds an item to a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
required The unique ID of the product. |
|
|
|
required The unique ID of the cart. |
|
|
|
required, default is 1 Quantity of products added to the cart. |
|
|
|
required The The unique ID of the user. |
|
|
POST
Updates the quantity of items in a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
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). |
|
|
|
required The unique ID of the cart. |
|
|
|
required New quantity of products in the cart. |
|
|
|
required The The unique ID of the user. |
|
|
DELETE
Removes an item from a cart.
Request URL
/.rest/ecommerce/v2/carts/{cartId}/items/{itemId}
Parameters
Parameter | Description | Type | Data Type |
---|---|---|---|
|
required The definition name. |
|
|
|
required The connection name. |
|
|
|
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). |
|
|
|
required The unique ID of the cart. |
|
|
|
required The The unique ID of the user. |
|
|