API reference · Inventory and Price
Update or Create Batch Inventory for Branch
- Method
- PUT
- Route
-
/v1/stock/batch/:partnerId - Base URL
https://ws.autorei.net- Path parameters
:partnerId- Token
- Requires Bearer token
Opens this request in the public API documentation, the official source of the reference.
Description
Allows a head office account to create or update the inventory and price of up to 50 products per request in one of its branches. 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 body and the response are identical to those of the submission to the store itself — the difference is the target branch, which comes in the path and is validated against the links of your head office.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
partnerId |
integer | Yes | Id of the branch that will receive the inventory. It must be linked to the head office of the token. |
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 | Quantity in inventory. 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, 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 only by quote. |
stockRequest[].leadTimeByRequest |
boolean | No | Preparation time on request. See Lead time and virtual inventory. |
stockRequest[].leadTimeDate |
datetime | No | Expected product availability date. ISO-8601 full, 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 do not send any 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 at 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 have contracted the product catalog service with your own 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 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 stored — 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 to be 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, the inventories in the same warehouse that already have that code stored 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 the submission. Zeroed or empty fields are omitted — if virtualQuantity comes back absent, it is 0.
| Field | Description |
|---|---|
id |
Id of the inventory created or updated. It is 0 when the item failed. |
productId |
SKU id resolved by the platform. |
warehouseId |
Warehouse of the item. |
price |
Stored price. |
status |
CREATED · UPDATED · ERROR |
error |
Reason for the rejection. Present only when status is ERROR. |
quantity · virtualQuantity · leadTime · byRequest · leadTimeByRequest · leadTimeDate |
Stored 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 |
Stored 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 walk the whole list, even with HTTP 200.
Errors
| Code | When |
|---|---|
| 400 | The partnerId in the path is not numeric: {"error":"Invalid target partner ID"}. |
| 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 given warehouse does not belong to the branch. Here the envelope is different from the rest — code, message and errorDescription — instead of error. Handle both formats. |
| 401 | Token missing, malformed or expired: {"error":"Authentication required for this route"}. |
| 403 | The branch is not linked to your head office: {"error":"Access denied: Invalid partnership"}. Unlike 400, here the payload is correct — what is missing is the link. |
| 422 | Problem in the envelope: stockRequest empty or with more than 50 items. The detail comes in error. |
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/:partnerId' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
"stockRequest": [
{
"skuAttributeName": "codigo-interno",
"skuAttributeValue": "SKU-A-001",
"warehouseId": 4970,
"price": 58.62,
"quantity": 1123,
"virtualQuantity": 0,
"leadTime": 2
},
{
"skuAttributeName": "codigo-interno",
"skuAttributeValue": "SKU-B-002",
"warehouseId": 4970,
"price": 150.0,
"quantity": 5,
"virtualQuantity": 0,
"leadTime": 2
}
]
}' Example responses
200Success — identification by manufacturer data
[
{
"id": 4410001,
"productId": 500101,
"warehouseId": 4970,
"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": 4970,
"skuAttributeName": "codigo-interno",
"skuAttributeValue": "SKU-A-001",
"price": 58.62,
"quantity": 1123,
"leadTime": 2,
"status": "UPDATED"
},
{
"id": 0,
"warehouseId": 4970,
"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
Related endpoints
Generated from the public API collection, published on 2026-09-04: api-docs.cws.digital.