Promotion Codes
You can enable a mini cart view in the following requests to show changes to the cart immediately. Find out more in the Views for Cart modifying operations
Prerequisites
access_token
from Headless API AuthenticationcartId
from Create a CartpriceGroupId
from Price Groups (string)cultureCode
, e.g.en-US
(string)
Add Promotion Codes
Request
curl -D- -X POST <base_url>/api/v1/carts/<cartId>/promotion-codes/<code> \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
-d '{
"priceGroupId": "<priceGroupId>",
"cultureCode": "<CultureCode>"
}'
Response
{
"promotionCodes": [
{
"code": "{promotionCode}",
}
]
}
Get Promotion Codes
Request
curl -D- -X GET <base_url>/api/v1/carts/<cartId>/promotion-codes \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
Response
{
"promotionCodes": [
{
"code": "{promotionCode}",
}
]
}
Remove Promotion Codes
Request
curl -D- -X DELETE <base_url>/api/v1/carts/<cartId>/promotion-codes/<code> \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
-d '{
"priceGroupId": "<priceGroupId>",
"cultureCode": "<cultureCode>"
}'
Response
{
"promotionCodes": [
]
}
Error Handling
Error
Description
BadRequest (400)
PriceGroup does not exist.
NotFound (404)
Cart not found; Promotion Code not found.
Error Response Example
{
"errors":
[
{
"error-description": "AccessToken not found, access denied.",
"error": "BadRequest"
}
]
}
Related Articles
Error HandlingLast updated
Was this helpful?