Queries and mutations for managing the Carts of the authenticated Customer.

The My Carts mutations operate on the same Cart output type as the Carts mutations, but accept a restricted set of input types and update actions. Types that are shared with Carts are documented only on the Carts page and linked from here.

Queries

The queries for My Carts are the cart, carts, and activeCart fields on the me field. They are the same as the queries documented on the Carts page (Query Carts, Get Cart, and Get active Cart), but return only Carts of the authenticated Customer.

Mutations

Create My Cart

MUTATIONcreateMyCart
BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta
Arguments
draft​
storeKey​

The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions.

Output:Cart

Update My Cart

MUTATIONupdateMyCart
BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta
Arguments
id​
String​
version​
Long​
actions​
Array of MyCartUpdateAction​
storeKey​

The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions.

Output:Cart

Delete My Cart

MUTATIONdeleteMyCart
BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta
Arguments
id​
String​
version​
Long​
storeKey​

The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions.

Output:Cart

Replicate My Cart

MUTATIONreplicateMyCart
BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta
Arguments
reference​
Output:Cart

Output types

The My Carts mutations return the Cart type. To query Carts of the authenticated Customer, use the cart, carts, and activeCart fields on the me field. These return Cart and CartQueryResult.

Input types

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.

country​
Used for Line Item price selection. If used for Create Cart in Store, the provided country must be one of the Store's countries.
inventoryMode​

Determines how stock quantities are tracked for Line Items in the Cart.

Can be None, TrackOnly, ReserveOnOrder, or ReserveOnCart​Default: None​
custom​

Custom Fields for the Cart.

customerEmail​
String​

Email address of the Customer the Cart belongs to.

shippingAddress​
Shipping address associated with the Cart. Determines eligible ShippingMethod rates and Tax Rates of Line Items.
billingAddress​

Billing address associated with the Cart.

shippingMethod​
Shipping Method for the Cart. If the referenced ShippingMethod has a predicate that does not match the Cart, an InvalidOperation error is returned when creating a Cart.
taxMode​
Determines how Tax Rates are set. The Disabled TaxMode cannot be set.
Can be Disabled, External, ExternalAmount, or Platform​Default: Platform​
locale​
Language of the Cart. Must be one of the languages supported by the Project.
deleteDaysAfterLastModification​
Int​
Number of days after the last modification before a Cart is deleted. If not provided, the default value for this field configured in Project settings is assigned.
Create a ChangeSubscription for Carts to receive a ResourceDeletedDeliveryPayload upon deletion of the Cart.
itemShippingAddresses​
Array of AddressInput​
Multiple shipping addresses of the Cart. Each address must contain a key that is unique in this Cart. The keys are used by LineItems to reference these addresses under their shippingDetails.
Eligible Shipping Methods or applicable Tax Rates are determined by the Cart shippingAddress, and not itemShippingAddresses.
Default: []​
discountCodes​
Array of String​
code of the existing DiscountCodes to add to the Cart.
Default: []​
ResourceIdentifier to the Store the Cart should belong to. Once set, it cannot be updated.
businessUnit​
ResourceIdentifier to the Business Unit the Cart should belong to. The Customer must be an Associate of the Business Unit. Only available for B2B-enabled Projects.
purchaseOrderNumber​
String​
shippingMode​
  • If set to Single, only a single Shipping Method can be added to the Cart.
  • If set to Multiple, multiple Shipping Methods can be added to the Cart.
Can be Multiple, or Single​Default: Single​
customShipping​
Default: []​
shipping​
Array of ShippingDraft​
Default: []​
lineItems​
Array of MyLineItemDraft​
Line Items to add to the Cart.
Default: []​

InventoryMode

None
No inventory checks or modifications when adding items or ordering. Default for a new cart.
TrackOnly
Orders decrement the available quantity on the matching inventory entry; ordering fails only when no inventory entry exists for a line item.
ReserveOnOrder
Line items are reserved only for the duration of the ordering transaction; creating an order fails when an unavailable line item exists.
ReserveOnCart
Items are reserved when added to the cart. Not supported by this service.

