Order API - Update stock

Update stock

PUT *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

products
array
required

Array of products to update stock on

product
string
required

String to update a product item. Use ean or a combination of sku, variantSku and sizeSku to update the quantity for each product.

quantity
int
required

The quantity of the physical stock for the item.

costPrice
string
optional

The internal cost price for this item.

costPriceCurrency
string
optional

ISO code for the currency for the cost price. USD, EUR, SEK, etc.

xml
boolean
optional

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": "1234567890123",
      "quantity": 54
    },
    {
      "product": "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

status
string
required

ok if success, else no.

msg
string
optional

If status returns no, this value should send back a message why it failed.

errors
object
optional

If status returns no, this object might contain information about products that could not be updated.

productsNotFound
array of string
optional

This will be an array with the product identifiers that could not be updated from the request.

Like this: ["43242342", "43243294", "432432232"]

productsAreBundles
array of string
optional

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"
    ]
  }
}