# Stocks

Managing stocks in the e-shop.

## List of stocks

 - [GET /api/stocks](https://api.docs.shoptet.com/shoptet-api/openapi/stocks/getlistofstocks.md): Returns the list of stocks. There are usually not many stocks, therefore the endpoint returns all of them without Paging.

## Stock detail

 - [GET /api/stocks/{stockId}](https://api.docs.shoptet.com/shoptet-api/openapi/stocks/getstockdetail.md): Returns detailed information about one stock.

## Stock movements

 - [GET /api/stocks/{stockId}/movements](https://api.docs.shoptet.com/shoptet-api/openapi/stocks/getstockmovements.md): It returns the list of changes in product quantity, which were done
within one stock. Supports the Paging movements.

This endpoint supports optional parts using the include parameter (see
Section on demand). Please note that there is some
performance penalty associated with the usage of "orderCode" include
and/or query parameter.
Also please note that when include productGuid is used, the returned data can be null for specific cases. Either when this is a historic stock move, or the product code has been changed and/or is inconsistent with internally stored guid. This is to ensure that the returned code and productGuid always point to the same product consistently.
To return GUID of product at the time of the stock movement, please use the include and attribute historicalProductGuid. The returned data can still be null on historic stock movements.

## Update quantity in stock

 - [PATCH /api/stocks/{stockId}/movements](https://api.docs.shoptet.com/shoptet-api/openapi/stocks/updatequantityinstock.md): Endpoint enables the quantity of product in stock (relative and
absolute) to be changed. Within a call, the update

of multiple products at once can be requested (max. 300
products/variants).


In case an error occurs for one of the records, the correct records will
be updated, the response will be 200 OK

and there will be records in the errors array for each failed record.
If all records are incorrect, the response

code will be 400 BAD REQUEST instead.


Item productCode is mandatory. Then one of the three items has to be
provided:


- amountChange to increase or decrease amount available for
ordering/physically on stock (relative change)


- quantity to set amount available for ordering (absolute amount)


- realStock to set amount physically stored in a warehouse (absolute
amount)


The difference between quantity and realStock is amount of goods
requested by the pending orders (so called "claim").


amount for ordering = realStock - claim


The claim cannot be changed explicitly, it is updated when a new order
is submitted or an order is sent out. Please note,

that the stock amount cannot be changed for product sets, where the
amount is calculated dynamically from the individual

products in the set. Trying to change the amount of product set will
result in an error.

## Stock movements - Last move

 - [GET /api/stocks/{stockId}/movements/last](https://api.docs.shoptet.com/shoptet-api/openapi/stocks/getstockmovementslastmove.md): It returns informations about last stock move.

## Product supplies in stock

 - [GET /api/stocks/{stockId}/supplies](https://api.docs.shoptet.com/shoptet-api/openapi/stocks/getproductsuppliesinstock.md): Returns the product supplies in stock for all products in a specific stock, contains GUID, code and quantity 
in stock for a specific product variant. It is possible to filter the specific GUID of a product, possibly a variant code. The endpoint supports Paging, in case of filtering, the amount of items per page increases.
This endpoint supports optional parts using the include parameter (see Section on demand). The changeTime item 
is always temporarily returned, however as of 16. 3. 2019 only upon using the include parameter.


If you defined the include=changeTime parameter within the URL, the response will also contain the time
when the last quantity in stock was changed.