TaxMode

Disabled
No taxes are added to the cart.
External
The tax rates are set externally per ExternalTaxRateDraft. A cart with this tax mode can only be ordered if all line items, all custom line items and the shipping method have an external tax rate set. The totalNet and totalGross as well as the taxPortions fields are calculated according to the taxRoundingMode.
ExternalAmount
The tax amounts and the tax rates as well as the tax portions are set externally per ExternalTaxAmountDraft. A cart with this tax mode can only be ordered if the cart itself and all line items, all custom line items and the shipping method have an external tax amount and rate set
Platform
The tax rates are selected from the TaxCategories based on the cart shipping address. The totalNet and totalGross as well as the taxPortions fields are calculated according to the taxRoundingMode.

ShippingMode

Multiple
Allows multiple shipping methods for the cart with their respective shipping addresses
Single
Allows only one shipping method and shipping address for the cart

CustomShippingDraft

key​
String​
User-defined unique identifier of the custom Shipping Method in the Cart with Multiple ShippingMode.
shippingMethodName​
String​

Name of the custom Shipping Method.

shippingAddress​

Determines the shipping rate and Tax Rate of the associated Line Items.

shippingRate​

Determines the shipping price.

shippingRateInput​
Input used to select a ShippingRatePriceTier. The data type of this field depends on the shippingRateInputType.type configured in the Project:
taxCategory​
Tax Category used to determine a shipping Tax Rate if the Cart has the Platform TaxMode.
externalTaxRate​
Tax Rate used to tax a shipping expense if the Cart has the External TaxMode.
deliveries​
Array of DeliveryDraft​

Deliveries to be shipped with the custom Shipping Method.

custom​

Custom Fields for the custom Shipping Method.

ShippingRateInputDraft

Classification​
Score​

ClassificationShippingRateInputDraft

key​
String​

Key of the value used as a programmatic identifier.

ScoreShippingRateInputDraft

score​
Int​

Abstract value for categorizing a Cart.

ExternalTaxRateDraft

Controls calculation of taxed prices for Line Items, Custom Line Items, and Shipping Methods as explained in Cart tax calculation.
name​
String​

Name of the Tax Rate.

amount​
Float​

Percentage in the range of 0-1.

  • If no subRates are specified, a value must be defined.
  • If subRates are specified, this can be omitted or its value must be the sum of all subRates amounts.
country​

Country for which the tax applies.

state​
String​

State within the specified country.

subRates​
Array of SubRateDraft​
Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.
Default: []​
includedInPrice​
Boolean​
  • If set to false, the related price is considered the net price and the provided amount is applied to calculate the gross price.
  • If set to true, the related price is considered the gross price, and the provided amount is applied to calculate the net price.
Default: false​
taxRoundingTarget​
Determines whether the taxRoundingMode of the Cart or Order is applied to the net price or the tax amount when includedInPrice is true. The field is ignored if includedInPrice is false.
Can be Net, or Tax​Default: Net​

SubRateDraft

name​
String​
amount​
Float​

TaxRoundingTarget

Net
Default. `taxRoundingMode` is applied to the net price and the tax amount is the exact remainder. E.g. at 20% on `1.23`, the net rounds to `1.02` and the tax is `0.21`.
Tax
`taxRoundingMode` is applied to the tax amount and the net price is the exact remainder. E.g. at 20% on `1.23`, the tax rounds to `0.20` and the net is `1.03`. Has no effect when the rate is not included in the price.

DeliveryDraft

key​
String​

User-defined identifier of the Delivery. Must be unique among Deliveries in the Order.

items​
Line Items or Custom Line Items to deliver. It can also be specified individually for each Parcel.
parcels​
Array of ParcelDraft​

Information regarding the appearance, content, and shipment of a parcel.

address​

Address to which the Parcels are delivered.

custom​

Custom Fields for the Delivery.

DeliveryItemDraftType

id​
String​
quantity​
Long​

