API reference · Contracts
Create Contract
https://api.sandbox.cws.digital/priceContractDescription
Creates a price contract: the table of special prices that the store applies to a set of customers during a period.
The creation stores the contract header — validity period, scope and application filters. Customers and products come in later, through Add Customers to the Contract and Add Products to the Contract.
The store is always the token's store. To create the contract of a branch, use Create Branch Contract.
Request body
application/jsonRequired| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| name | string | Yes | Contract name. | |
| startDate | string | Yes | Start of the validity period, in the format | |
| endDate | string | Yes | End of the validity period, in the format | |
| allCustomers | boolean | Yes |
| |
| allPartners | boolean | Yes |
| |
| active | boolean | No | Active contract. Default | |
| priority | integer | No | Priority in the dispute between contracts. Default | |
| contractType | string | No |
| |
| priceBeforeAfter | boolean | No |
| |
| isDiscountBlockedByAttendant | boolean | No |
| |
| stateList | array of string | No | Abbreviations of the Brazilian states where the contract applies, with two uppercase letters: | Separate values with commas or line breaks. |
| storeList | array of integer | No | Ids of the stores where the contract applies. Without the list, it applies in any store. | Separate values with commas or line breaks. |
| partners | array of integer | No | Ids of the branches where the contract applies. Ignored when | Separate values with commas or line breaks. |
| customerGroupList | array of object | No | Customer groups (price types) that the contract reaches. Fields in customerGroupList[] |
customerGroupList[]| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| externalId | string | Yes | Id of the group in your system, resolved to the platform id. |
Business rules
Customer scope
allCustomers: true applies the contract to all customers of the store, and the contract starts rejecting the addition of individual customers with 400.
With allCustomers: false, the contract applies only to the customers you add later, one by one.
Which contract wins
When more than one active contract reaches the same product for the same customer, the one with the highest priority wins. With tied priority, the contract restricted to specific customers wins over the one that applies to all customers. If the tie persists, the oldest contract wins.
Countdown offer
contractType: COUNTDOWN marks the contract as a countdown offer: the returned price starts carrying the discount and the end date of the offer.
The countdown contract only enters the price calculation with priceBeforeAfter: true.