API reference · Price Rule
Create Price Rule
- Method
- POST
- Route
-
/v1/priceRule - Base URL
https://ws.autorei.net- Token
- Requires Bearer token
Opens this request in the public API documentation, the official source of the reference.
Description
Creates a price rule in your store. The rule is evaluated in every price quote: when the product and the customer meet all the configured criteria, the value is applied.
Request body (JSON)
Numbers and booleans are also accepted as strings ("priority": "10", "cumulative": "true").
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Rule name. Cannot be empty. |
priority |
integer | Yes | Application priority: lower number, higher priority. |
type |
string | Yes | PERCENT for percentage, REAL for value in reais. No other value is accepted. |
value |
number | Yes | Negative for discount, positive for surcharge. |
cumulative |
boolean | Yes | true allows this rule to be added to others. |
customerHasStateRegistration |
boolean | Yes | true applies only to customers with a state registration. |
quantity |
integer | No | Minimum quantity of the item in the quote for the rule to apply. Only has effect above 1. |
customerState |
string | No | State (UF) of the quote address. |
warehouseState |
string | No | State (UF) of the warehouse. |
customerCnae |
string | No | Applies only to customers with this CNAE. A customer without CNAE does not receive the rule. |
customerTypeId |
integer | No | Applies only to the customer type informed. |
customerTagId |
integer | No | Applies only to customers with this tag. The tag must belong to your store. |
customerPaysIcms |
boolean | No | true applies only to customers who are ICMS taxpayers. |
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 inventory informed. |
skuNcm |
string | No | Applies only to products with this NCM. A product without NCM does not receive the rule. |
promotionalBeforeAfter |
boolean | No | Marks the rule as promotional, for "from/to" price display. Changes the evaluation order: promotional rules are evaluated after regular ones. |
Business rules
A configured criterion is a required criterion
Each optional field you fill in narrows the rule: it is only applied 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's value would take the price to zero or to a negative number, it is ignored in the quote — the price does not go negative and no error is generated.
Order of application
First the non-promotional rules, then the non-cumulative ones, then the priority (lowest first) and, on a tie, the oldest.
Response · 201
The rule created. The code is 201 Created, not 200. promotionalBeforeAfter is saved, but does not come back in the response.
| Field | Type | Description |
|---|---|---|
id |
integer | Rule id. It is what you use to deactivate it. |
name |
string | Rule name. |
priority |
integer | Application priority. |
type |
string | PERCENT or REAL. |
value |
number | Value applied. |
cumulative |
boolean | Whether the rule can be added to others. |
stateRegistration |
boolean | Corresponds to the customerHasStateRegistration you sent — the field changes name in the response. |
quantity |
integer | Minimum quantity of the item. null when not used. |
warehouseState · customerState |
string | States (UF) configured in the rule. null when not used. |
customerTagId · customerTypeId · customerCnae · customerPaysIcms |
— | Configured customer criteria. |
customerTypeName |
string | Customer type name. Comes as "" when the rule does not use customerTypeId. |
skuStockId · skuPartnerTagId · skuNcm |
— | Configured product criteria. |
isDiscountBlockedByAttendant |
boolean | Whether the rule blocks the attendant's discount in the cart. |
createdBy |
string | E-mail of the user who created the rule, resolved from your token. |
Errors
| Code | When |
|---|---|
| 422 | Required field missing ({"error":"cumulative is required"}), type outside PERCENT/REAL ({"error":"invalid type"}) or body that cannot be parsed ({"error":"invalid request body: ..."}). |
| 404 | customerTagId or skuPartnerTagId that does not belong to your store: {"error":"Tag de produto não encontrada"}. Same response as for a nonexistent tag. |
| 401 | Token missing, malformed or expired. |
Example request
curl --request POST 'https://ws.autorei.net/v1/priceRule' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
"name": "Desconto Atacado",
"priority": 10,
"type": "PERCENT",
"value": -5,
"cumulative": false,
"customerHasStateRegistration": false,
"quantity": 100
}' Example responses
201Success — percentage discount
{
"id": 4210001,
"name": "Desconto Atacado",
"priority": 10,
"type": "PERCENT",
"value": -5,
"cumulative": false,
"stateRegistration": false,
"isDiscountBlockedByAttendant": false,
"quantity": 100,
"warehouseState": null,
"customerState": null,
"customerTagId": null,
"customerCnae": null,
"customerTypeId": null,
"customerTypeName": "",
"customerPaysIcms": false,
"skuNcm": null,
"skuStockId": null,
"skuPartnerTagId": null,
"createdBy": "integracao@lojaexemplo.com.br"
} Used in
- Use casesEcommerce ERP integration: the typical path through the API
- Use casesB2B customer portal: the typical path through the API
- Use casesB2B marketplace: the typical path through the API
- Use casesComplex retail and B2B2C: the typical path through the API
- Use casesGuided selling and counter sales: the typical path through the API
Related endpoints
Generated from the public API collection, published on 2026-09-04: api-docs.cws.digital.