The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the GraphQL Admin API. For details and migration steps, visit our migration guide.

Requires inventory access scope.

An inventory level represents the quantities of an inventory item for a location.

Each inventory level belongs to one inventory item and has one location. For every location where an inventory item can be stocked, there's an inventory level that represents the inventory item's quantities relating to that location.

Before you begin updating inventory, it's helpful to understand the relationships between the inventory resources:

  • Product Variant: Contains merchandising information, such as price, description, and images. Think of this as the product information that you might want a customer to see.

    All product variants have a 1:1 relationship with their associated inventory item. Each product variant has one inventory item, and that inventory item belongs only to that product variant.

  • InventoryItem: Contains information about the physical product, such as its SKU. Think of this as the back-end information used for managing inventory, shipping, and fulfillments.

    Inventory items are associated with one or many inventory levels. An inventory item will have an inventory level for each location where the item is stocked.

  • InventoryLevel: Represents the actual quantity of an item that is available.

    Inventory levels connect one inventory item to one location. Each inventory level holds the available quantity for its inventory item at the associated location.

  • Location: Represents a geographical location where a merchant does business, such as a retail store or warehouse.

    Locations can have many inventory levels. Each location has one inventory level for each inventory item that the location stocks.

How an order affects inventory

When a product variant that Shopify tracks is included in an order, Shopify decrements the inventory for that variant. Shopify doesn't know which location the item will be fulfilled from, so Shopify decrements the inventory level at the location that has the lowest ID.

When an order is fulfilled, the fulfillment includes the ID of the location where the fulfillment is taking place. Shopify checks whether the fulfillment location matches the original location where stock was decremented, and then adjusts the inventory if necessary:

  • If the fulfillment location matches the original location, then no action is needed.
  • If the fulfillment location doesn't match the original location, then Shopify decrements the inventory level at the fulfillment location and increments the inventory level at the original location.

Example: Inventory adjustments for a simple order

An online store uses two warehouses to stock product inventory: one in Los Angeles (ID: 6884556842), and one in New York (ID: 13968834616). One of the store's products is a hat that's stocked at both locations with the following inventory levels:

  • Los Angeles: 8
  • New York: 6

A customer places an order for a hat. The Los Angeles location has the lowest ID, so Shopify decrements the item's inventory level at that location:

  • Los Angeles: 7
  • New York: 6

The order is actually fulfilled from the New York location. When the fulfillment is created, it includes the ID for the New York location. Shopify compares the fulfillment location ID to the original location and finds that they're different. Shopify then increments the inventory level at the Los Angeles location, and decrements the inventory level at the New York location:

  • Los Angeles: 8
  • New York: 5

Inventory levels and fulfillment service locations

A fulfillment service location has a 1:1 relationship with a third-party fulfillment service. When an app creates a new fulfillment service on a store, Shopify automatically creates a location that's associated with that fulfillment service. The FulfillmentService resource has a location_id property, which identifies the associated location.

An inventory item connected to a fulfillment service location can't be connected to any other locations at the same time:

Connecting an inventory item to a fulfillment service location

When you work with items that have been or will be connected a fulfillment location, you should include "relocate_if_necessary": true in the body of the request. There are two situations where you might do this:

  • connecting an inventory item to a fulfillment service location and disconnecting it from all standard locations
  • connecting an inventory item to one or more standard locations and disconnecting it from a fulfillment service location

If relocate_if_necessary is true, then all inventory for the item is relocated to the new location and disconnected from any other locations. If a fulfillment service location is involved but relocate_if_necessary is false, then the connection will fail. If no fulfillment service is involved, then the property is ignored and no inventory is relocated.

Setting the inventory level at a fulfillment service location

