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.
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.
null
if the inventory item is not tracked.Adjusts the inventory level of an inventory item at a single location
"available_adjustment": 2
increases the current available quantity by 2, and "available_adjustment": -3
decreases the current available quantity by 3.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.
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.