Skip to content

Stock

The Stock Import Endpoint

https://{BASE_URL}/imports/stock

All import integration endpoints use the same authentication parameters, please see Authentication page for more details.

The stock import endpoint is intended for the situation where the stock count needs to be overridden for one or more products. This can be necessary if the singular truth is placed in a third party system.

You can, however, supply an additional query parameter: adjustment=true. This will cause the imported data to be interpreted as stock adjustments instead of as new values.

Each stock count imported through the stock endpoint will, if successfully imported, become a stock event of the type external_reset - or in case adjustment=true is used, it will be external_adjustment.

Importing stock counts

The body of the POST request must be a JSON object with the following layout:

Without variants:

{
    "stock_location_id": {
        "product1": 7,
        "product2": 7
    }
}

With variants:

{
    "stock_location_id": {
        "product1": 7,
        "product2": 7,
        "product3": {
            "variant1": 7,
            "variant2": 7
        }
    }
}

It is possible to import products that do not (yet) exist at a given stock location.

It is not possible to import stock numbers to a non existing stock location.

Upon success a HTTP 200 OK reponse will be given with body looking something like this:

{
    "status": "OK",
    "message": "Import of 2 stock value(s) initiated"
}

The number of values that has been parsed from the request will be noted in the message (as seen in the example above).

Deleting Stock

Send an HTTP DELETE request to the endpoint with a body similar to stock registration.

Since the format is shared between the DELETE and the POST requests, this means that there must be a stock count value. Note that this value is ignored as the purpose of the DELETE request is to remove the stock information for the product in question.

Without variants:

{
    "stock_location_id": {
        "product1": 0,
        "product2": 0
    }
}

With variants:

{
    "stock_location_id": {
        "product1": 0,
        "product2": 0,
        "product3": {
            "variant1": 0,
            "variant2": 0
        }
    }
}

Please not the difference between setting the stock to 0 (sending the data above in a POST request) and removing the stock value (sending the data above in a DELETE request).

The former means: This is a product that we sell, but currently the stock count is 0.

The latter means: This is no longer a product that we keep in stock - and thus it will no longer be present when performing stock counts, etc.