Stocks (Create and Update)

To optimise the order routing and to have an overview, how many pieces of an article there are in a facility or the whole network, we have an entity called stock. This part of our tutorial series show

Creating stock

The process for creating stock is pretty straight forward. We can just use the stocks endpoint and POST the amount of stock for each article for each facility. As this is LU.XY's test system, we create 100 of each entity, when the productive deployment takes place, this should be synced with the ERP system. The creation call looks like this:

curl --location 'https://your.api.fulfillmenttools.com/api/stocks' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
    "facilityRef": "d286e108-698b-4f6c-97b7-21f090f17e46",
    "tenantArticleId": "BLAZER-G-6354",
    "value": 100
}'

After creating the stock, we receive a 201 CREATED response:

{
    "created": "2024-02-02T10:27:55.154Z",
    "facilityRef": "d286e108-698b-4f6c-97b7-21f090f17e46",
    "id": "33fb7ef6-47b5-4fd7-ac07-584293d84af3",
    "lastModified": "2024-02-02T10:27:55.154Z",
    "tenantArticleId": "BLAZER-G-6354",
    "value": 100,
    "scannableCodes": [],
    "scores": [
        {
            "type": "RATING",
            "name": "RECEIPT_DATE",
            "value": 3255
        }
    ],
    "reserved": 0,
    "facilityWideReserved": 0,
    "available": 100,
    "traits": [
        "PICKABLE",
        "ACCESSIBLE"
    ],
    "properties": {},
    "serializedProperties": "{}",
    "receiptDate": "2024-02-02T10:27:55.136Z",
    "version": 1
}

Besides some other properties, you might have noticed reserved and facilityWideReserved. When there is a PickJob inside the facility which needs this stock or this article in the facility, the stock will be reserved until it is picked. When the item is picked, the reservation will be removed and the amount of stock will be decreased.

Creating stock with properties

Stock Properties allow tracking of specific values on stock. When creating stock you can provide the desired stock properties in the properties field of your request:

curl -sSL -X POST 'https://your.api.fulfillmenttools.com/api/stocks' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data-raw '{
    "facilityRef": "<your facility>",
    "tenantArticleId": "<your tenantArticleId>",
    "value": 100,
    "properties": {
        "batch": "0-1-2-3",
        "expiry": "2023-08-17T09:39:28.966Z"
    }
}'

Updating stock

Each stock created in our system receives a unique ID. This ID must be specified when updating stock. Therefore, we advise to either temporarily store stock Ids or get all stocks before updating.

Deleting stock

Each stock created in our system receives a unique ID. This ID must be specified when deleting stock.

Deleting stock by product / location / id in batch

  • For deleting all stocks for a product in a facility, use the DELETE_BY_PRODUCTS action

  • For deleting all stocks on a storage location in a facility, use the DELETE_BY_LOCATIONS action

  • For deleting multiple stocks in a facility in one call, use the DELETE_BY_IDS action

Move stock to another location

For moving a stock from one location to another, specify the respective stockId as well as the toLocationRef to which the stock should be moved. When setting deleteFromStockIfZero to true, the stock on the start location is deleted when value reaches 0 after move action was completed. Attention: If deleteFromStockIfZero is set to true, the stock entity is deleted even when the KEEP_ON_ZERO trait is active on the respective location.

Create safety stock

In some cases it might be necessary to have some safety stock which will not be affected by online orders. For example when we have a fashion retail store, clothes which are currently with an end customer - either in their basket or on their way to the fitting rooms, this item can't be picked. To handle these situations, we can create safety stock which prevents the set amount from being considered in the routing decision and hence not being picked.

The PUT safetyStock endpoint lets us create the safety stock in bulk:

curl --location --request PUT 'https://ocff-cyanicsloth-git.api.fulfillmenttools.com/api/safetystocks' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
    "operations": [
        {
            "tenantArticleId": "SNEAK-W-4891",
            "facilityRef": "d286e108-698b-4f6c-97b7-21f090f17e46",
            "value": 10
        }
    ]
}'

The 207 MULTI-STATUS status code indicates success, the payload shows the status for each entity:

[
    {
        "tenantArticleId": "SNEAK-W-4891",
        "value": 10,
        "status": "CREATED",
        "facilityRef": "d286e108-698b-4f6c-97b7-21f090f17e46"
    }
]

Integration layer

We highly recommend using events on the integration layer to handle the stock topic. For example an event from the POS cashier could trigger a stock change in the fulfillmenttools platform. Furthermore, we provide an event if there is a stock change. More information can be read here.

Last updated