# InventoryLevel <p>An inventory level represents the quantities of an inventory item for a location.</p> <p>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.</p> {{ '/api/reference/inventory.png' | image }} <p>Before you begin updating inventory, it's helpful to understand the relationships between the inventory resources:</p> <ul> <li><strong><a href="/api/admin-rest/latest/resources/product-variant">Product Variant</a></strong>: Contains merchandising information, such as price, description, and images. Think of this as the product information that you might want a customer to see. <p>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.</p></li> <li><strong><a href="/api/admin-rest/latest/resources/inventoryitem">InventoryItem</a></strong>: 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. <p>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.</p></li> <li><strong><a href="/api/admin-rest/latest/resources/inventorylevel">InventoryLevel</a></strong>: Represents the actual quantity of an item that is available. <p>Inventory levels connect one inventory item to one location. Each inventory level holds the available quantity for its inventory item at the associated location.</p></li> <li><strong><a href="/api/admin-rest/latest/resources/location">Location</a></strong>: Represents a geographical location where a merchant does business, such as a retail store or warehouse. <p>Locations can have many inventory levels. Each location has one inventory level for each inventory item that the location stocks.</p></li> </ul> <h2 id="how-an-order-affects-inventory">How an order affects inventory</h2> <p>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.</p> <aside class="note note"> Orders placed through Shopify POS are associated with the location where the sale was made. For those orders, inventory is decremented at that location. </aside> <p>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: <ul> <li>If the fulfillment location matches the original location, then no action is needed.</li> <li>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.</li> </ul> </p> <h3>Example: Inventory adjustments for a simple order</h3> <p>An online store uses two warehouses to stock product inventory: one in Los Angeles (ID: <code>6884556842</code>), and one in New York (ID: <code>13968834616</code>). One of the store's products is a hat that's stocked at both locations with the following inventory levels: <ul> <li>Los Angeles: 8</li> <li>New York: 6</li> </ul> </p> <p>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: <ul> <li>Los Angeles: 7</li> <li>New York: 6</li> </ul> </p> <p>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: <ul> <li>Los Angeles: 8</li> <li>New York: 5</li> </ul> </p> <h2 id="inventory-levels-and-fulfillment-service-locations">Inventory levels and fulfillment service locations</h2> <p>A fulfillment service <a href="/api/admin-rest/latest/resources/location">location</a> has a 1:1 relationship with a third-party fulfillment service. When an app <a href="/api/admin-rest/latest/resources/fulfillmentservice">creates a new fulfillment service</a> on a store, Shopify automatically creates a location that's associated with that fulfillment service. The FulfillmentService resource has a <code>location_id</code> property, which identifies the associated location.</p> <p>An inventory item connected to a fulfillment service location can't be connected to any other locations at the same time:</p> {{ '/api/reference/location-types.png' | image }} <h3>Connecting an inventory item to a fulfillment service location</h3> <p>When you work with items that have been or will be connected a fulfillment location, you should include <code>"relocate_if_necessary": true</code> in the body of the request. There are two situations where you might do this:</p> <ul> <li>connecting an inventory item to a fulfillment service location and disconnecting it from all standard locations</li> <li>connecting an inventory item to one or more standard locations and disconnecting it from a fulfillment service location</li> </ul> <p>If <code>relocate_if_necessary</code> is <code>true</code>, 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 <code>relocate_if_necessary</code> is <code>false</code>, then the connection will fail. If no fulfillment service is involved, then the property is ignored and no inventory is relocated.</p> <h3>Setting the inventory level at a fulfillment service location</h3> <p>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 <code>"disconnect_if_necessary": true</code> in the body of the request. There are two situations where you might do this:</p> <ul> <li>setting inventory for an inventory item at a fulfillment service location when the item is already connected to one or more standard locations</li> <li>setting inventory for an inventory item at a standard location when the item is already connected to a fulfillment service location</li> </ul> <p>The inventory at the new location is set to the value of the <code>available</code> property. The inventory for other locations is set to 0 and the locations are disconnected from the inventory item.</p> <p>If <code>disconnect_if_necessary</code> is set to <code>false</code> 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.</p> ## Resource Properties ### InventoryLevel * available: The available quantity of an inventory item at the inventory level's associated location. Returns <code>null</code> if the inventory item is not tracked. * Type: x-string * Example: 6 * inventory_item_id: The ID of the inventory item associated with the inventory level. To find the ID of an inventory item, use the <a href='/api/admin-rest/latest/resources/inventoryitem'>Inventory Item resource</a> * Type: x-string * Example: 450789469 * location_id: The ID of the location that the inventory level belongs to. To find the ID of the location, use the <a href='/api/admin-rest/latest/resources/location'>Location resource</a> * Type: x-string * Example: 40642626 * updated_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601 format</a>) when the inventory level was last modified. * Type: x-string * Example: "2012-08-24T14:01:47-04:00" ## Retrieves a list of inventory levels <p>Retrieves a list of inventory levels.</p> <p>You must include <code>inventory_item_ids</code>, <code>location_ids</code>, or both as filter parameters.</p> <p><strong>Note:</strong> This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to <a href='/api/usage/pagination-rest'>Make paginated requests to the REST Admin API</a>.</p> ### Endpoint /admin/api/#{api_version}/inventory_levels.json?location_ids=655441491 (GET) ### Parameters * api_version (required): * inventory_item_ids: A comma-separated list of inventory item IDs. To find the ID of an inventory item, use the <a href='/api/admin-rest/latest/resources/inventoryitem'>Inventory Item resource</a> * limit: The maximum number of results to show. * location_ids: A comma-separated list of location IDs. To find the ID of a location, use the <a href='/api/admin-rest/latest/resources/location'>Location resource</a> * updated_at_min: Show inventory levels updated at or after date (format: 2019-03-19T01:21:44-04:00). ### Responses #### 200 Retrieves a list of inventory levels Examples: ##### Retrieve inventory levels at a single location Request: ``` GET /admin/api/unstable/inventory_levels.json ``` Response: ``` HTTP/1.1 200 OK {"inventory_levels":[{"inventory_item_id":49148385,"location_id":655441491,"available":2,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=49148385"},{"inventory_item_id":808950810,"location_id":655441491,"available":1,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"},{"inventory_item_id":457924702,"location_id":655441491,"available":4,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=457924702"},{"inventory_item_id":39072856,"location_id":655441491,"available":3,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=39072856"}]} ``` ##### Retrieve inventory levels for a single inventory item Request: ``` GET /admin/api/unstable/inventory_levels.json ``` Response: ``` HTTP/1.1 200 OK {"inventory_levels":[{"inventory_item_id":808950810,"location_id":487838322,"available":9,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/548380009?inventory_item_id=808950810"},{"inventory_item_id":808950810,"location_id":655441491,"available":1,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"}]} ``` ##### Retrieve inventory levels for the specified inventory items and locations Request: ``` GET /admin/api/unstable/inventory_levels.json ``` Response: ``` HTTP/1.1 200 OK {"inventory_levels":[{"inventory_item_id":808950810,"location_id":487838322,"available":9,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/548380009?inventory_item_id=808950810"},{"inventory_item_id":39072856,"location_id":487838322,"available":27,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/548380009?inventory_item_id=39072856"},{"inventory_item_id":808950810,"location_id":655441491,"available":1,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"},{"inventory_item_id":39072856,"location_id":655441491,"available":3,"updated_at":"2025-01-08T16:01:01-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=39072856"}]} ``` #### 422 Retrieves a list of inventory levels Examples: ##### Retrieving inventory levels without specifying <code>location_ids</code> or <code>inventory_item_ids</code> fails and returns an error Request: ``` GET /admin/api/unstable/inventory_levels.json ``` Response: ``` HTTP/1.1 422 Unprocessable Entity ``` ## Adjusts the inventory level of an inventory item at a location <p>Adjusts the inventory level of an inventory item at a single location</p> ### Endpoint /admin/api/#{api_version}/inventory_levels/adjust.json (POST) ### Parameters * api_version (required): * available_adjustment (required): The amount to adjust the available inventory quantity. Send negative values to subtract from the current available quantity. For example, <code>"available_adjustment": 2</code> increases the current available quantity by 2, and <code>"available_adjustment": -3</code>decreases 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 <a href='/api/admin-rest/latest/resources/location'>Location resource</a> ### Responses #### 200 Adjusts the inventory level of an inventory item at a location Examples: ##### Adjust the available quantity of an inventory item by 5 at a single location Request: ``` POST /admin/api/unstable/inventory_levels/adjust.json {"location_id":655441491,"inventory_item_id":808950810,"available_adjustment":5} ``` Response: ``` HTTP/1.1 200 OK {"inventory_level":{"inventory_item_id":808950810,"location_id":655441491,"available":6,"updated_at":"2025-01-08T16:01:57-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"}} ``` #### 404 Adjusts the inventory level of an inventory item at a location Examples: ##### Adjusting inventory levels at a non-existent location fails and returns an error Request: ``` POST /admin/api/unstable/inventory_levels/adjust.json {"location_id":655441491,"inventory_item_id":808950810,"available_adjustment":5} ``` Response: ``` HTTP/1.1 404 Not Found {"errors":"Not Found"} ``` #### 422 Adjusts the inventory level of an inventory item at a location Examples: ##### Adjusting inventory levels for an inventory item that is untracked fails and returns an error Request: ``` POST /admin/api/unstable/inventory_levels/adjust.json {"location_id":655441491,"inventory_item_id":808950810,"available_adjustment":5} ``` Response: ``` HTTP/1.1 422 Unprocessable Entity ``` ## Deletes an inventory level from a location 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. ### Endpoint /admin/api/#{api_version}/inventory_levels.json?inventory_item_id=808950810&location_id=655441491 (DELETE) ### Parameters * api_version (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 <a href='/api/admin-rest/latest/resources/location'>Location resource</a> ### Responses #### 204 Deletes an inventory level from a location Examples: ##### Delete an inventory level Request: ``` DELETE /admin/api/unstable/inventory_levels.json ``` Response: ``` HTTP/1.1 204 No Content ``` ## Connects an inventory item to a location <p>Connects an inventory item to a location by creating an inventory level at that location.</p> <p>When connecting inventory items to locations, it's important to understand the rules around <a href="#inventory-levels-and-fulfillment-service-locations">fulfillment service locations</a>.</p> ### Endpoint /admin/api/#{api_version}/inventory_levels/connect.json (POST) ### Parameters * api_version (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 <a href='/api/admin-rest/latest/resources/location'>Location resource</a> * relocate_if_necessary: 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 <a href="#inventory-levels-and-fulfillment-service-locations"><em>Inventory levels and fulfillment service locations</em></a>. ### Responses #### 201 Connects an inventory item to a location Examples: ##### Connect an inventory item to a location Request: ``` POST /admin/api/unstable/inventory_levels/connect.json {"location_id":844681632,"inventory_item_id":457924702} ``` Response: ``` HTTP/1.1 201 Created {"inventory_level":{"inventory_item_id":457924702,"location_id":844681632,"available":0,"updated_at":"2025-01-08T16:01:50-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/844681632?inventory_item_id=457924702"}} ``` #### 422 Connects an inventory item to a location Examples: ##### Connecting an inventory item to a fulfillment service location without <code>"relocate_if_necessary": true</code> fails with a 422 error when permits_sku_sharing is false Request: ``` POST /admin/api/unstable/inventory_levels/connect.json {"location_id":611870435,"inventory_item_id":808950810} ``` Response: ``` HTTP/1.1 422 Unprocessable Entity {"errors":["An item cannot be active at more than one location if one of them is a fulfillment service location."]} ``` #### 404 Connects an inventory item to a location Examples: ##### Connecting an inventory item to a non-existent location fails and returns an error Request: ``` POST /admin/api/unstable/inventory_levels/connect.json {"location_id":123,"inventory_item_id":457924702} ``` Response: ``` HTTP/1.1 404 Not Found {"errors":"Not Found"} ``` ## Sets the inventory level for an inventory item at a location 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 <a href="#inventory-levels-and-fulfillment-service-locations">fulfillment service locations</a>. ### Endpoint /admin/api/#{api_version}/inventory_levels/set.json (POST) ### Parameters * api_version (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 <a href='/api/admin-rest/latest/resources/inventoryitem'>Inventory Item resource</a> * location_id (required): The ID of the location that the inventory level belongs to. To find the ID of the location, use the <a href='/api/admin-rest/latest/resources/location'>Location resource</a> * disconnect_if_necessary: 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 <a href="#inventory-levels-and-fulfillment-service-locations"><em>Inventory levels and fulfillment service locations</em></a>. ### Responses #### 200 Sets the inventory level for an inventory item at a location Examples: ##### Set the available inventory at a location Request: ``` POST /admin/api/unstable/inventory_levels/set.json {"location_id":655441491,"inventory_item_id":808950810,"available":42} ``` Response: ``` HTTP/1.1 200 OK {"inventory_level":{"inventory_item_id":808950810,"location_id":655441491,"available":42,"updated_at":"2025-01-08T16:01:59-05:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/655441491?inventory_item_id=808950810"}} ``` #### 422 Sets the inventory level for an inventory item at a location Examples: ##### Setting an inventory item to a fulfillment service without <code>"disconnect_if_necessary": true</code> fails with a 422 error Request: ``` POST /admin/api/unstable/inventory_levels/set.json {"location_id":611870435,"inventory_item_id":808950810,"available":42} ``` Response: ``` HTTP/1.1 422 Unprocessable Entity {"errors":["An item cannot be active at more than one location if one of them is a fulfillment service location."]} ```