Manage inventory quantities and states
This guide shows you how to use the GraphQL Admin API to sync and maintain accurate inventory quantities, and transition products to different inventory states.
RequirementsAnchor link to section titled "Requirements"
- Your app can make authenticated requests to the GraphQL Admin API.
- Your app has the
write_inventoryaccess scopes. For more information on requesting access scopes when your app is installed, refer to Getting started with OAuth.
- Your store has existing products.
- You're familiar with the different inventory states.
- You're using API version 2023-01 or higher.
Inventory object relationshipsAnchor link to section titled "Inventory object relationships"
Before you begin managing inventory quantities and states, it's helpful to understand the relationships between inventory objects. The following diagram illustrates the relationships between inventory objects in the GraphQL Admin API:
|ProductVariant||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.
|InventoryItem||Contains information about the physical product, such as its SKU.
Think of this as the backend information used for managing inventory, shipping, and fulfillments. Inventory items are associated with one or many inventory levels. An inventory item has an inventory level for each location where the item is stocked.
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||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.
Step 1: Retrieve IDs for inventory locations and inventory itemsAnchor link to section titled "Step 1: Retrieve IDs for inventory locations and inventory items"
You can use the
locations query to retrieve the IDs of inventory locations and inventory items.
An inventory level represents the quantities of an inventory item that's associated with a location. An inventory item represents the goods that are available to be shipped to a customer. You'll use the IDs for inventory levels and inventory items to query inventory quantities in the next step.
The following example shows how to retrieve the first three locations and their associated inventory levels. The response returns a set of parameterized global IDs.
Step 2: Query inventory quantitiesAnchor link to section titled "Step 2: Query inventory quantities"
You can use the following queries to retrieve inventory quantities:
- Query inventory quantities for an item at a specific location
- Query inventory quantities for an item at multiple locations
Query inventory quantities for an item at a specific locationAnchor link to section titled "Query inventory quantities for an item at a specific location"
You can use the
inventoryLevel query to retrieve inventory quantities for an item at a specific 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.
The following example query retrieves the quantity of an inventory item that's available at a specific location. The response shows 11 items that are available at the location.
Query inventory quantities for an item at multiple locationsAnchor link to section titled "Query inventory quantities for an item at multiple locations"
You can use the
inventoryItem query to retrieve inventory quantities for an item at multiple locations.
The following example query retrieves the quantity of an inventory item that are available, on-hand, reserved, and committed at the first five locations. The response shows 72 available items, 101 on-hand items, 0 reserved items, and 29 committed items at the locations.
Step 3: Manage inventory quantitiesAnchor link to section titled "Step 3: Manage inventory quantities"
You can use the following mutations to manage inventory quantities:
- Set inventory quantities on hand: Explicitly set the quantity of inventory that's in the
- Adjust inventory quantities: Add or remove quantities of inventory that are in the
- Move inventory quantities between states: Transition inventory quantities between the
Set inventory quantities on handAnchor link to section titled "Set inventory quantities on hand"
on_hand state represents the total number of units that are physically stocked at a location. The
on_hand state equals the sum of inventory quantities in the
You set inventory in the
on_hand state to maintain an accurate count of physical inventory. For example, you might need to set inventory in the
on_hand state in the following scenarios:
- Inventory was received outside of a purchase order
- A stocktake was completed and inventory needs to be adjusted accordingly
- Damaged inventory was thrown out
You can use the
inventorySetOnHandQuantities mutation to set on-hand inventory quantities at a location to a given value. In the
reason field in the mutation's input, you can specify one of the following reasons for adjusting on-hand inventory quantities:
||Used to reserve, or temporarily set aside unavailable units.|
||Used to remove the number of unavailable units that have been reserved.|
||Used to update the number of unavailable units that have been reserved.|
||Used to correct an inventory error or as a general adjustment reason.|
||Used to specify an adjusted inventory count due to a discrepancy between the actual inventory quantity and previously recorded inventory quantity.|
||Used to remove units from inventory count due to damage.|
||Used to remove units from inventory count due to a promotion or donation.|
||Used to specify inventory that the merchant received.|
||Used to add a returned unit back to available inventory so the unit can be resold.|
||Used when actual inventory levels are less than recorded due to theft or loss.|
The following example shows how to set the on-hand inventory quantity to 102. The response shows the delta of incrementing the on-hand inventory quantity by 1 because the previous inventory count in the
on_hand state was 101.
Adjust inventory quantitiesAnchor link to section titled "Adjust inventory quantities"
You can use the
inventoryAdjustQuantities mutation to increment or decrement the total amount of inventory that's in the
reserved state at a location. For example, a merchant might need to adjust inventory quantities in the following cases:
|State that needs adjustments||Use cases|
The following example shows how to increase the quantity of available inventory units by 2 at a location. The response shows the delta of incrementing the available inventory quantity by 2.
Move inventory quantities between statesAnchor link to section titled "Move inventory quantities between states"
You can use the
inventoryMoveQuantities mutation to transition inventory quantities between the
reserved states. For example, a merchant might need to move inventory quantities between states in the following cases:
reserved: A third-party logistics provider finds and reports damaged inventory.
reserved: The merchant is using Shopify POS and needs to set inventory aside for a customer. In this scenario, you should use a draft order rather than manually moving inventory to the
available: An inventory unit that was previously damaged and set aside was repaired.
The following example shows how to move a quantity of 2 inventory units from the
available to the
- Learn about other types of fulfillment apps that you can create to integrate into order management, fulfillment, and returns workflows.