> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/api-references/readme/api-reference-5/discounts.md).

# Discounts

Manage Discounts

## Returning all discounts from the cart

> Returns all discounts of the specified cart.

```json
{"openapi":"3.0.0","info":{"title":"Cart Service","version":"0.0.1"},"tags":[{"name":"Discounts","description":"Manage Discounts"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["cart.cart_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"cart.cart_manage":"Needed to manage carts. This scope is only required for OAuth2 authorization method to authorize the request with the `access_token`.","cart.cart_manage_external_prices":"Needed to manage external prices, products, fees and discounts. It's required only when an external price, product, fee or discount is provided."}}}}},"schemas":{"discountResponse":{"description":"Discount details.","type":"object","properties":{"id":{"type":"string","description":"Discount's unique identifier."},"yrn":{"$ref":"#/components/schemas/YRN"},"couponYrn":{"$ref":"#/components/schemas/YRN"},"code":{"maxLength":150,"description":"Discount code generated when a discount coupon is created through the Coupon Service.","type":"string"},"amount":{"type":"number","minimum":0,"description":"Discount expressed as fixed amount.","format":"double"},"currency":{"type":"string","pattern":"[A-Z]{3}","description":"Three-letter currency code, compliant with the ISO 4217 standard.","minLength":3,"maxLength":3},"discountRate":{"type":"number","minimum":0,"description":"Discount expressed as a percentage of the price.","format":"double"},"name":{"maxLength":150,"description":"Discount's displayed name.","type":"string"},"calculationType":{"type":"string","maxLength":30,"default":"ApplyDiscountBeforeTax","description":"Calculation type specifies how the discount should be calculated. Can be set to one of the following:\n* `ApplyDiscountBeforeTax`\n* `ApplyDiscountAfterTax`","enum":["ApplyDiscountBeforeTax","ApplyDiscountAfterTax"]},"discountCalculationType":{"type":"string","description":"Determines whether the coupon is applied to the total or subtotal value of the order.","enum":["SUBTOTAL","TOTAL"]},"valid":{"default":true,"description":"Flag indicating whether the discount is valid. \nInvalid discounts are not taken into account when the cart is calculated.","type":"boolean"},"links":{"minItems":2,"type":"array","description":"Links to Coupon Service endpoints used to validate and redeem the discount.","items":{"$ref":"#/components/schemas/link"}},"discountValidationDetails":{"$ref":"#/components/schemas/discountValidationDetails"},"vendorRestricted":{"type":"boolean","default":false,"description":"Indicates whether the discount is limited to the vendors in `restrictions.vendors`."},"restrictions":{"$ref":"#/components/schemas/discountRestrictions"},"discountIndex":{"type":"integer","description":"The index of the discount. It represents the discount position in the cart discounts array."}},"required":["code"]},"YRN":{"type":"string","title":"YRN","description":"A unique identifier of a global resource, which stores information about the resource, such as its type, ID or name of the tenant.","minLength":1},"link":{"description":"","type":"object","properties":{"rel":{"type":"string","maxLength":50,"description":"Action to be done using the endpoint provided in the `href` field.","enum":["validate","redeem"]},"title":{"maxLength":100,"description":"Detailed link description.","type":"string"},"href":{"type":"string","maxLength":2000,"description":"Endpoint used to validate or redeem the discount."},"type":{"type":"string","maxLength":500,"description":"Content type."}},"required":["rel","href","type"]},"discountValidationDetails":{"description":"","type":"object","properties":{"message":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}},"discountRestrictions":{"description":"Restrictions copied from the coupon.","type":"object","properties":{"validFrom":{"type":"string","description":"Start of the discount validity period."},"validUntil":{"type":"string","description":"End of the discount validity period."},"minOrderValue":{"allOf":[{"$ref":"#/components/schemas/price"},{"description":"Minimum order value copied from the coupon. When `vendorRestricted` is `true`, this value is checked against the total of the matching vendor items."}]},"includedCategories":{"type":"array","description":"Categories to which the discount applies.","items":{"type":"string"}},"excludedCategories":{"type":"array","description":"Categories to which the discount does not apply.","items":{"type":"string"}},"segments":{"type":"array","description":"Customer segments to which the discount applies.","items":{"type":"string"}},"vendors":{"type":"array","description":"Vendor identifiers to which the discount applies.","items":{"type":"string"}}}},"price":{"type":"object","properties":{"amount":{"type":"number","minimum":0,"format":"double","description":"Price."},"currency":{"type":"string","pattern":"[A-Z]{3}","minLength":3,"maxLength":3,"description":"Three-letter currency code, compliant with the ISO 4217 standard."}},"required":["amount","currency"],"description":""},"ErrorMessage":{"title":"error","description":"Schema for API-specific errors.","type":"object","properties":{"code":{"description":"Original HTTP error code. It should be consistent with the HTTP response code.","type":"integer"},"status":{"description":"HTTP Status","type":"string"},"message":{"description":"Descriptive error message for debugging purposes.","type":"string"}}}},"responses":{"trait_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_notFound_404":{"description":"The requested resource does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_500":{"description":"Some server-side error occurred. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}}},"paths":{"/cart/{tenant}/carts/{cartId}/discounts":{"get":{"tags":["Discounts"],"summary":"Returning all discounts from the cart","operationId":"GET-cart-list-all-discounts","responses":{"200":{"description":"The request was successful. Cart discounts items are returned.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/discountResponse"}}}}},"403":{"$ref":"#/components/responses/trait_403"},"404":{"$ref":"#/components/responses/trait_notFound_404"},"500":{"$ref":"#/components/responses/trait_500"}},"description":"Returns all discounts of the specified cart."}}}}
```

