API reference · Price Rule

Create Price Rule

POSThttps://api.sandbox.cws.digital/v1/priceRule

Description

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

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
namestringYes

Rule name. Cannot be empty.

priorityintegerYes

Application priority: lower number, higher priority.

typestringYes

PERCENT for a percentage, REAL for a value in reais. No other value is accepted.

Allowed values:PERCENTREAL
valuenumberYes

Negative for a discount, positive for a surcharge.

cumulativebooleanYes

true allows this rule to be added to others.

customerHasStateRegistrationbooleanYes

true applies only to customers with a state registration.

quantityintegerNo

Minimum item quantity in the quotation for the rule to apply. Only has effect above 1.

customerStatestringNo

State (UF) of the quotation address.

warehouseStatestringNo

State (UF) of the warehouse.

customerCnaestringNo

Applies only to customers with this CNAE. A customer without a CNAE does not get the rule.

customerTypeIdintegerNo

Applies only to the given customer type.

customerTagIdintegerNo

Applies only to customers with this tag. The tag must belong to your store.

customerPaysIcmsbooleanNo

true applies only to customers that are ICMS taxpayers.

skuPartnerTagIdintegerNo

Applies only to products with this price tag. The tag must belong to your store.

skuStockIdintegerNo

Applies only to the given stock.

skuNcmstringNo

Applies only to products with this NCM. A product without an NCM does not get the rule.

promotionalBeforeAfterbooleanNo

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.

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request POST \
  --url 'https://api.sandbox.cws.digital/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
}'

Response

Click Try it to see the real response here, or pick a documented example: