Execute
Run a chain of existing cart operations in one request.
Runs a sequence of existing cart operations in one HTTP request. Cart, item, and discount REST endpoints stay unchanged. POST /cart/{tenant}/carts/{cartId}/execute is an additional, opt-in way to call the same operations. The cart id is the path parameter. The service copies it onto every command. One request is one cart.
A typical storefront flow is AddCartItem followed by GetCart with expandCalculation set to true. The 207 results array already contains the created item and the calculated cart, so the client does not send a second GET unless it wants a later refresh. The two-call sequence (POST .../items then GET .../carts/{cartId}) continues to work.
Request duration is approximately the sum of the chained commands. The client saves a network round trip, not the calculation work. Clients and API gateways must set timeouts for the full chain, especially when a command runs cart calculation.
The service does not send HTTP requests to the existing REST URLs. Downstream calls inside those operations (price, product, cart calculation) still happen, the same as in the equivalent REST calls.
For command types, error handling, session and legal entity, versioning, and whole-request validation errors, see How to add an item and retrieve the calculated cart in one request.
Additional scopes information
cart.cart_manage– Use when a service token manages carts that do not belong to the request customer.cart.cart_manage_external_prices– Use when a command payload includes an external price, product, fee, or discount.
Cart unique identifier generated when a cart is created.
Your Emporix tenant name.
Note: The tenant should always be written in lowercase.
^[a-z][a-z0-9]+$Controls whether the chain stops after the first non-2xx command.
Possible values:
fail– Stop after the first non-2xx command.resultscontains only the commands that ran, including the failed one.resume– Run every command. Later commands still see earlier successful mutations.
An invalid value returns 400 for the whole request before any command runs.
failPossible values: If-Match strategy for participating writes (AddCartItem, UpdateCartItem, UpdateCart, ApplyCartDiscount).
Possible values:
skip– Never pass a version. Ignoreoptions.resourceVersionif present.explicit– Every participating command must sendoptions.resourceVersion. Missing version on any participating write returns 400 for the whole request (preflight). This is notskip.follow– Seed from the first participating write, then use that cursor for later writes. After the cursor exists, a successfulRefreshCart, delete, or itemsBatch also bumps it.
An invalid value returns 400 for the whole request before any command runs.
skipPossible values: Anonymous customer unique session identifier. Shared by every command in the chain. Commands cannot override this header.
Legal entity of the shopper context. Shared by every command in the chain. Commands cannot override this header. To act as a different legal entity, send another request.
Body of POST /cart/{tenant}/carts/{cartId}/execute. Between 1 and 10 commands.
The command chain was accepted and executed. results lists each command that ran. This status is used for all-2xx chains and for partial failures.
Body of a 207 execute response. Present only when the chain was accepted and executed.
The execute request is invalid. No command ran. results is not returned.
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
Given authorization scopes are not sufficient and do not match scopes required by the endpoint.
Some server-side error occurred. Details will be provided in the response payload.
POST /cart/{tenant}/carts/{cartId}/execute HTTP/1.1
Host: api.emporix.io
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 304
{
"commands": [
{
"type": "AddCartItem",
"data": {
"itemYrn": "urn:yaas:saasag:caasproduct:product:yourTenant;mobile-phone-s24-gross",
"quantity": 2,
"price": {
"priceId": "679ca63dbcdefe5b380c98bc",
"originalAmount": 350,
"effectiveAmount": 350,
"currency": "EUR"
}
}
},
{
"type": "GetCart",
"options": {
"expandCalculation": true
}
}
]
}{
"results": [
{
"index": 0,
"type": "AddCartItem",
"code": 201,
"status": "Created",
"data": {
"itemId": "3",
"yrn": "urn:yaas:saasag:caascart:item:yourTenant;6a86b20c2f5961330a8b3eb6;3"
}
},
{
"index": 1,
"type": "GetCart",
"code": 200,
"status": "OK",
"data": {
"id": "6a86b20c2f5961330a8b3eb6",
"currency": "EUR",
"siteCode": "main",
"type": "shopping",
"items": [
{
"id": "3",
"quantity": 2,
"effectiveQuantity": 2,
"itemYrn": "urn:yaas:saasag:caasproduct:product:yourTenant;mobile-phone-s24-gross",
"unitPrice": {
"netValue": 294.118,
"grossValue": 350,
"taxValue": 55.882,
"taxCode": "STANDARD",
"taxRate": 19
},
"calculatedPrice": {
"price": {
"netValue": 588.235,
"grossValue": 700,
"taxValue": 111.765,
"taxCode": "STANDARD",
"taxRate": 19,
"calculated": "INTERNAL"
},
"finalPrice": {
"netValue": 588.235,
"grossValue": 700,
"taxValue": 111.765,
"taxCode": "STANDARD",
"taxRate": 19,
"calculated": "INTERNAL"
}
}
}
],
"calculatedPrice": {
"price": {
"netValue": 588.235,
"grossValue": 700,
"taxValue": 111.765
},
"finalPrice": {
"netValue": 588.235,
"grossValue": 700,
"taxValue": 111.765
}
}
}
}
]
}Last updated
Was this helpful?

