LianaCommerce REST API

Stocks

Serverhttps://shop.example.com/api/v1

Set the stock of many products and variations in one request, by id, product code, EAN code or ERP id.


Update stock in bulk

POST
https://shop.example.com/api/v1
/stocks

Sets the stock of products and variations. The body is a JSON array; each element has the new stock and exactly one identifier: code, ean_code, erp_id, product_id or variation_id. An element with no identifier or more than one returns 400 for the whole request.

  • code, ean_code and erp_id are matched exactly against both products and variations, so one element can update several products and variations. Deleted products and variations are not matched.
  • If several elements match the same product or variation, the last one wins.
  • The change is recorded in the stock history with the comment REST API.
  • When the shop computes product stock from variations (the product_stock_by_variations setting), a product that has variations (deleted ones don't count) is skipped: set the stock on its variations. Updating a variation then also recomputes its product's stock, and the product is listed in items too.

If no element updated anything, the response is 404. Otherwise elements that updated nothing (unknown, deleted or skipped targets) are listed in not_found. The response items have no result_index.

Update stock in bulk › Request Body

​StockIn[] · minItems: 1
The new stock and exactly one identifier. An identifier that is an empty string or `0` counts as missing.
stock
​integer · required

The new stock quantity.

Example: 25
code
​string

Matches products by product code and variations by variation code.

Example: COF-ETH-250
ean_code
​string

Matches products and variations by EAN code.

Example: 6412345678903
erp_id
​string

Matches products and variations by ERP id.

Example: ERP-10042
product_id
​integer

Matches the product with this id.

Example: 5
variation_id
​integer

Matches the variation with this id.

Example: 31

Update stock in bulk › Responses

The updated products and variations.

href
​string

The URL of the request.

Example: https://shop.example.com/api/v1/products
​object[]

The request elements that updated nothing, as {"<identifier>": <value as sent>}. Present only when some elements matched and some didn't.

​StockOut[]

The updated products and variations.

​Meta