ParcelDraft

id​
String​
key​
String​
createdAt​
measurements​
trackingData​
items​
Default: []​
custom​

ParcelMeasurementsDraftType

heightInMillimeter​
Int​
lengthInMillimeter​
Int​
widthInMillimeter​
Int​
weightInGram​
Int​

TrackingDataDraftType

trackingId​
String​
carrier​
String​
provider​
String​
providerTransaction​
String​
isReturn​
Boolean​
Default: false​

ShippingDraft

Wraps all shipping-related information (such as address, rate, deliveries) per Shipping Method for Carts with multiple Shipping Methods.

key​
String​
User-defined unique identifier for the Shipping in a Cart with Multiple ShippingMode.
shippingMethod​
Shipping Methods added to the Cart with Multiple ShippingMode.
shippingAddress​

Determines the shipping rate and Tax Rate of the associated Line Items.

shippingRateInput​
Input used to select a ShippingRatePriceTier. The data type of this field depends on the shippingRateInputType.type configured in the Project:
externalTaxRate​
Tax Rate used for taxing a shipping expense if the Cart has the External TaxMode.
deliveries​
Array of DeliveryDraft​

Deliveries to be shipped with the Shipping Method.

custom​

Custom Fields for Shipping.

MyLineItemDraft

For Product Variant identification, either the productId and variantId, or sku must be provided.
key​
String​

User-defined identifier of the LineItem. Must be unique among LineItems in the Cart.

productId​
String​
id of the Product.
sku​
String​
sku of the ProductVariant.
quantity​
Long​

Quantity of Product Variants to add to the Cart.

variantId​
Int​
id of the ProductVariant in the Product. If not provided, the Master Variant is used.
supplyChannel​
Used to identify Inventory entries that must be reserved. The Channel must have the InventorySupply ChannelRoleEnum.
distributionChannel​
Used to select a Product Price. The Channel must have the ProductDistribution ChannelRoleEnum.
If the Cart is bound to a Store with distributionChannels set, the Channel must match one of the Store's distribution channels.
custom​

Custom Fields for the Cart.

shippingDetails​

Container for Line Item-specific addresses.

addedAt​

Date and time (UTC) the Product Variant was added to the Cart. If not set, it defaults to the current date and time.

Optional for backwards compatibility reasons.

recurrenceInfo​

Recurring Order and frequency data.

ItemShippingDetailsDraft

targets​
Default: []​
shippingTargets​
Default: []​
itemShippingAddressTargets​
Default: []​

ShippingTargetDraft

addressKey​
String​
quantity​
Long​
shippingMethodKey​
String​

ShippingMethodTargetDraft

shippingMethodKey​
String​
quantity​
Long​

ItemShippingAddressTargetDraft

addressKey​
String​
quantity​
Long​

LineItemRecurrenceInfoInputDraft

recurrencePolicy​
expiresAt​
priceSelectionMode​
Can be Dynamic, or Fixed​

MyCartUpdateAction

addDiscountCode​
addItemShippingAddress​
addPayment​
addShoppingList​
changeLineItemsOrder​
changeTaxMode​
recalculate​
removeDiscountCode​
removeItemShippingAddress​
removeLineItem​
removePayment​
setBillingAddress​
setBillingAddressCustomField​
setBillingAddressCustomType​
setBusinessUnit​
setCountry​
setCustomField​
setCustomType​
setCustomerEmail​
setDeleteDaysAfterLastModification​
setItemShippingAddressCustomField​
setItemShippingAddressCustomType​
setLineItemCustomField​
setLineItemCustomType​
setLineItemDistributionChannel​
setLineItemShippingDetails​
setLineItemSupplyChannel​
setLocale​
setShippingMethod​
setShippingAddress​
setShippingAddressCustomField​
setShippingAddressCustomType​
setShippingCustomField​
setShippingCustomType​
updateItemShippingAddress​
applyDeltaToLineItemShippingDetailsTargets​
applyDeltaToCustomLineItemShippingDetailsTargets​
addLineItem​
setLineItemRecurrenceInfo​
setCustomLineItemRecurrenceInfo​
changeLineItemQuantity​