When you set inventory for a location, the inventory item is connected to the location if they are not already connected. If the item has been or will be connected to a fulfillment service location, then you should include "disconnect_if_necessary": true in the body of the request. There are two situations where you might do this:

  • setting inventory for an inventory item at a fulfillment service location when the item is already connected to one or more standard locations
  • setting inventory for an inventory item at a standard location when the item is already connected to a fulfillment service location

The inventory at the new location is set to the value of the available property. The inventory for other locations is set to 0 and the locations are disconnected from the inventory item.

If disconnect_if_necessary is set to false when you set inventory at a location and a fulfillment service location is involved, then the action will fail. If no fulfillment service location is involved, then this property is ignored.

Was this section helpful?

Properties

available
The available quantity of an inventory item at the inventory level's associated location. Returns null if the inventory item is not tracked.

inventory_item_id
read-only
->id
The ID of the inventory item associated with the inventory level. To find the ID of an inventory item, use the Inventory Item resource

location_id
->id
The ID of the location that the inventory level belongs to. To find the ID of the location, use the Location resource

updated_at
read-only
The date and time (ISO 8601 format) when the inventory level was last modified.

Was this section helpful?
{}The InventoryLevel resource
{
  "available": 6,
  "inventory_item_id": 450789469,
  "location_id": 40642626,
  "updated_at": "2012-08-24T14:01:47-04:00"
}

Adjusts the inventory level of an inventory item at a single location


api_version
string
required

available_adjustment
required
The amount to adjust the available inventory quantity. Send negative values to subtract from the current available quantity. For example, "available_adjustment": 2 increases the current available quantity by 2, and "available_adjustment": -3decreases the current available quantity by 3.

inventory_item_id
required
The ID of the inventory item.

location_id
required
The ID of the location that the inventory level belongs to. To find the ID of the location, use the Location resource

Was this section helpful?
Request body
locationid
Location_id resource
Was this section helpful?
post
/admin/api/2024-10/inventory_levels/adjust.json
Copy
curl -d '{"location_id":655441491,"inventory_item_id":808950810,"available_adjustment":5}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-10/inventory_levels/adjust.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
{}Response
JSON
HTTP/1.1 200 OK
{
  "inventory_level": {
    "inventory_item_id": 808950810,
    "location_id": 655441491,
    "available": 6,
    "updated_at": "2024-09-19T10:28:11-04:00",
    "admin_graphql_api_id": "gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"
  }
}

Connects an inventory item to a location by creating an inventory level at that location.

When connecting inventory items to locations, it's important to understand the rules around fulfillment service locations.


api_version
string
required

inventory_item_id
required
The ID of the inventory item.

location_id
required
The ID of the location that the inventory level belongs to. To find the ID of the location, use the Location resource

relocate_if_necessary
default false
Whether inventory for any previously connected locations will be relocated. This property is ignored when no fulfillment service location is involved. For more information, refer to Inventory levels and fulfillment service locations.

Was this section helpful?
Request body
locationid
Location_id resource
Was this section helpful?
post
/admin/api/2024-10/inventory_levels/connect.json
Copy
curl -d '{"location_id":844681632,"inventory_item_id":457924702}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-10/inventory_levels/connect.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
{}Response
JSON
HTTP/1.1 201 Created
{
  "inventory_level": {
    "inventory_item_id": 457924702,
    "location_id": 844681632,
    "available": 0,
    "updated_at": "2024-09-19T10:28:10-04:00",
    "admin_graphql_api_id": "gid://shopify/InventoryLevel/844681632?inventory_item_id=457924702"
  }
}

Sets the inventory level for an inventory item at a location. If the specified location is not connected, it will be automatically connected first. When connecting inventory items to locations, it's important to understand the rules around fulfillment service locations.

api_version
string
required

available
required
Sets the available inventory quantity.

inventory_item_id
required
The ID of the inventory item associated with the inventory level. To find the ID of the inventory item, use the Inventory Item resource

location_id
required
The ID of the location that the inventory level belongs to. To find the ID of the location, use the Location resource