## Applying a discount to cart

> Applies a discount on the specified cart. Multiple discount coupons can be applied to cart, but you need to send a separate request for each discount coupon.

```json
{"openapi":"3.0.0","info":{"title":"Cart Service","version":"0.0.1"},"tags":[{"name":"Discounts","description":"Manage Discounts"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["cart.cart_manage"]},{"CustomerAccessToken":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"cart.cart_manage":"Needed to manage carts. This scope is only required for OAuth2 authorization method to authorize the request with the `access_token`.","cart.cart_manage_external_prices":"Needed to manage external prices, products, fees and discounts. It's required only when an external price, product, fee or discount is provided."}}}},"CustomerAccessToken":{"type":"http","scheme":"bearer"}},"schemas":{"appliedDiscount":{"type":"object","properties":{"yrn":{"$ref":"#/components/schemas/YRN"},"discountId":{"type":"string","format":"double"},"discountIndex":{"type":"integer","description":"The index of the discount that represents the number in the discounts array. It can be used for the discount removal from the cart."}},"required":["yrn","discountId","discountIndex"]},"YRN":{"type":"string","title":"YRN","description":"A unique identifier of a global resource, which stores information about the resource, such as its type, ID or name of the tenant.","minLength":1},"ErrorMessage":{"title":"error","description":"Schema for API-specific errors.","type":"object","properties":{"code":{"description":"Original HTTP error code. It should be consistent with the HTTP response code.","type":"integer"},"status":{"description":"HTTP Status","type":"string"},"message":{"description":"Descriptive error message for debugging purposes.","type":"string"}}},"discount":{"description":"","type":"object","title":"","properties":{"id":{"type":"string","description":"Discount unique identifier."},"couponYrn":{"$ref":"#/components/schemas/YRN"},"code":{"type":"string","maxLength":150,"description":"Discount code generated when a discount coupon is created through the Coupon Service.","minLength":1},"currency":{"type":"string","pattern":"[A-Z]{3}","description":"Three-letter currency code, compliant with the ISO 4217 standard.","minLength":3,"maxLength":3},"amount":{"type":"number","minimum":0,"description":"Discount expressed as fixed amount.","format":"double"},"name":{"maxLength":150,"description":"Discount displayed name.","type":"string"},"discountRate":{"type":"number","minimum":0,"description":"Discount expressed as a percentage of the price.","format":"double"},"discountCalculationType":{"type":"string","default":"SUBTOTAL","description":"Determines whether the coupon is applied to the total or subtotal value of the order.","enum":["SUBTOTAL","TOTAL"]},"links":{"minItems":2,"type":"array","description":"Links to Coupon Service endpoints used to validate and redeem the discount.","items":{"$ref":"#/components/schemas/link"}},"calculationType":{"type":"string","maxLength":30,"default":"ApplyDiscountBeforeTax","deprecated":true,"enum":["ApplyDiscountBeforeTax","ApplyDiscountAfterTax"],"description":"Calculation type specifies how the discount should be calculated. It can be set to one of the following:\n* `ApplyDiscountBeforeTax`\n* `ApplyDiscountAfterTax`\n\nThe field is **deprecated** and is not used in calculatedPrice fields. The calculated price takes into account site's settings\nwhere:\n* `includesTax=true` results in `ApplyDiscountAfterTax`\n* `includesTax=false` results in `ApplyDiscountBeforeTax`"}},"required":["code"]},"link":{"description":"","type":"object","properties":{"rel":{"type":"string","maxLength":50,"description":"Action to be done using the endpoint provided in the `href` field.","enum":["validate","redeem"]},"title":{"maxLength":100,"description":"Detailed link description.","type":"string"},"href":{"type":"string","maxLength":2000,"description":"Endpoint used to validate or redeem the discount."},"type":{"type":"string","maxLength":500,"description":"Content type."}},"required":["rel","href","type"]}},"responses":{"trait_400":{"description":"The request was syntactically incorrect. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired.\n\nDetails will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_notFound_404":{"description":"The requested resource does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_add_discount_conflict_409":{"description":"The request could not be completed due to a conflict with the current state of the target resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"parameters":{"trait_tenant":{"name":"tenant","in":"path","required":true,"description":"Your Emporix tenant name.\n\n**Note**: The tenant should always be written in lowercase.\n","schema":{"pattern":"^[a-z][a-z0-9]+$","minLength":3,"maxLength":16,"type":"string"}}}},"paths":{"/cart/{tenant}/carts/{cartId}/discounts":{"post":{"tags":["Discounts"],"responses":{"201":{"description":"The request was successful. The discount has been applied to cart.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/appliedDiscount"}}},"headers":{"Location":{"description":"Location of the newly created discount.","schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/trait_400"},"401":{"$ref":"#/components/responses/trait_401"},"403":{"$ref":"#/components/responses/trait_403"},"404":{"$ref":"#/components/responses/trait_notFound_404"},"409":{"$ref":"#/components/responses/trait_add_discount_conflict_409"},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"description":"","type":"object","properties":{"code":{"type":"number","description":"Original HTTP error code. It should be consistent with the HTTP response code."},"status":{"type":"string","minLength":1,"description":"Classification of the error."},"message":{"type":"string","minLength":1,"description":"Descriptive error message for debugging purposes."}}}}}}},"description":"Applies a discount on the specified cart. Multiple discount coupons can be applied to cart, but you need to send a separate request for each discount coupon.","operationId":"POST-cart-apply-discount","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/discount"}}},"required":false},"parameters":[{"$ref":"#/components/parameters/trait_tenant"}],"summary":"Applying a discount to cart"}}}}
```

