Need to adjust stock levels across your Shopify store? The Shopify Admin API makes it possible to update inventory programmatically, helping you keep product availability accurate without relying on manual edits.
In this guide, you’ll learn how to update Shopify inventory using the Admin API, including the key concepts and steps to get started. Whether you’re syncing stock from another system or automating routine changes, you’ll be ready to manage inventory with greater confidence.
Shopify Admin API Update Inventory: Get Set Up
Before an API request can change stock, it needs to point to the right item at the right place—and have permission to make that change. Getting those details lined up first helps prevent a successful request from updating the wrong inventory level.
Identify the inventory item, location, and quantity to change
Start with the product variant, but note that Shopify tracks stock through its associated inventory item. In GraphQL, retrieve the variant’s inventory item ID, then identify the location where the stock should change. A product can have different quantities at different locations, so a product or variant ID alone isn’t enough.
Decide which quantity you intend to set. For example, if a warehouse system reports 18 units available at a particular location, the update should target that location’s inventory item and the available quantity—not a different location or quantity type. Keep these values together before building the request:
- Inventory item ID: the item linked to the product variant.
- Location ID: the location whose stock is changing.
- Quantity name and value: such as available and 18.
For absolute updates, Shopify’s GraphQL Admin API provides the inventorySetQuantities mutation. If your source system sends changes rather than full counts, choose an adjustment approach that reflects that workflow; confusing a new total with a change amount can produce inaccurate stock.
With the target values confirmed, the next step is making sure your app can access the relevant data and perform the update. Shopify’s API documentation describes the required inputs and behavior for the inventorySetQuantities mutation.
Prepare API access and permissions for inventory updates
Use an app with Admin API access and request the scopes that match your workflow. Inventory changes generally require writeinventory; reading inventory levels requires readinventory. If the app must look up variants and their inventory item IDs, it may also need product-reading access, such as read_products.
After installing or authorizing the app, send requests to the GraphQL Admin API endpoint for a specific, supported API version and include the app’s access token. Store that token securely—never expose it in browser code or public repositories. Before running updates against live stock, test the request with a known item and location, and inspect any user errors returned by the mutation.
Make a Shopify Admin API Update Inventory Request
Once the app is authorized and the target values are ready, the request itself is fairly compact. The important part is matching the endpoint to your store and API version, then sending a quantity update that reflects the source data accurately.
First, make sure the request is being sent to the correct GraphQL address and a version your app supports. This keeps the mutation aligned with the API schema you’re using.
Choose the right endpoint and API version
Send the request to your store’s GraphQL Admin API endpoint using this format: https://{shop}.myshopify.com/admin/api/{version}/graphql.json. Replace {shop} with the store’s permanent .myshopify.com domain and {version} with a supported version, such as 2026-10.
Use a version explicitly rather than relying on an unspecified or outdated endpoint. Shopify releases API versions regularly, so check the Shopify API versioning documentation when choosing or updating the version. Send the app’s access token in the X-Shopify-Access-Token header, and make the request with a JSON content type.
With the endpoint in place, you can submit the absolute quantity for the selected inventory item and location. The example below uses GraphQL variables, which makes it easier to reuse the mutation with different stock counts.
Set the inventory quantity and submit the request
For a full count from a warehouse system, use inventorySetQuantities and set the quantity name to available. The value should be the new total—not the amount to add or subtract. For example, if the verified count is 18, send 18 as the quantity.
mutation SetInventory($input: InventorySetQuantitiesInput!) {
inventorySetQuantities(input: $input) {
inventoryAdjustmentGroup {
createdAt
}
userErrors {
field
message
}
}
}In the variables, provide the matching IDs and quantity:
{
"input": {
"name": "available",
"reason": "correction",
"quantities": [{
"inventoryItemId": "gid://shopify/InventoryItem/123",
"locationId": "gid://shopify/Location/456",
"quantity": 18
}]
}
}Submit the mutation as a POST request, then inspect userErrors before treating the update as successful. Where supported by your workflow, include compareQuantity to help detect a stock value that changed between reading it and submitting the update. This safeguard can prevent an older count from silently replacing a newer one.
Verify Your Inventory Changes and Troubleshoot Issues
A successful HTTP response is a good start, but it doesn’t prove the intended stock level changed. Confirm the result in Shopify, then use the response details to decide whether a failed request is safe to retry or needs investigation.
Confirm the updated quantity in Shopify
Check the mutation’s userErrors first. If the list is empty, query the inventory level for the same inventory item and location, requesting the available quantity. Comparing that value with your submitted count confirms that the update landed where you expected.
For example, if you set 18 units but the follow-up query shows a different number, verify that you queried the correct location and quantity name. Another process may have updated stock in the meantime. Shopify’s InventoryLevel documentation describes the location-specific inventory data you can inspect.
Handle API errors, retries, and inventory syncs
When a request fails, distinguish between transport or GraphQL errors and mutation-level userErrors; each points to a different issue. Check the message and field details before changing the request. Common causes include missing scopes, invalid IDs, a location that can’t stock the item, or a quantity that doesn’t meet the mutation’s requirements.
For temporary throttling or server errors, wait before retrying and use exponential backoff with jitter rather than sending repeated requests immediately. If you’re setting an absolute count, compare the current quantity before retrying; for adjustments that add or subtract units, don’t blindly repeat the operation, because it could apply the change twice.
In a recurring sync, decide which system is authoritative and keep a record of each update’s item, location, source count, and result. Use inventory webhooks to respond to changes, then periodically reconcile Shopify against your source system. This helps catch missed events and competing updates without treating every difference as an automatic correction.
- Retry transient failures after a delay; investigate validation and permission errors first.
- Protect against stale counts with quantity comparisons where appropriate.
- Reconcile periodically so webhook gaps or concurrent changes don’t persist unnoticed.
Keep Shopify Inventory Accurate with a Reliable API Workflow
A Shopify Admin API update inventory workflow starts with the right inventory item, location, and quantity, backed by the permissions and API version your app needs. From there, choose an update method that matches your source data, submit the request, and verify the result rather than relying on a successful response alone.
For ongoing syncs, clear ownership of inventory data, careful error handling, and periodic reconciliation help prevent stale counts and duplicate adjustments. With these habits in place, you can automate stock updates more confidently and keep product availability aligned across your systems.