inventory Move Quantitiesmutation
mutation
2024-07
Requires
write_inventory
access scope. Also: The user must have a permission to move an inventory.
Moves inventory between inventory quantity names at a single location.
Arguments
The information required to move inventory quantities.
Was this section helpful?
InventoryMoveQuantitiesPayload returns
Anchor to InventoryMoveQuantitiesPayload.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 inventoryMoveQuantities($input: InventoryMoveQuantitiesInput!, $quantityNames: [String!]) { inventoryMoveQuantities(input: $input) { userErrors { field message code } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes(quantityNames: $quantityNames) { name delta } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation inventoryMoveQuantities($input: InventoryMoveQuantitiesInput!, $quantityNames: [String!]) { inventoryMoveQuantities(input: $input) { userErrors { field message code } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes(quantityNames: $quantityNames) { name delta } } } }", "variables": { "input": { "reason": "damaged", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "quantity": 10, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "from": { "locationId": "gid://shopify/Location/124656943", "name": "available", "ledgerDocumentUri": null }, "to": { "locationId": "gid://shopify/Location/124656943", "name": "reserved", "ledgerDocumentUri": "logistics://toronto.warehouse/work-orders/2023-01-04/2" } } ] }, "quantityNames": [ "committed", "reserved", "safety_stock", "quality_control", "damaged", "available", "on_hand", "incoming" ] } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation inventoryMoveQuantities($input: InventoryMoveQuantitiesInput!, $quantityNames: [String!]) { inventoryMoveQuantities(input: $input) { userErrors { field message code } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes(quantityNames: $quantityNames) { name delta } } } }`, { variables: { "input": { "reason": "damaged", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "quantity": 10, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "from": { "locationId": "gid://shopify/Location/124656943", "name": "available", "ledgerDocumentUri": null }, "to": { "locationId": "gid://shopify/Location/124656943", "name": "reserved", "ledgerDocumentUri": "logistics://toronto.warehouse/work-orders/2023-01-04/2" } } ] }, "quantityNames": [ "committed", "reserved", "safety_stock", "quality_control", "damaged", "available", "on_hand", "incoming" ] }, }, ); 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 inventoryMoveQuantities($input: InventoryMoveQuantitiesInput!, $quantityNames: [String!]) { inventoryMoveQuantities(input: $input) { userErrors { field message code } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes(quantityNames: $quantityNames) { name delta } } } } QUERY variables = { "input": { "reason": "damaged", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [{"quantity"=>10, "inventoryItemId"=>"gid://shopify/InventoryItem/30322695", "from"=>{"locationId"=>"gid://shopify/Location/124656943", "name"=>"available", "ledgerDocumentUri"=>nil}, "to"=>{"locationId"=>"gid://shopify/Location/124656943", "name"=>"reserved", "ledgerDocumentUri"=>"logistics://toronto.warehouse/work-orders/2023-01-04/2"}}] }, "quantityNames": ["committed", "reserved", "safety_stock", "quality_control", "damaged", "available", "on_hand", "incoming"] } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation inventoryMoveQuantities($input: InventoryMoveQuantitiesInput!, $quantityNames: [String!]) { inventoryMoveQuantities(input: $input) { userErrors { field message code } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes(quantityNames: $quantityNames) { name delta } } } }`, "variables": { "input": { "reason": "damaged", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "quantity": 10, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "from": { "locationId": "gid://shopify/Location/124656943", "name": "available", "ledgerDocumentUri": null }, "to": { "locationId": "gid://shopify/Location/124656943", "name": "reserved", "ledgerDocumentUri": "logistics://toronto.warehouse/work-orders/2023-01-04/2" } } ] }, "quantityNames": [ "committed", "reserved", "safety_stock", "quality_control", "damaged", "available", "on_hand", "incoming" ] }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation inventoryMoveQuantities($input: InventoryMoveQuantitiesInput!, $quantityNames: [String!]) { inventoryMoveQuantities(input: $input) { userErrors { field message code } inventoryAdjustmentGroup { createdAt reason referenceDocumentUri changes(quantityNames: $quantityNames) { name delta } } } } QUERY; $variables = [ "input" => [ "reason" => "damaged", "referenceDocumentUri" => "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes" => [{"quantity"=>10, "inventoryItemId"=>"gid://shopify/InventoryItem/30322695", "from"=>{"locationId"=>"gid://shopify/Location/124656943", "name"=>"available", "ledgerDocumentUri"=>nil}, "to"=>{"locationId"=>"gid://shopify/Location/124656943", "name"=>"reserved", "ledgerDocumentUri"=>"logistics://toronto.warehouse/work-orders/2023-01-04/2"}}], ], "quantityNames" => ["committed", "reserved", "safety_stock", "quality_control", "damaged", "available", "on_hand", "incoming"], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "input": { "reason": "damaged", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "quantity": 10, "inventoryItemId": "gid://shopify/InventoryItem/30322695", "from": { "locationId": "gid://shopify/Location/124656943", "name": "available", "ledgerDocumentUri": null }, "to": { "locationId": "gid://shopify/Location/124656943", "name": "reserved", "ledgerDocumentUri": "logistics://toronto.warehouse/work-orders/2023-01-04/2" } } ] }, "quantityNames": [ "committed", "reserved", "safety_stock", "quality_control", "damaged", "available", "on_hand", "incoming" ] }
Hide code
Response
JSON
{ "inventoryMoveQuantities": { "userErrors": [], "inventoryAdjustmentGroup": { "createdAt": "2024-09-12T01:06:28Z", "reason": "Damaged", "referenceDocumentUri": "logistics://some.warehouse/take/2023-01-23T13:14:15Z", "changes": [ { "name": "available", "delta": -10 }, { "name": "reserved", "delta": 10 } ] } } }