## Removing all discounts from cart

> Removes all discounts applied to the specified cart.

```json
{"openapi":"3.0.0","info":{"title":"Cart Service","version":"0.0.1"},"tags":[{"name":"Discounts","description":"Manage Discounts"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["cart.cart_manage"]},{"CustomerAccessToken":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"cart.cart_manage":"Needed to manage carts. This scope is only required for OAuth2 authorization method to authorize the request with the `access_token`.","cart.cart_manage_external_prices":"Needed to manage external prices, products, fees and discounts. It's required only when an external price, product, fee or discount is provided."}}}},"CustomerAccessToken":{"type":"http","scheme":"bearer"}},"responses":{"trait_400":{"description":"The request was syntactically incorrect. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired.\n\nDetails will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_notFound_404":{"description":"The requested resource does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_500":{"description":"Some server-side error occurred. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"schemas":{"ErrorMessage":{"title":"error","description":"Schema for API-specific errors.","type":"object","properties":{"code":{"description":"Original HTTP error code. It should be consistent with the HTTP response code.","type":"integer"},"status":{"description":"HTTP Status","type":"string"},"message":{"description":"Descriptive error message for debugging purposes.","type":"string"}}}},"parameters":{"trait_tenant":{"name":"tenant","in":"path","required":true,"description":"Your Emporix tenant name.\n\n**Note**: The tenant should always be written in lowercase.\n","schema":{"pattern":"^[a-z][a-z0-9]+$","minLength":3,"maxLength":16,"type":"string"}}}},"paths":{"/cart/{tenant}/carts/{cartId}/discounts":{"delete":{"tags":["Discounts"],"responses":{"204":{"description":"The request was successful. Discounts have been removed."},"400":{"$ref":"#/components/responses/trait_400"},"401":{"$ref":"#/components/responses/trait_401"},"403":{"$ref":"#/components/responses/trait_403"},"404":{"$ref":"#/components/responses/trait_notFound_404"},"500":{"$ref":"#/components/responses/trait_500"}},"description":"Removes all discounts applied to the specified cart.","operationId":"DELETE-cart-remove-all-discounts","parameters":[{"$ref":"#/components/parameters/trait_tenant"},{"schema":{"type":"string"},"in":"query","name":"codes","description":"Discount codes, listed with commas, specify the discounts slated for deletion. If no codes are provided, all discounts will be removed."}],"summary":"Removing all discounts from cart"}}}}
```