Update actions

MyCartUpdateAction supports a subset of the CartUpdateAction update actions. Update actions that are not listed on this page are not available for My Carts. Update actions that use the same input type as on Carts link to their definition on the Carts page.

Add DiscountCode

See Add DiscountCode on Carts.

Add ItemShippingAddress

Add Payment

See Add Payment on Carts.

Add Shopping List

See Add Shopping List on Carts.

Change LineItems Order

Change TaxMode

taxMode​
Can be Disabled, External, ExternalAmount, or Platform​

TaxMode

Disabled
No taxes are added to the cart.
External
The tax rates are set externally per ExternalTaxRateDraft. A cart with this tax mode can only be ordered if all line items, all custom line items and the shipping method have an external tax rate set. The totalNet and totalGross as well as the taxPortions fields are calculated according to the taxRoundingMode.
ExternalAmount
The tax amounts and the tax rates as well as the tax portions are set externally per ExternalTaxAmountDraft. A cart with this tax mode can only be ordered if the cart itself and all line items, all custom line items and the shipping method have an external tax amount and rate set
Platform
The tax rates are selected from the TaxCategories based on the cart shipping address. The totalNet and totalGross as well as the taxPortions fields are calculated according to the taxRoundingMode.
This update action uses a dedicated input type instead of ChangeCartTaxMode. See Change TaxMode on Carts for the Cart version.

Recalculate

See Recalculate on Carts.

Remove DiscountCode

See Remove DiscountCode on Carts.

Remove ItemShippingAddress

Remove LineItem

See Remove LineItem on Carts.

Remove Payment

See Remove Payment on Carts.

Set Billing Address

See Set Billing Address on Carts.

Set Billing Address CustomField

Set Billing Address Custom Type

Set Business Unit B2B B2X

See Set Business Unit on Carts.

Set Country

See Set Country on Carts.

Set CustomField

See Set CustomField on Carts.

Set Custom Type

See Set Custom Type on Carts.

Set Customer Email

See Set Customer Email on Carts.

Set DeleteDaysAfterLastModification

Set ItemShipping Address CustomField

Set ItemShipping Address Custom Type

Set LineItem CustomField

Set LineItem Custom Type

Set LineItem DistributionChannel

Set LineItem ShippingDetails

Set LineItem SupplyChannel

Set Locale

See Set Locale on Carts.

Set ShippingMethod

shippingMethod​
This update action uses a dedicated input type instead of SetCartShippingMethod. See Set ShippingMethod on Carts for the Cart version.

Set Shipping Address

See Set Shipping Address on Carts.

Set Shipping Address CustomField

Set Shipping Address Custom Type

Set Shipping CustomField

Set Shipping Custom Type

Update ItemShippingAddress

Apply DeltaToLineItemShippingDetailsTargets

Apply DeltaToCustomLineItemShippingDetailsTargets

Add LineItem

key​
String​
productId​
String​
sku​
String​
quantity​
Long​
variantId​
Int​
supplyChannel​
distributionChannel​
custom​
shippingDetails​
addedAt​
recurrenceInfo​

ItemShippingDetailsDraft

targets​
Default: []​
shippingTargets​
Default: []​
itemShippingAddressTargets​
Default: []​

ShippingTargetDraft

addressKey​
String​
quantity​
Long​
shippingMethodKey​
String​

ShippingMethodTargetDraft

shippingMethodKey​
String​
quantity​
Long​

ItemShippingAddressTargetDraft

addressKey​
String​
quantity​
Long​

LineItemRecurrenceInfoInputDraft

recurrencePolicy​
expiresAt​
priceSelectionMode​
Can be Dynamic, or Fixed​
This update action uses a dedicated input type instead of AddCartLineItem. See Add LineItem on Carts for the Cart version.

Set LineItemRecurrenceInfo

Set CustomLineItemRecurrenceInfo

Change LineItem Quantity