API reference · Price Rule
Create Price Rule
https://api.sandbox.cws.digital/v1/priceRuleDescription
Creates a price rule for your store.
The rule starts being evaluated in every price quotation: when the product and the customer meet all the configured criteria, the value is applied.
Numbers and booleans are also accepted as strings ("priority": "10", "cumulative": "true").
Request body
application/jsonRequired| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| name | string | Yes | Rule name. Cannot be empty. | |
| priority | integer | Yes | Application priority: lower number, higher priority. | |
| type | string | Yes |
Allowed values: PERCENTREAL | |
| value | number | Yes | Negative for a discount, positive for a surcharge. | |
| cumulative | boolean | Yes |
| |
| customerHasStateRegistration | boolean | Yes |
| |
| quantity | integer | No | Minimum item quantity in the quotation for the rule to apply. Only has effect above 1. | |
| customerState | string | No | State (UF) of the quotation address. | |
| warehouseState | string | No | State (UF) of the warehouse. | |
| customerCnae | string | No | Applies only to customers with this CNAE. A customer without a CNAE does not get the rule. | |
| customerTypeId | integer | No | Applies only to the given customer type. | |
| customerTagId | integer | No | Applies only to customers with this tag. The tag must belong to your store. | |
| customerPaysIcms | boolean | No |
| |
| skuPartnerTagId | integer | No | Applies only to products with this price tag. The tag must belong to your store. | |
| skuStockId | integer | No | Applies only to the given stock. | |
| skuNcm | string | No | Applies only to products with this NCM. A product without an NCM does not get the rule. | |
| promotionalBeforeAfter | boolean | No | Marks the rule as promotional, for "from/to" price display. It changes the evaluation order: promotional rules are evaluated after the regular ones. |
Business rules
A configured criterion is a required criterion
Each optional field you fill in narrows the rule: it is applied only when the product and the customer meet all of them. Leave out what is not a condition.
A rule that would zero the price is not applied
If the rule value would take the price to zero or to a negative number, the rule is ignored in the quotation — the price does not become negative and no error is raised.
Order of application
First the non-promotional rules, then the non-cumulative ones, then by priority (lowest first) and, on a tie, the one that makes the price cheapest.
Responses
- 401
Missing, malformed or expired token.