API reference · Inventory and Price
Update or Create Inventory in Bulk
- Method
- PUT
- Route
-
/v1/stock/batch - 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 or updates the inventory and price of up to 50 products per request, in your own store. Each item is processed independently: the result of each one comes in the status field of the response, and a rejected item does not block the others.
The store is always the one on the token. To send inventory for a branch, use Update or Create Inventory in Bulk for Branch.
Request body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
stockRequest |
array | Yes | From 1 to 50 items. |
stockRequest[].warehouseId |
integer | Yes | Warehouse where the inventory is allocated. |
stockRequest[].price |
number | Yes | Sale price. Cannot be negative. |
stockRequest[].quantity |
integer | Yes | Inventory quantity. Cannot be negative. |
stockRequest[].virtualQuantity |
integer | Yes | Virtual inventory. Cannot be negative. Send 0 when you do not work with virtual inventory. |
stockRequest[].leadTime |
integer | Yes | Preparation time in days. Cannot be negative. |
| Product identification — not a field, it is a group | — | Yes | One of the three combinations in the How to identify the product section: productId · brand + mfrPartCode + composition · skuAttributeName + skuAttributeValue. |
stockRequest[].byRequest |
boolean | No | Product available for quote only. |
stockRequest[].leadTimeByRequest |
boolean | No | Preparation time on request. See Lead time and virtual inventory. |
stockRequest[].leadTimeDate |
datetime | No | Expected product availability date. full ISO-8601 with time zone — 2026-09-10T00:00:00-03:00. See Availability date. |
stockRequest[].profitMargin |
number | No | Profit margin, from 0 to 100. |
stockRequest[].targetMargin |
number | No | Target margin, from 0 to 100. |
stockRequest[].totalCost |
number | No | Total cost of the item. Cannot be negative. |
stockRequest[].multipleQuantity |
integer | No | Sales multiple. 0 is normalized to 1. |
stockRequest[].partnerPartCode |
string | No | Your product code. |
stockRequest[].partnerPartCodeUnique |
boolean | No | Makes the partnerPartCode unique in the warehouse. See Unique product code in the warehouse. |
stockRequest[].priceRuleTags |
array | No | Price rule tags to link to the product: [{"name":"promocao"}]. A tag that does not exist in your store is ignored. |
stockRequest[].deleteTag |
boolean | No | true removes all price rule tags from the product, even if you send no new tag in priceRuleTags. If you send both, the old tags are removed and only those in priceRuleTags remain. |
How to identify the product
Each item must carry one of the three forms, in this order of precedence:
| Form | Fields | When to use |
|---|---|---|
| By id | productId |
You have already stored the SKU id on CWS. |
| By manufacturer data | brand + mfrPartCode + composition |
All three together; none identifies the product alone. composition accepts UNITARY, PAIR, KIT, WARRANTY and SET, always in uppercase. |
| By attribute | skuAttributeName + skuAttributeValue |
You contracted the product catalog service with a custom attribute. |
All items in the same batch must use the same form. Mixing forms in one request rejects the entire batch with 400 and the message mixed request types in list — split it into one request per form.
Business rules
Lead time and virtual inventory
Two combinations are rejected: leadTimeByRequest: true together with leadTime greater than zero; and leadTimeByRequest: false with leadTime zero or missing when virtualQuantity is greater than zero.
Availability date
leadTimeDate is converted to the platform time zone (-03:00) before being saved — 2026-09-10T00:00:00Z becomes 09/09 at 21:00, one day earlier than you intended. Always send it with the -03:00 offset.
The format must be the full date and time: 2026-09-10 or 10/09/2026 reject the entire request with 400, before any item is processed.
With the date filled in and the real quantity at zero, virtual inventory starts being offered — the same effect as leadTime and leadTimeByRequest.
The submission is always complete
On update, the optional fields you do not resend are erased: leadTimeDate, leadTimeByRequest, profitMargin, totalCost and targetMargin go back to empty. partnerPartCode and multipleQuantity do not behave this way — they only change when you send them. Resend the whole item on every update.
Repeated items in the same batch
Items with the same warehouse and the same identifier are deduplicated before processing. If the duplicates carry different values, the conflict is not processed — send each product only once per request.
Unique product code in the warehouse
With partnerPartCodeUnique: true, inventories in the same warehouse that already have that code saved in partnerPartCode are zeroed (price, quantity and virtual inventory) and the old code receives the suffix _i. Use it when you reuse a product code for another SKU.
Response · 200
A list with one object per item sent, in the same order as submitted. Zeroed or empty fields are omitted — if virtualQuantity comes back absent, it is 0.
| Field | Description |
|---|---|
id |
Id of the inventory created or updated. Comes as 0 when the item failed. |
productId |
SKU id resolved by the platform. |
warehouseId |
Warehouse of the item. |
price |
Saved price. |
status |
CREATED · UPDATED · ERROR |
error |
Reason for the rejection. Present only when status is ERROR. |
quantity · virtualQuantity · leadTime · byRequest · leadTimeByRequest · leadTimeDate |
Saved values. Omitted when zero, false or absent. |
brand · mfrPartCode · composition · skuAttributeName · skuAttributeValue |
Echo of the identification fields you sent. Omitted when not used. |
partCode |
Echo of the partnerPartCode you sent — in the response it comes back under this name. |
profitMargin · targetMargin · totalCost · multipleQuantity |
Saved values, when sent. |
priceRuleTags · deleteTag |
Tags applied and the removal request, when used. |
When the batch responds 200
Whenever the envelope is valid — including when all items failed. A rejected item does not block the others: the result of each one comes in its own status, and a rejection for a missing field, an out-of-range value or a product not found appears as status: ERROR with the reason in error. Always go through the whole list, even with HTTP 200.
Errors
| Code | When |
|---|---|
| 400 | The body is not valid JSON. The detail comes in error. |
| 400 | A failure that affects the entire batch: mixed identification forms (mixed request types in list) or the warehouse provided does not belong to your store. Here the envelope is different from the rest — code, message and errorDescription — instead of error. Handle both formats. |
| 422 | Envelope problem: stockRequest empty or with more than 50 items. The detail comes in error. |
| 401 | Token missing, malformed or expired. |
An item rejection — missing field, out-of-range value, nonexistent product — is not a request error: it comes in 200, item by item. See When the batch responds 200.
Example request
curl --request PUT 'https://ws.autorei.net/v1/stock/batch' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
"stockRequest": [
{
"skuAttributeName": "codigo-interno",
"skuAttributeValue": "SKU-A-001",
"warehouseId": 1001,
"price": 58.62,
"quantity": 1123,
"virtualQuantity": 0,
"leadTime": 2
},
{
"skuAttributeName": "codigo-interno",
"skuAttributeValue": "SKU-B-002",
"warehouseId": 1001,
"price": 150.0,
"quantity": 5,
"virtualQuantity": 0,
"leadTime": 2
}
]
}' Example responses
200Success — identification by manufacturer data
[
{
"id": 4410001,
"productId": 500101,
"warehouseId": 1001,
"brand": "Fabricante Exemplo",
"mfrPartCode": "FE-500101",
"composition": "UNITARY",
"price": 58.62,
"quantity": 1123,
"leadTime": 2,
"status": "UPDATED"
}
] 200Success — identification by attribute, with a rejected item in the batch
[
{
"id": 4410001,
"productId": 500101,
"warehouseId": 1001,
"skuAttributeName": "codigo-interno",
"skuAttributeValue": "SKU-A-001",
"price": 58.62,
"quantity": 1123,
"leadTime": 2,
"status": "UPDATED"
},
{
"id": 0,
"warehouseId": 1001,
"price": 0,
"quantity": 5,
"status": "ERROR",
"error": "price is required; virtualQuantity is required; leadTime is required; missing product identifier: provide productId OR (brand+mfrPartCode+composition) OR (skuAttributeName+skuAttributeValue)"
}
] 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 casesB2B procurement and supplies: the typical path through the API
- Get startedPagination and limits
- Get startedErrors
Related endpoints
Generated from the public API collection, published on 2026-09-04: api-docs.cws.digital.