disconnect_if_necessary
default false
Whether inventory for any previously connected locations will be set to 0 and the locations disconnected. This property is ignored when no fulfillment service is involved. For more information, refer to Inventory levels and fulfillment service locations.

Was this section helpful?
Request body
locationid
Location_id resource
Was this section helpful?
post
/admin/api/2024-10/inventory_levels/set.json
Copy
curl -d '{"location_id":655441491,"inventory_item_id":808950810,"available":42}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-10/inventory_levels/set.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
{}Response
JSON
HTTP/1.1 200 OK
{
  "inventory_level": {
    "inventory_item_id": 808950810,
    "location_id": 655441491,
    "available": 42,
    "updated_at": "2024-09-19T10:28:12-04:00",
    "admin_graphql_api_id": "gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"
  }
}

Retrieves a list of inventory levels.

You must include inventory_item_ids, location_ids, or both as filter parameters.

Note: This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to Make paginated requests to the REST Admin API.


api_version
string
required

inventory_item_ids
≤ 50
A comma-separated list of inventory item IDs. To find the ID of an inventory item, use the Inventory Item resource

limit
≤ 250
default 50
The maximum number of results to show.

location_ids
≤ 50
A comma-separated list of location IDs. To find the ID of a location, use the Location resource

updated_at_min
Show inventory levels updated at or after date (format: 2019-03-19T01:21:44-04:00).

Was this section helpful?
Query parameters
locationids=655441491
≤ 50
A comma-separated list of location IDs. To find the ID of a location, use the Location resource
Was this section helpful?
get
/admin/api/2024-10/inventory_levels.json?locationids=655441491
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/inventory_levels.json?location_ids=655441491" \
-H "X-Shopify-Access-Token: {access_token}"
{}Response
JSON
HTTP/1.1 200 OK
{
  "inventory_levels": [
    {
      "inventory_item_id": 49148385,
      "location_id": 655441491,
      "available": 2,
      "updated_at": "2024-09-19T10:10:57-04:00",
      "admin_graphql_api_id": "gid://shopify/InventoryLevel/655441491?inventory_item_id=49148385"
    },
    {
      "inventory_item_id": 808950810,
      "location_id": 655441491,
      "available": 1,
      "updated_at": "2024-09-19T10:10:57-04:00",
      "admin_graphql_api_id": "gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"
    },
    {
      "inventory_item_id": 457924702,
      "location_id": 655441491,
      "available": 4,
      "updated_at": "2024-09-19T10:10:57-04:00",
      "admin_graphql_api_id": "gid://shopify/InventoryLevel/655441491?inventory_item_id=457924702"
    },
    {
      "inventory_item_id": 39072856,
      "location_id": 655441491,
      "available": 3,
      "updated_at": "2024-09-19T10:10:57-04:00",
      "admin_graphql_api_id": "gid://shopify/InventoryLevel/655441491?inventory_item_id=39072856"
    }
  ]
}

Deletes an inventory level of an inventory item at a location. Deleting an inventory level for an inventory item removes that item from the specified location. Every inventory item must have at least one inventory level. To move inventory to another location, first connect the inventory item to another location, and then delete the previous inventory level.

api_version
string
required

inventory_item_id
required
The ID for the inventory item.

location_id
required
The ID of the location that the inventory level belongs to. To find the ID of the location, use the Location resource

Was this section helpful?
Query parameters
inventoryitemid=808950810
required
The ID for the inventory item.
locationid=655441491
required
The ID of the location that the inventory level belongs to. To find the ID of the location, use the Location resource
Was this section helpful?
del
/admin/api/2024-10/inventory_levels.json?inventoryitemid=808950810&locationid=655441491
Copy
curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2024-10/inventory_levels.json?inventory_item_id=808950810&location_id=655441491" \
-H "X-Shopify-Access-Token: {access_token}"
{}Response
JSON
HTTP/1.1 204 No Content