API reference · Contracts · Store Management
Create Contract
- Method
- POST
- Route
-
/priceContract - 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 contract: the special price table that the store applies to a set of customers during a period. Creation stores the contract header — validity, scope and application filters. Customers and products are added afterwards, through Add Customers to Contract and Add Products to Contract.
The store is always the one in the token. To create a branch's contract, use Create Branch Contract.
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Contract name. |
startDate |
datetime | Yes | Start of validity. See Accepted date formats. |
endDate |
datetime | Yes | End of validity. Must be equal to or later than startDate. |
allCustomers |
boolean | Yes | true applies the contract to all customers of the store. See Customer scope. |
allPartners |
boolean | Yes | true applies the contract to all branches of the store. With true, partners is ignored. |
active |
boolean | No | Active contract. Default true. Only an active contract within its validity enters the price calculation. |
priority |
integer | No | Priority when contracts compete. Default 0. See Which contract wins. |
contractType |
string | No | BASIC (default) or COUNTDOWN. See Countdown offer. |
priceBeforeAfter |
boolean | No | true returns the product's list price as the previous price, for the "was/now" display. See Countdown offer. |
isDiscountBlockedByAttendant |
boolean | No | true prevents the sales rep from giving a discount on the contract price in the cart. |
stateList |
array | No | State codes (UFs) where the contract is valid, with two uppercase letters: ["SP","MG"]. Without the list, the contract is valid in any state. |
storeList |
array | No | Ids of the stores where the contract is valid. Without the list, it is valid in any store. |
partners |
array | No | Ids of the branches where the contract is valid. Ignored when allPartners is true. |
customerGroupList |
array | No | Customer groups (price types) that the contract reaches. |
customerGroupList[].externalId |
string | Yes | Group id in your system, resolved to the platform id. |
Accepted date formats
startDate and endDate accept four formats: 2026-09-01, 2026-09-01 08:30, 2026-09-01T08:30:00 and 2026-09-01T08:30:00Z. If only the date is sent, the validity starts and ends at midnight.
Business rules
Customer scope
allCustomers: true applies the contract to all customers of the store, and the contract starts rejecting the addition of an individual customer with 400. With allCustomers: false, the contract is valid only for the customers you add afterwards, 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. If the priority is tied, 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 to carry the discount and the end date of the offer. The countdown contract only enters the price calculation with priceBeforeAfter: true.
Response · 200
| Field | Description |
|---|---|
id |
Id of the contract created. It is the one that goes in the path of the other contract endpoints. |
name |
Stored name. |
active |
Active contract. |
partner.id |
Id of the partner that owns the contract. |
partner.name · partner.document |
Name and document of the partner that owns the contract. |
allCustomers · allPartners |
Stored scope. |
priority |
Stored priority. |
dateStart · dateEnd |
Stored validity, in UTC. |
dateCreated · lastUpdated |
Creation and last change, in UTC. |
priceBeforeAfter |
Previous price enabled. Comes back null when you do not send the field. |
contractType |
Stored type. |
isDiscountBlockedByAttendant |
Stored discount block. |
priceContractPartners |
Ids of the branches stored from partners. |
priceContractStates |
States stored from stateList. |
priceContractCustomerGroups |
Ids of the customer groups stored from customerGroupList. |
priceContractStores |
Ids of the stores stored from storeList. |
Errors
| Code | When |
|---|---|
| 400 | The body is not valid JSON. The detail comes in error. |
| 422 | Empty body, missing required field (name, startDate, endDate, allCustomers, allPartners), date in an unaccepted format or endDate earlier than startDate. The detail comes in error. |
| 401 | Token missing, malformed or expired. |
Example request
curl --request POST 'https://ws.autorei.net/priceContract' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
"name": "Tabela Atacado 2026",
"startDate": "2026-09-01",
"endDate": "2026-12-31",
"allCustomers": false,
"allPartners": false,
"active": true,
"priority": 10,
"contractType": "BASIC",
"isDiscountBlockedByAttendant": false,
"stateList": [
"SP",
"MG"
],
"customerGroupList": [
{
"externalId": "GRUPO-ATACADO"
}
]
}' Example responses
200Success — contract created
{
"id": 4610001,
"name": "Tabela Atacado 2026",
"active": true,
"partner": {
"id": 5050,
"name": "Loja Exemplo",
"document": "30.424.972/0001-74"
},
"allCustomers": false,
"allPartners": false,
"priority": 10,
"dateStart": "2026-09-01T00:00:00Z",
"dateEnd": "2026-12-31T00:00:00Z",
"dateCreated": "2026-09-04T13:22:32.687284Z",
"lastUpdated": "2026-09-04T13:22:32.687284Z",
"priceBeforeAfter": null,
"contractType": "BASIC",
"isDiscountBlockedByAttendant": false,
"priceContractPartners": [],
"priceContractStates": [
"SP",
"MG"
],
"priceContractCustomerGroups": [
4610101
],
"priceContractStores": []
} 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 casesB2B procurement and supplies: 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.