Order API - Update stock
Update stock
Endpoint: POST *base*/stock
Authentication: API Key
This updates the physicalStock
quantities in Centra. This is the number of products in stock including those that are reserved for orders.
You cannot set the quantity below the number that is reserved for orders, the value specified in allocatedStock
from :ref:Get stock <order-api-get-stock>
. In the case the stock update contains a lower amount than the allocated stock, Centra will set the quantity to allocatedStock
which the lowest possible value without affecting any reserved orders.
The request will not return any error message, but an email notification can be sent to a Centra-administrator from the plugin settings.
Parameters
Array of products to update stock on
String to update a product item. Use ean
, upc
or a combination of sku
, variantSku
and sizeSku
to update the quantity for each product.
The quantity of the physical stock for the item.
The internal cost price for this item.
ISO code for the currency for the cost price. USD
, EUR
, SEK
, etc.
Response in xml format instead of json.
Request example
The example above uses EAN, this is the same field as the Get stock product field ean
. The example below uses SKU by combining the Get stock fields sku
, variantSku
and sizeSku
:
POST <base>/stock HTTP/1.1
Content-type: application/json
{
"products": [
{
"product": "12312378901", # <- Combined product number (SKU) "123123" + variant number "789" + size number "01"
"quantity": 54
},
{
"product": "9876543210123", # <- Size-level EAN "9876543210123"
"quantity": 55
},
{
"product": "5432167890123",
"quantity": 1
}
]
}
Optionally you can also include a cost / pcs value for the items.
POST <base>/stock HTTP/1.1
Content-type: application/json
{
"products":[
{
"product": "1234567890123",
"quantity": 54,
"costPrice": 12.54,
"costPriceCurrency": "SEK"
},
{
"product": "9876543210123",
"quantity": 55,
"costPrice": 8.12,
"costPriceCurrency": "EUR"
},
{
"product": "5432167890123",
"quantity": 1,
"costPrice": 54.24,
"costPriceCurrency": "USD"
}
]
}
Response
200
Content-type: application/json
ok
if success, else no
.
If status
returns no
, this value should send back a message why it failed.
If status
returns no
, this object might contain information about products that could not be updated.
This will be an array with the product identifiers that could not be updated from the request.
Like this: ["43242342", "43243294", "432432232"]
This will be an array with the product identifiers that are bundled products. This means that they can not be updated directly, since they are based on products the bundle is connected to.
Like this: ["43242342", "43243294", "432432232"]
Response example
{
"status":"ok"
}
Error example
{
"status": "no",
"msg": "Some of the products were not updated",
"errors": {
"productsNotFound": [
"9876543210123",
"5432167890123"
]
}
}