API reference · Stock and Price

Update or Create Stock in Batch

PUThttps://api.sandbox.cws.digital/v1/stock/batch

Description

Creates or updates the stock 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 prevent the others.

The store is always the token's store. To send stock for a branch, use Update or Create Stock in Batch for Branch.

How to identify the product

Each item must carry one of these two forms:

FormFields
By manufacturer databrand, mfrPartCode and composition, all three together.
By attributeskuAttributeName and skuAttributeValue, both together. Available to those who have contracted the product catalog service with their own attribute.

All items in the same batch must use the same form. A batch that mixes both is rejected entirely with 400: send one request for each form.

The examples use the sandbox test product, which is already registered: only replace the warehouseId with a warehouse of your store.

Request body

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
stockRequestarray of objectYes

From 1 to 50 items.

Fields in stockRequest[]

Items of stockRequest[]
stockRequest[]
FieldTypeRequiredDescriptionValue
warehouseIdintegerYes

Warehouse where the stock is allocated.

pricenumberYes

Sale price. Cannot be negative.

quantityintegerYes

Stock quantity. Cannot be negative.

virtualQuantityintegerYes

Virtual stock. Cannot be negative. Send 0 when you do not work with virtual stock.

leadTimeintegerYes

Preparation time in days. Cannot be negative.

brandstringNo

Name of the manufacturer's brand, such as Bosch. Goes together with mfrPartCode and composition.

mfrPartCodestringNo

Product code at the manufacturer. Goes together with brand and composition.

compositionstringNo

Product composition, always in uppercase. Goes together with brand and mfrPartCode.

Allowed values:UNITARYPAIRKITWARRANTYSET
skuAttributeNamestringNo

Name of your own attribute in the product catalog. Goes together with skuAttributeValue.

skuAttributeValuestringNo

Value of the attribute for this product. Goes together with skuAttributeName.

byRequestbooleanNo

Product available for quotation.

leadTimeByRequestbooleanNo

Preparation time upon request. See Lead time and virtual stock.

leadTimeDatestringNo

Expected availability date of the product, with full date and time in Brasília time — 2026-09-10T00:00:00-03:00. See Availability date.

profitMarginnumberNo

Profit margin, from 0 to 100.

targetMarginnumberNo

Target margin, from 0 to 100.

totalCostnumberNo

Total cost of the item. Cannot be negative.

multipleQuantityintegerNo

Sales multiple. 0 is normalized to 1.

partnerPartCodestringNo

Your product code.

partnerPartCodeUniquebooleanNo

Makes the partnerPartCode unique in the warehouse. See Unique product code in the warehouse.

priceRuleTagsarray of objectNo

Price rule tags to link to the product: [{"name":"promocao"}]. A tag that does not exist in your store is ignored.

Fields in stockRequest[].priceRuleTags[]

deleteTagbooleanNo

true removes all price rule tags from the product, even if you do not send any new tag in priceRuleTags. When sending both, the old tags are removed and only those in priceRuleTags remain.

Items of stockRequest[].priceRuleTags[]
stockRequest[].priceRuleTags[]
FieldTypeRequiredDescriptionValue
namestringNo

Business rules

Lead time and virtual stock

The preparation time can be provided in two ways:

  • In days: send the number of days in leadTime. If you send leadTimeByRequest, it must be false.
  • Upon request: send leadTimeByRequest: true with leadTime: 0.

With virtual stock (virtualQuantity greater than zero) and leadTimeByRequest: false, leadTime must be greater than zero.

An item outside these combinations is rejected, with status: ERROR.

Availability date

Send leadTimeDate with the full date and time, in Brasília time: 2026-09-10T00:00:00-03:00.

A date without time (2026-09-10) or in another format (10/09/2026) rejects the entire request with 400.

With the date filled in and the real quantity at zero, the virtual stock starts being offered.

The submission is always complete

Resend the whole item on every update. The optional fields you do not resend go back to empty: leadTimeDate, leadTimeByRequest, profitMargin, totalCost and targetMargin.

partnerPartCode and multipleQuantity are the exception: they only change when you send them.

Repeated items in the same batch

Send each product only once per request. Items with the same warehouse and the same product are treated as repeated:

  • with the same values, only the first one is processed;
  • with different values, none of them is processed.

Unique product code in the warehouse

Use partnerPartCodeUnique: true when you reuse a product code for another SKU.

With it, the stocks in the same warehouse that already have that code in partnerPartCode are zeroed (price, quantity and virtual stock), and the old code receives the _i suffix.

Responses

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request PUT \
  --url 'https://api.sandbox.cws.digital/v1/stock/batch' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "stockRequest": [
    {
      "skuAttributeName": "codigo-produto-teste",
      "skuAttributeValue": "PRODUTO-TESTE-001",
      "warehouseId": 1001,
      "price": 58.62,
      "quantity": 1123,
      "virtualQuantity": 0,
      "leadTime": 2
    }
  ]
}'

Response

Click Try it to see the real response here, or pick a documented example: