inventory Set On Hand Quantitiesmutation deprecated
mutation
2025-01release candidate
Requires
write_inventory
access scope. Also: The user must have a permission to update an inventory.
Set inventory on-hand quantities using absolute values. Use inventory
to set on_hand or available quantites instead.
Arguments
The information required to set inventory on hand quantities.
Was this section helpful?
InventorySetOnHandQuantitiesPayload returns
Anchor to InventorySetOnHandQuantitiesPayload.inventoryAdjustmentGroupinventoryAdjustment Group The group of changes made by the operation.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
Copy
mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/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 } ] } } }'
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 data = await response.json();
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)
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 } ] } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $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]);
Hide code
Input variables
Copy
{ "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 } ] } }
Hide code
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 } ] } } }