magento 2 api how to create stocks

Magento 2 API (Updated 2023): How to create stocks

This post will show you the process of creating stocks using Magento 2 API. In Magento, the stock is like a virtual inventory of products for sources of your sale channels (websites). A stock can map to multiple sales channels, but a sales channel can be assigned to only one stock.

Create the stock

While creating a new warehouse, this information will be needed:

  • name
  • type
  • code


POST <host>/rest/default/V1/inventory/stocks

Authorization: Admin – Bearer token


  "stock": {
    "name": "US Stock",
    "extension_attributes": {
      "sales_channels": [
          "type": "website",
          "code": "base"
}Code language: JSON / JSON with Comments (json)


Magento will return stock ID. Later we will use this ID to link the source to stock.

create stock using magento 2 api

Verify the result

Log in to your admin account and check your new stocks. Goes to

Stores > Inventory > Stocks

They are displayed in the Stock grid.

view stock on admin Magento 2

I have shown you how to create stocks with Magento 2 API. Check how to create warehouses with Magento 2 here. If you have any questions, please leave a comment in the section below, or refer to Magento DevDocs.