--- title: inventorySetOnHandQuantities - GraphQL Admin description: Set inventory on-hand quantities using absolute values. api_version: 2025-10 api_name: admin type: mutation api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/mutations/inventorySetOnHandQuantities md: https://shopify.dev/docs/api/admin-graphql/latest/mutations/inventorySetOnHandQuantities.md --- # inventory​Set​On​Hand​Quantities mutation Requires `write_inventory` access scope. Also: The user must have a permission to update an inventory. Deprecated. Use [inventorySetQuantities](https://shopify.dev/docs/api/admin-graphql/latest/mutations/inventorySetQuantities) to set on\_hand or available quantites instead. Set inventory on-hand quantities using absolute values. ## Arguments * input [Inventory​Set​On​Hand​Quantities​Input!](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/InventorySetOnHandQuantitiesInput) required The information required to set inventory on hand quantities. *** ## Inventory​Set​On​Hand​Quantities​Payload returns * inventory​Adjustment​Group [Inventory​Adjustment​Group](https://shopify.dev/docs/api/admin-graphql/latest/objects/InventoryAdjustmentGroup) The group of changes made by the operation. * user​Errors [\[Inventory​Set​On​Hand​Quantities​User​Error!\]!](https://shopify.dev/docs/api/admin-graphql/latest/objects/InventorySetOnHandQuantitiesUserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Adjust on\_hand quantity for 2 items, with reason 'correction'. #### Query ```graphql mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } } ``` #### Variables ```json { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }", "variables": { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, { variables: { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } } QUERY variables = { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, "variables": { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } }, }, }); ``` #### Response ```json { "inventorySetOnHandQuantities": { "userErrors": [], "inventoryAdjustmentGroup": { "createdAt": "2024-09-12T01:05:46Z", "reason": "Inventory correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "name": "available", "delta": 31 }, { "name": "available", "delta": 12 }, { "name": "on_hand", "delta": 31 }, { "name": "on_hand", "delta": 12 } ] } } } ``` * ### inventorySetOnHandQuantities reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20inventorySetOnHandQuantities\(%24input%3A%20InventorySetOnHandQuantitiesInput!\)%20%7B%0A%20%20inventorySetOnHandQuantities\(input%3A%20%24input\)%20%7B%0A%20%20%20%20userErrors%20%7B%0A%20%20%20%20%20%20field%0A%20%20%20%20%20%20message%0A%20%20%20%20%7D%0A%20%20%20%20inventoryAdjustmentGroup%20%7B%0A%20%20%20%20%20%20createdAt%0A%20%20%20%20%20%20reason%0A%20%20%20%20%20%20referenceDocumentUri%0A%20%20%20%20%20%20changes%20%7B%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20delta%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22input%22%3A%20%7B%0A%20%20%20%20%22reason%22%3A%20%22correction%22%2C%0A%20%20%20%20%22referenceDocumentUri%22%3A%20%22logistics%3A%2F%2Fsome.warehouse%2Ftake%2F2023-01-23T13%3A14%3A15Z%22%2C%0A%20%20%20%20%22setQuantities%22%3A%20%5B%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22inventoryItemId%22%3A%20%22gid%3A%2F%2Fshopify%2FInventoryItem%2F30322695%22%2C%0A%20%20%20%20%20%20%20%20%22locationId%22%3A%20%22gid%3A%2F%2Fshopify%2FLocation%2F124656943%22%2C%0A%20%20%20%20%20%20%20%20%22quantity%22%3A%2042%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22inventoryItemId%22%3A%20%22gid%3A%2F%2Fshopify%2FInventoryItem%2F113711323%22%2C%0A%20%20%20%20%20%20%20%20%22locationId%22%3A%20%22gid%3A%2F%2Fshopify%2FLocation%2F124656943%22%2C%0A%20%20%20%20%20%20%20%20%22quantity%22%3A%2013%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%0A%20%20%7D%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, { variables: { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } }, }, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }", "variables": { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, { variables: { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, "variables": { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } }, }, }); ``` ##### Ruby ``` session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } } QUERY variables = { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "input": { "reason": "correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "setQuantities": [ { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943", "quantity": 42 }, { "inventoryItemId": "gid://shopify/InventoryItem/113711323", "locationId": "gid://shopify/Location/124656943", "quantity": 13 } ] } } ``` ## Response JSON ```json { "inventorySetOnHandQuantities": { "userErrors": [], "inventoryAdjustmentGroup": { "createdAt": "2024-09-12T01:05:46Z", "reason": "Inventory correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "name": "available", "delta": 31 }, { "name": "available", "delta": 12 }, { "name": "on_hand", "delta": 31 }, { "name": "on_hand", "delta": 12 } ] } } } ```