API reference · Contracts
Create Branch Contract
https://api.sandbox.cws.digital/priceContract/store/{partnerId}Description
Allows a parent account to create a price contract in one of its branches.
The creation stores the contract header — validity period, scope and application filters. Customers and products come in later, through Add Customers to the Branch Contract and Add Products to the Branch Contract.
The body and the response are identical to those of the creation in your own store — the difference is the branch that owns the contract, which comes in the route and is validated against the links of your parent account.
Parameters
Path parameters
| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| partnerId | integer | Yes | Id of the branch that owns the contract. It must be linked to the token's parent account. |
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.
Responses
- 400
The route
partnerIdis not numeric. - 403
Branch not linked to your parent account.