inventory Adjust Quantitiesmutation
mutation
2024-01
Requires write
access scope. Also: The user must have a permission to apply changes to inventory quantities.
Apply changes to inventory quantities.
Arguments
The information required to adjust inventory quantities.
Was this section helpful?
InventoryAdjustQuantitiesPayload returns
Anchor to InventoryAdjustQuantitiesPayload.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 inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }", "variables": { "input": { "reason": "correction", "name": "available", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13", "changes": [ { "delta": -4, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943" } ] } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, { variables: { "input": { "reason": "correction", "name": "available", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13", "changes": [ { "delta": -4, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943" } ] } }, }, ); 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 inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } } QUERY variables = { "input": { "reason": "correction", "name": "available", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13", "changes": [{"delta"=>-4, "inventoryItemId"=>"gid://shopify/InventoryItem/30322695", "locationId"=>"gid://shopify/Location/124656943"}] } } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } }`, "variables": { "input": { "reason": "correction", "name": "available", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13", "changes": [ { "delta": -4, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943" } ] } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes { name delta } } } } QUERY; $variables = [ "input" => [ "reason" => "correction", "name" => "available", "referenceDocumentUri" => "logistics://some.warehouse/take/2023-01/13", "changes" => [{"delta"=>-4, "inventoryItemId"=>"gid://shopify/InventoryItem/30322695", "locationId"=>"gid://shopify/Location/124656943"}], ], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "input": { "reason": "correction", "name": "available", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13", "changes": [ { "delta": -4, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "locationId": "gid://shopify/Location/124656943" } ] } }
Hide code
Response
JSON
{ "inventoryAdjustQuantities": { "userErrors": [], "inventoryAdjustmentGroup": { "createdAt": "2024-09-12T01:06:47Z", "reason": "Inventory correction", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13", "changes": [ { "name": "available", "delta": -4 }, { "name": "on_hand", "delta": -4 } ] } } }