This is the early access documentation preview for Custom Views. This documentation might not be in sync with our official documentation.
My Carts
The My Carts API creates and provides access to Carts scoped to a specific Customer. The endpoints require an access token from the password flow or anonymous session flow.
The My Carts API intentionally provides write access only to a limited subset of the fields on a Cart. This provides extra security in scenarios when a mobile or browser application communicates directly with the Composable Commerce API on behalf of a customer. For example, the mobile application can not set external line item prices. If you need to modify a protected field available on the full Cart resource, do it from a trusted, server-side application. Use an API Extension to make the modification during the API call.
Custom Line Items and custom Tax Rates cannot be set via this API.
Representations
Find below the representations for the request payloads that are specific for My Carts, the response representations are equal to the ones for the general Carts documented there.
MyCartDraft
The customerId
is determined by a password flow token and
automatically set on the resulting Cart.
The anonymousId
is determined by a token for an anonymous session and
automatically set on the resulting Cart.
currency | Currency the Cart uses. Pattern:^[A-Z]{3}$ |
customerEmail String | Email address of the Customer the Cart belongs to. |
businessUnit | ResourceIdentifier to the Business Unit the Cart should belong to. The Customer must be an Associate of the Business Unit. |
store | ResourceIdentifier to the Store the Cart should belong to. Once set, it cannot be updated. |
lineItems Array of MyLineItemDraft | Line Items to add to the Cart. |
taxMode | Determines how Tax Rates are set. The Platform |
inventoryMode | Determines how stock quantities are tracked for Line Items in the Cart. Default:None |
billingAddress | Billing address associated with the Cart. |
shippingAddress | Shipping address associated with the Cart. Determines eligible ShippingMethod rates and Tax Rates of Line Items. |
shippingMethod | Shipping Method for the Cart. If the referenced ShippingMethod has a |
itemShippingAddresses Array of BaseAddress | Multiple shipping addresses of the Cart. Each address must contain a Eligible Shipping Methods or applicable Tax Rates are determined by the Cart |
shippingMode |
Single |
discountCodes Array of String |
|
country | Used for LineItem Price selection.
If used for Create Cart in Store, the provided country must be one of the Store's ^[A-Z]{2}$ |
locale | Languages of the Cart. Can only contain languages supported by the Project. |
deleteDaysAfterLastModification Int | Number of days after which a Cart with Create a ChangeSubscription for Carts to receive a ResourceDeletedDeliveryPayload upon deletion of the Cart. |
custom | Custom Fields for the Cart. |
MyLineItemDraft
For Product Variant identification, either the productId
and variantId
, or sku
must be provided.
key String | User-defined unique identifier of the LineItem. MinLength:2 MaxLength: 256 Pattern: ^[a-zA-Z0-9_-] |
productId String |
|
variantId Int |
|
sku String |
|
quantity Int | Number of Product Variants to add to the Cart. Default:1 |
addedAt | Date and time (UTC) the Product Variant is added to the Cart. If not set, it defaults to the current date and time. Optional for backwards compatibility reasons. |
supplyChannel | Used to identify Inventory entries that must be reserved.
The Channel must have the |
distributionChannel | Used to select a Product Price.
The Channel must have the If the Cart is bound to a Store with |
shippingDetails | Container for Line Item-specific addresses. |
custom | Custom Fields for the Cart. |
ReplicaMyCartDraft
Get Cart
Get Cart
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/me/carts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Get Cart in Store
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
id String |
|
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Get active Cart
Retrieves the Customer's most recently modified active Cart.
Carts with Merchant
or Quote
CartOrigin are ignored.
If no active Cart exists, this method returns a ResourceNotFound error.
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/me/active-cart -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Get active Cart in Store
Retrieves the Customer's most recently modified active Cart in the Store specified by the storeKey
path parameter.
Carts with Merchant
or Quote
CartOrigin are ignored.
If no active Cart exists, this method returns a ResourceNotFound error.
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/active-cart -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Query Carts
Query Carts
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
where | The parameter can be passed multiple times. |
/^var[.][a-zA-Z0-9]+$/ Any string parameter matching this regular expression | Predicate parameter values. The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limit Int | Number of results requested. |
offset Int | Number of elements skipped. |
withTotal Boolean | Controls the calculation of the total number of query results. Set to |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/me/carts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit": 20,"offset": 0,"count": 2,"total": 2,"results": [{"type": "Cart","id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc","version": 5,"createdAt": "2015-09-22T15:36:17.510Z","lastModifiedAt": "2015-09-22T15:41:55.816Z","lineItems": [{"id": "b925a817-d5ad-48bb-a407-29ad8e0649b5","productId": "9f10dcfb-5cc9-4a18-843a-c07f7e22d01f","name": {"en": "SAPPHIRE"},"productType": {"typeId": "product-type","id": "2543e1d8-4915-4f72-a3c9-1df9b1b0082d","version": 8},"productSlug": {"en": "sapphire1421832124423"},"variant": {"id": 1,"sku": "sku_SAPPHIRE_variant1_1421832124423","prices": [{"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 2800},"id": "8da659ef-9e54-447d-9c36-84912db1848f"}],"images": [{"url": "https://www.commercetools.com/cli/data/252542005_1.jpg","dimensions": {"w": 1400,"h": 1400}}],"attributes": [],"assets": []},"price": {"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 2800},"id": "8da659ef-9e54-447d-9c36-84912db1848f"},"quantity": 2,"discountedPricePerQuantity": [],"state": [{"quantity": 2,"state": {"typeId": "state","id": "7c2e2694-aefe-43d7-888e-6a99514caaca"}}],"priceMode": "Platform","lineItemMode": "Standard","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 5600},"perMethodTaxRate": [],"taxedPricePortions": []}],"cartState": "Active","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 5600},"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": [],"shipping": [],"shippingMode": "Single"},{"type": "Cart","id": "668e5783-73c8-4f2d-91f4-3c90b872c700","version": 3,"createdAt": "2015-10-07T07:33:05.894Z","lastModifiedAt": "2015-10-07T07:33:06.070Z","lineItems": [{"id": "90dff06c-272e-47fa-b8de-923dce092474","productId": "7b1203f4-66c0-438c-9a30-f4fb6be79bdf","name": {"de": "WB ATHLETIC PANZER","en": "WB ATHLETIC TANK"},"productType": {"typeId": "product-type","id": "2543e1d8-4915-4f72-a3c9-1df9b1b0082d","version": 8},"productSlug": {"en": "wb-athletic-tank1421832124574"},"variant": {"id": 1,"sku": "sku_WB_ATHLETIC_TANK_variant1_1421832124574","prices": [{"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"id": "37696f7c-8260-4941-a921-68e6aa76b4a3"}],"images": [{"url": "https://www.commercetools.com/cli/data/253265444_1.jpg","dimensions": {"w": 1400,"h": 1400}}],"attributes": [],"assets": []},"price": {"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"id": "37696f7c-8260-4941-a921-68e6aa76b4a3"},"quantity": 1,"discountedPricePerQuantity": [],"state": [{"quantity": 1,"state": {"typeId": "state","id": "7c2e2694-aefe-43d7-888e-6a99514caaca"}}],"priceMode": "Platform","lineItemMode": "Standard","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"custom": {"type": {"typeId": "type","id": "3ae9bcca-df23-443e-bd22-0c592f9694fa"},"fields": {"offer_name": "SuperMax"}},"perMethodTaxRate": [],"taxedPricePortions": []}],"cartState": "Active","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"country": "DE","customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": [],"shipping": [],"shippingMode": "Single"}]}
Query Carts in Store
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
where | The parameter can be passed multiple times. |
/^var[.][a-zA-Z0-9]+$/ Any string parameter matching this regular expression | Predicate parameter values. The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limit Int | Number of results requested. |
offset Int | Number of elements skipped. |
withTotal Boolean | Controls the calculation of the total number of query results. Set to |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit": 20,"offset": 0,"count": 2,"total": 2,"results": [{"type": "Cart","id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc","version": 5,"createdAt": "2015-09-22T15:36:17.510Z","lastModifiedAt": "2015-09-22T15:41:55.816Z","lineItems": [{"id": "b925a817-d5ad-48bb-a407-29ad8e0649b5","productId": "9f10dcfb-5cc9-4a18-843a-c07f7e22d01f","name": {"en": "SAPPHIRE"},"productType": {"typeId": "product-type","id": "2543e1d8-4915-4f72-a3c9-1df9b1b0082d","version": 8},"productSlug": {"en": "sapphire1421832124423"},"variant": {"id": 1,"sku": "sku_SAPPHIRE_variant1_1421832124423","prices": [{"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 2800},"id": "8da659ef-9e54-447d-9c36-84912db1848f"}],"images": [{"url": "https://www.commercetools.com/cli/data/252542005_1.jpg","dimensions": {"w": 1400,"h": 1400}}],"attributes": [],"assets": []},"price": {"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 2800},"id": "8da659ef-9e54-447d-9c36-84912db1848f"},"quantity": 2,"discountedPricePerQuantity": [],"state": [{"quantity": 2,"state": {"typeId": "state","id": "7c2e2694-aefe-43d7-888e-6a99514caaca"}}],"priceMode": "Platform","lineItemMode": "Standard","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 5600},"perMethodTaxRate": [],"taxedPricePortions": []}],"cartState": "Active","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 5600},"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": [],"shipping": [],"shippingMode": "Single"},{"type": "Cart","id": "668e5783-73c8-4f2d-91f4-3c90b872c700","version": 3,"createdAt": "2015-10-07T07:33:05.894Z","lastModifiedAt": "2015-10-07T07:33:06.070Z","lineItems": [{"id": "90dff06c-272e-47fa-b8de-923dce092474","productId": "7b1203f4-66c0-438c-9a30-f4fb6be79bdf","name": {"de": "WB ATHLETIC PANZER","en": "WB ATHLETIC TANK"},"productType": {"typeId": "product-type","id": "2543e1d8-4915-4f72-a3c9-1df9b1b0082d","version": 8},"productSlug": {"en": "wb-athletic-tank1421832124574"},"variant": {"id": 1,"sku": "sku_WB_ATHLETIC_TANK_variant1_1421832124574","prices": [{"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"id": "37696f7c-8260-4941-a921-68e6aa76b4a3"}],"images": [{"url": "https://www.commercetools.com/cli/data/253265444_1.jpg","dimensions": {"w": 1400,"h": 1400}}],"attributes": [],"assets": []},"price": {"value": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"id": "37696f7c-8260-4941-a921-68e6aa76b4a3"},"quantity": 1,"discountedPricePerQuantity": [],"state": [{"quantity": 1,"state": {"typeId": "state","id": "7c2e2694-aefe-43d7-888e-6a99514caaca"}}],"priceMode": "Platform","lineItemMode": "Standard","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"custom": {"type": {"typeId": "type","id": "3ae9bcca-df23-443e-bd22-0c592f9694fa"},"fields": {"offer_name": "SuperMax"}},"perMethodTaxRate": [],"taxedPricePortions": []}],"cartState": "Active","totalPrice": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "EUR","centAmount": 8400},"country": "DE","customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": [],"shipping": [],"shippingMode": "Single"}]}
Check if Cart exists
Check if Cart exists
Checks if a Cart exists for a given id
. Returns a 200 OK
status if the Cart exists or a 404 Not Found
otherwise.
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/me/carts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Check if Cart exists in Store
Checks ifa My Cart exists for a given id
. Returns a 200 OK
status if the My Cart exists or a 404 Not Found
otherwise.
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
id String |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Check if active Cart exists
Checks if an active Cart exists. Returns a 200 OK
status if an active Cart exists or a 404 Not Found
otherwise.
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/me/active-cart -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Check if active Cart exists in Store
Checks if an active Cart exists. Returns a 200 OK
status if an active Cart exists or a 404 Not Found
otherwise.
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/active-cart -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Check if Cart exists by Query Predicate
Checks if a Cart exists for a given Query Predicate. Returns a 200 OK
status if any Carts match the Query Predicate or a 404 Not Found
otherwise.
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
where | The parameter can be passed multiple times. |
curl --head https://api.{region}.commercetools.com/{projectKey}/me/carts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Check if Cart exists in Store by Query Predicate
Checks if a Cart exists for a given Query Predicate. Returns a 200 OK
status if any Carts match the Query Predicate or a 404 Not Found
otherwise.
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
where | The parameter can be passed multiple times. |
curl --head https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Create Cart
When creating B2B Carts, the Customer must have the CreateMyCarts
Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.
Create Cart
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
expand | The parameter can be passed multiple times. |
application/json
application/json
curl https://api.{region}.commercetools.com/{projectKey}/me/carts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"currency" : "EUR"}DATA
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Create Cart in Store
The store
field in the created Cart is set to the Store specified by the storeKey
path parameter.
Specific Error Codes: CountryNotConfiguredInStore
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
expand | The parameter can be passed multiple times. |
application/json
application/json
curl https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"currency" : "EUR"}DATA
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Replicate My Cart
Creates a new Cart by replicating an existing Cart or Order of the authenticated Customer. This can be useful in cases where a customer wants to cancel a recent order to make some changes or reorder a previous order.
The replicated Cart preserves Customer information, Line Items and Custom Line Items, Custom Fields, Discount Codes, and other settings of the Cart or Order.
If the Line Items become invalid, for example, due to removed Products or Prices, they are removed from the new Cart.
If the Customer switches to another Customer Group, the new Cart is updated with the new value.
It has up-to-date Tax Rates, Prices, and Line Item product data and is in Active
CartState.
The new Cart does not contain Payments or Deliveries. The State of Line Items and Custom Line Items is reset to initial
.
In case the Cart or Order to be replicated does not belong to the authenticaed Customer, the API returns a ResourceNotFound error
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
application/json
application/json
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Update Cart
When updating B2B Carts, the Customer must have the UpdateMyCarts
Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.
Update Cart
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
expand | The parameter can be passed multiple times. |
application/json
version Int | Expected version of the Cart on which the changes apply. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actions Array of MyCartUpdateAction | Update actions to be performed on the Cart. |
application/json
curl https://api.{region}.commercetools.com/{projectKey}/me/carts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "addLineItem","productId" : "9f10dcfb-5cc9-4a18-843a-c07f7e22d01f","variantId" : 1,"quantity" : 1} ]}DATA
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Update Cart in Store
If the Cart exists in the Project but does not have the store
field, or the store
field references a different Store, this method returns a ResourceNotFound error.
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
id String |
|
expand | The parameter can be passed multiple times. |
application/json
version Int | Expected version of the Cart on which the changes apply. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actions Array of MyCartUpdateAction | Update actions to be performed on the Cart. |
application/json
curl https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "addLineItem","productId" : "9f10dcfb-5cc9-4a18-843a-c07f7e22d01f","variantId" : 1,"quantity" : 1} ]}DATA
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Update actions
on Cart
Set Customer Email
action String | "setCustomerEmail" |
email String | Value to set. If empty, any existing value is removed. |
Set Business Unit
Updates the Business Unit on the Cart. The Cart must have an existing Business Unit assigned already.
action String | "setBusinessUnit" |
businessUnit | New Business Unit to assign to the Cart, which must have access to the Store that is set on the Cart. Additionally, the authenticated user must be an Associate in the Business Unit. |
Add LineItem
If the Cart contains a LineItem for a Product Variant with the same LineItemMode, Custom Fields, supply and distribution channel, then only the quantity of the existing Line Item is increased.
If LineItem shippingDetails
is set, it is merged. All addresses will be present afterwards and, for address keys present in both shipping details, the quantity will be summed up.
The LineItem price is set as described in LineItem Price selection.
If the Tax Rate is not set, a MissingTaxRateForCountry error is returned.
If the Line Items do not have a Price according to the Product priceMode
value for a selected currency and/or country, Customer Group, or Channel, a MatchingPriceNotFound error is returned.
action String | "addLineItem" |
key String | User-defined unique identifier of the LineItem. MinLength:2 MaxLength: 256 Pattern: ^[a-zA-Z0-9_-] |
productId String |
Either the |
variantId Int |
If not given, the Master Variant is used. Either the |
sku String |
Either the |
quantity Int | Number of Line Items to add to the Cart. Default:1 |
addedAt | Date and time (UTC) the Line Item was added to the Cart. If not set, it defaults to the current date and time. Optional for backwards compatibility reasons. |
distributionChannel | Used to select a Product Price.
The Channel must have the |
supplyChannel | Used to identify Inventory entries that must be reserved.
The Channel must have the |
shippingDetails | Container for Line Item-specific addresses. |
custom | Custom Fields for the Line Item. |
{"action": "addLineItem","productId": "{{product-id}}","variantId": 2,"quantity": 1,"supplyChannel": {"typeId": "channel","id": "{{channel-id}}"},"distributionChannel": {"typeId": "channel","id": "{{channel-id}}"},"externalTaxRate": {"name": "StandardExternalTaxRate","amount": 0.19,"country": "DE","state": "Bavaria"},"shippingDetails": {"targets": [{"addressKey": "AddressKeyStringFromAddress","quantity": 2}]}}
Remove LineItem
The LineItem price is updated as described in LineItem Price selection.
action String | "removeLineItem" |
lineItemId String |
|
lineItemKey String |
|
quantity Int | Amount to subtract from the LineItem's |
externalPrice | Sets the LineItem |
externalTotalPrice | Sets the LineItem |
shippingDetailsToRemove | Container for Line Item-specific addresses to remove. |
{"action": "removeLineItem","lineItemId": "{{lineItemId}}","quantity": 1,"externalPrice": {"currencyCode": "EUR","centAmount": 4000},"shippingDetailsToRemove": {"targets": [{"addressKey": "AddressKeyStringFromAddress","quantity": 2}]}}
Add DiscountCode
Adds a DiscountCode to the Cart to activate the related CartDiscounts.
Adding a Discount Code is only possible if no DirectDiscount has been applied to the Cart.
Discount Codes can be added to frozen Carts, but their DiscountCodeState is then DoesNotMatchCart
.
The maximum number of Discount Codes in a Cart is restricted by a limit.
Specific Error Code: MatchingPriceNotFound
action String | "addDiscountCode" |
code String |
|
{"action": "addDiscountCode","code": "mydiscountcode"}
Remove DiscountCode
action String | "removeDiscountCode" |
discountCode | Discount Code to remove from the Cart. |
{"action": "removeDiscountCode","discountCode": {"typeId": "discount-code","id": "{{discount-code-id}}"}}
Add Payment
action String | "addPayment" |
payment | Payment to add to the Cart. Must not be assigned to another Order or active Cart already. |
{"action": "addPayment","payment": {"id": "{{payment-id}}","typeId": "payment"}}
Remove Payment
action String | "removePayment" |
payment | Payment to remove from the Cart. |
{"action": "removePayment","payment": {"id": "{{payment-id}}","typeId": "payment"}}
Change TaxMode
- When
External
TaxMode is changed toPlatform
orDisabled
, all previously set external Tax Rates are removed. - When set to
Platform
, Line Items, Custom Line Items, and Shipping Method require a Tax Category with a Tax Rate for the Cart'sshippingAddress
.
action String | "changeTaxMode" |
taxMode | The new TaxMode. |
{"action": "changeTaxMode","taxMode": "Platform"}
Set Billing Address
action String | "setBillingAddress" |
address | Value to set. If empty, any existing value is removed. |
{"action": "setBillingAddress","address": {"key": "exampleKey","title": "My Address","salutation": "Mr.","firstName": "Example","lastName": "Person","streetName": "Example Street","streetNumber": "4711","additionalStreetInfo": "Backhouse","postalCode": "80933","city": "Exemplary City","region": "Exemplary Region","state": "Exemplary State","country": "DE","company": "My Company Name","department": "Sales","building": "Hightower 1","apartment": "247","pOBox": "2471","phone": "+49 89 12345678","mobile": "+49 171 2345678","email": "email@example.com","fax": "+49 89 12345679","additionalAddressInfo": "no additional Info","externalId": "Information not needed"}}
Set Shipping Address
Setting the shipping address also sets the TaxRate of Line Items and calculates the TaxedPrice.
If a matching price cannot be found for the given shipping address during Line Item Price selection, a MissingTaxRateForCountry error is returned.
If you want to allow shipping to states inside a country that are not explicitly covered by a TaxRate,
set the countryTaxRateFallbackEnabled
field to true
in the CartsConfiguration by using
the Change CountryTaxRateFallbackEnabled update action.
action String | "setShippingAddress" |
address | Value to set.
If not set, the shipping address is unset, and the |
{"action": "setShippingAddress","address": {"key": "exampleKey","title": "My Address","salutation": "Mr.","firstName": "Example","lastName": "Person","streetName": "Example Street","streetNumber": "4711","additionalStreetInfo": "Backhouse","postalCode": "80933","city": "Exemplary City","region": "Exemplary Region","state": "Exemplary State","country": "DE","company": "My Company Name","department": "Sales","building": "Hightower 1","apartment": "247","pOBox": "2471","phone": "+49 89 12345678","mobile": "+49 171 2345678","email": "email@example.com","fax": "+49 89 12345679","additionalAddressInfo": "no additional Info","externalId": "Information not needed"}}
Add ItemShippingAddress
Adds an address to a Cart when shipping to multiple addresses is desired.
action String | "addItemShippingAddress" |
address | Address to append to The new address must have a key that is unique accross this Cart. |
{"action": "addItemShippingAddress","address": {"key": "exampleKey","title": "My Address","salutation": "Mr.","firstName": "Example","lastName": "Person","streetName": "Example Street","streetNumber": "4711","additionalStreetInfo": "Backhouse","postalCode": "80933","city": "Exemplary City","region": "Exemplary Region","state": "Exemplary State","country": "DE","company": "My Company Name","department": "Sales","building": "Hightower 1","apartment": "247","pOBox": "2471","phone": "+49 89 12345678","mobile": "+49 171 2345678","email": "email@example.com","fax": "+49 89 12345679","additionalAddressInfo": "no additional Info","externalId": "Information not needed"}}
Remove ItemShippingAddress
An address can only be removed if it is not referenced in any ItemShippingTarget of the Cart.
action String | "removeItemShippingAddress" |
addressKey String |
|
{"action": "removeItemShippingAddress","addressKey": "{{addressKey}}"}
Update ItemShippingAddress
Updates an address in itemShippingAddresses
by keeping the Address key
.
action String | "updateItemShippingAddress" |
address | The new Address with the same |
{"action": "updateItemShippingAddress","address": {"key": "exampleKey","title": "My Address","salutation": "Mr.","firstName": "Example","lastName": "Person","streetName": "Example Street","streetNumber": "4711","additionalStreetInfo": "Backhouse","postalCode": "80933","city": "Exemplary City","region": "Exemplary Region","state": "Exemplary State","country": "DE","company": "My Company Name","department": "Sales","building": "Hightower 1","apartment": "247","pOBox": "2471","phone": "+49 89 12345678","mobile": "+49 171 2345678","email": "email@example.com","fax": "+49 89 12345679","additionalAddressInfo": "no additional Info","externalId": "Information not needed"}}
Set ShippingMethod
To set the Cart's Shipping Method the Cart must have the Single
ShippingMode and a shippingAddress
.
action String | "setShippingMethod" |
shippingMethod | Value to set. If empty, any existing value is removed. If the referenced Shipping Method has a predicate that does not match the Cart, an InvalidOperation error is returned. |
externalTaxRate | An external Tax Rate can be set if the Cart has the |
{"action": "setShippingMethod","shippingMethod": {"id": "{{shipping-method-id}}","typeId": "shipping-method"}}
Set Locale
Set Country
Setting the country can lead to changes in the LineItem prices.
action String | "setCountry" |
country | Value to set. If empty, any existing value is removed. If the Cart is bound to a ^[A-Z]{2}$ |
{"action": "setCountry","country": "DE"}
Set DeleteDaysAfterLastModification
Number of days after which a Cart with Active
CartState is deleted since its last modification.
If a ChangeSubscription exists for Carts, a ResourceDeletedDeliveryPayload is sent.
action String | "setDeleteDaysAfterLastModification" |
deleteDaysAfterLastModification Int | Value to set. If not provided, the default value for this field configured in Project settings is assigned. |
{"action": "setDeleteDaysAfterLastModification","deleteDaysAfterLastModification": 90}
Set Custom Type
action String | "setCustomType" |
type | Defines the Type that extends the Cart with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Cart. |
fields | Sets the Custom Fields fields for the Cart. |
{"action": "setCustomType","type": {"id": "{{type-id}}","typeId": "type"},"fields": {"exampleStringTypeField": "TextString"}}
Set CustomField
action String | "setCustomField" |
name String | Name of the Custom Field. |
value | If |
{"action": "setCustomField","name": "ExampleStringTypeField","value": "TextString"}
Recalculate
This update action does not set any Cart field in particular, but it triggers several Cart updates to bring prices and discounts to the latest state. Those can become stale over time when no Cart updates have been performed for a while and prices on related Products have changed in the meanwhile.
If the priceMode
of the Product related to a Line Item is of Embedded
ProductPriceMode,
the updated price
of that LineItem may not correspond to a Price in the variant.prices
anymore.
action String | "recalculate" |
updateProductData Boolean |
false |
{"action": "recalculate","updateProductData": true}
on LineItem
Change LineItem Quantity
When multiple shipping addresses are set for a Line Item,
use the Remove LineItem and Add LineItem update action
to change the shipping details.
Since it is not possible for the API to infer how the overall change in the Line Item quantity should be distributed over the sub-quantities,
the shippingDetails
field is kept in its current state to avoid data loss.
To change the Line Item quantity and shipping details together, use this update action in combination with the Set LineItem ShippingDetails update action in a single Cart update command.
When the action applies to LineItems with ExternalTotal
LineItemPriceMode,
it will be changed to ExternalPrice
and the existing externalPrice
value, i.e. LineItem.price
, will be retained.
The LineItem total will be calculated by the system instead, so that the externalTotalPrice
will be dropped.
action String | "changeLineItemQuantity" |
lineItemId String |
|
lineItemKey String |
|
quantity Int | New value to set. If |
{"action": "changeLineItemQuantity","lineItemId": "{{lineItemId}}","quantity": 1}
Set LineItem DistributionChannel
Setting a distribution channel for a LineItem can lead to an updated price
as described in LineItem Price selection.
action String | "setLineItemDistributionChannel" |
lineItemId String |
|
lineItemKey String |
|
distributionChannel |
|
{"action": "setLineItemDistributionChannel","lineItemId": "{{lineItemId}}","distributionChannel": {"typeId": "channel","id": "{{channel-id}}"}}
Set LineItem SupplyChannel
Performing this action has no impact on inventory that should be reserved.
action String | "setLineItemSupplyChannel" |
lineItemId String |
|
lineItemKey String |
|
supplyChannel |
|
{"action": "setLineItemSupplyChannel","lineItemId": "{{lineItemId}}","supplyChannel": {"typeId": "channel","id": "{{channel-id}}"}}
Set LineItem ShippingDetails
action String | "setLineItemShippingDetails" |
lineItemId String |
|
lineItemKey String |
|
shippingDetails | Value to set. If empty, the existing value is removed. |
{"action": "setLineItemShippingDetails","lineItemId": "{{lineItemId}}","shippingDetails": {"targets": [{"addressKey": "{{addressKey}}","quantity": 1}]}}
Apply DeltaToLineItemShippingDetailsTargets
To override the shipping details, see Set LineItem ShippingDetails.
action String | "applyDeltaToLineItemShippingDetailsTargets" |
lineItemId String |
|
lineItemKey String |
|
targetsDelta Array of ItemShippingTarget | Using positive or negative quantities increases or decreases the number of items shipped to an address. |
{"action": "applyDeltaToLineItemShippingDetailsTargets","lineItemId": "{{lineItemId}}","targetsDelta": [{"addressKey": "addressKeyString","quantity": 1}]}
Set LineItem Custom Type
action String | "setLineItemCustomType" |
lineItemId String |
|
lineItemKey String |
|
type | Defines the Type that extends the LineItem with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Line Item. |
fields | Sets the Custom Fields fields for the Line Item. |
{"action": "setLineItemCustomType","lineItemId": "{{lineItemId}}","type": {"id": "{{type-id}}","typeId": "type"},"fields": {"exampleStringTypeField": "TextString"}}
Set LineItem CustomField
action String | "setLineItemCustomField" |
lineItemId String |
|
lineItemKey String |
|
name String | Name of the Custom Field. |
value | If |
{"action": "setLineItemCustomField","lineItemId": "{{lineItemId}}","name": "ExampleStringTypeField","value": "TextString"}
Delete Cart
When deleting B2B Carts, the Customer must have the DeleteMyCarts
Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.
Delete Cart
manage_my_orders:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
version Int | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/json
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/me/carts/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}
Delete Cart in Store
manage_my_orders:{projectKey} ,
manage_my_orders:{projectKey}:{storeKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
storeKey String |
|
id String |
|
version Int | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/json
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/me/carts/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"type": "Cart","id": "27b39077-aa57-48a5-b504-914f68fa44dc","version": 1,"createdAt": "2023-01-23T13:06:28.569Z","lastModifiedAt": "2023-01-23T13:06:28.569Z","lastModifiedBy": {"isPlatformClient": false},"createdBy": {"isPlatformClient": false},"lineItems": [],"cartState": "Active","totalPrice": {"type": "centPrecision","currencyCode": "EUR","centAmount": 0,"fractionDigits": 2},"shippingMode": "Single","shipping": [],"customLineItems": [],"discountCodes": [],"directDiscounts": [],"inventoryMode": "None","taxMode": "Platform","taxRoundingMode": "HalfEven","taxCalculationMode": "LineItemLevel","refusedGifts": [],"origin": "Customer","itemShippingAddresses": []}