## Removing a discount from cart

> Delete the discount in the cart by the provided discount Index.

```json
{"openapi":"3.0.0","info":{"title":"Cart Service","version":"0.0.1"},"tags":[{"name":"Discounts","description":"Manage Discounts"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["cart.cart_manage"]},{"CustomerAccessToken":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"cart.cart_manage":"Needed to manage carts. This scope is only required for OAuth2 authorization method to authorize the request with the `access_token`.","cart.cart_manage_external_prices":"Needed to manage external prices, products, fees and discounts. It's required only when an external price, product, fee or discount is provided."}}}},"CustomerAccessToken":{"type":"http","scheme":"bearer"}},"responses":{"trait_400":{"description":"The request was syntactically incorrect. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired.\n\nDetails will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"trait_notFound_404":{"description":"The requested resource does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"schemas":{"ErrorMessage":{"title":"error","description":"Schema for API-specific errors.","type":"object","properties":{"code":{"description":"Original HTTP error code. It should be consistent with the HTTP response code.","type":"integer"},"status":{"description":"HTTP Status","type":"string"},"message":{"description":"Descriptive error message for debugging purposes.","type":"string"}}}},"parameters":{"trait_tenant":{"name":"tenant","in":"path","required":true,"description":"Your Emporix tenant name.\n\n**Note**: The tenant should always be written in lowercase.\n","schema":{"pattern":"^[a-z][a-z0-9]+$","minLength":3,"maxLength":16,"type":"string"}}}},"paths":{"/cart/{tenant}/carts/{cartId}/discounts/{discountIndex}":{"delete":{"tags":["Discounts"],"responses":{"204":{"description":"The request was successful. The discount has been removed from cart."},"400":{"$ref":"#/components/responses/trait_400"},"401":{"$ref":"#/components/responses/trait_401"},"403":{"$ref":"#/components/responses/trait_403"},"404":{"$ref":"#/components/responses/trait_notFound_404"},"500":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"description":"Delete the discount in the cart by the provided discount Index.","operationId":"DELETE-cart-remove-discount","parameters":[{"$ref":"#/components/parameters/trait_tenant"}],"summary":"Removing a discount from cart"}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.emporix.io/api-references/readme/api-reference-5/discounts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
