beehexa integrationsidebar
beehexa logo

We Build HexaSync Integration Platform for Connecting ERP, POS, CRM, Accounting, and eCommerce Applications to Automate Business Processes

magento 2 api how to create stocks

Magento 2 API (Updated 2024): 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.

Table of Contents

Ready to integrate and automate at scale ?

Learn how HexaSync lets you build enterprise-grade integrations and automations without having to code.

Receive Exclusive Productivity Tips Directly in Your Inbox

We’ll email you 1-3 times per week—and never share your information.

Get started for free

You can’t add more hours to the day. Beehexa is the next best thing.