Anchor to inventoryAdjustQuantitiesinventory
inventory Adjust Quantities
mutation
Requires access scope. Also: The user must have a permission to apply changes to inventory quantities.
Apply changes to inventory quantities.
Anchor to Arguments
Arguments
- Anchor to inputinput•Inventory
Adjust Quantities Input!required The information required to adjust inventory quantities.
Was this section helpful?
- Anchor to inventoryAdjustmentGroupinventory•
Adjustment Group The group of changes made by the operation.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) {6 inventoryAdjustQuantities(input: $input) {7 userErrors {8 field9 message10 }11 inventoryAdjustmentGroup {12 createdAt13 reason14 referenceDocumentUri15 changes {16 name17 delta18 }19 }20 }21 }`,22 {23 variables: {24 "input": {25 "reason": "correction",26 "name": "available",27 "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13",28 "changes": [29 {30 "delta": -4,31 "inventoryItemId": "gid://shopify/InventoryItem/30322695",32 "locationId": "gid://shopify/Location/124656943"33 }34 ]35 }36 },37 },38);3940const data = await response.json();41
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-04/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();
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"
}
]
}
},
},
});
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)
Input variables
JSON1{2 "input": {3 "reason": "correction",4 "name": "available",5 "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13",6 "changes": [7 {8 "delta": -4,9 "inventoryItemId": "gid://shopify/InventoryItem/30322695",10 "locationId": "gid://shopify/Location/124656943"11 }12 ]13 }14}
Response
JSON1{2 "inventoryAdjustQuantities": {3 "userErrors": [],4 "inventoryAdjustmentGroup": {5 "createdAt": "2024-11-07T21:47:12Z",6 "reason": "Inventory correction",7 "referenceDocumentUri": "logistics://some.warehouse/take/2023-01/13",8 "changes": [9 {10 "name": "available",11 "delta": -412 },13 {14 "name": "on_hand",15 "delta": -416 }17 ]18 }19 }20}