Anchor to inventorySetOnHandQuantitiesinventory
inventorySetOnHandQuantities
mutationDeprecated
Requires access scope. Also: The user must have a permission to update an inventory.
Set inventory on-hand quantities using absolute values. Use to set on_hand or available quantites instead.
Anchor to Arguments
Arguments
- Anchor to inputinput•
The information required to set inventory on hand quantities.
Was this section helpful?
Anchor to InventorySetOnHandQuantitiesPayload returnsInventorySetOnHandQuantitiesPayload returns
- 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?
- Adjust on_hand quantity for 2 items, with reason 'correction'.
- inventorySetOnHandQuantities reference
Examples
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": [
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/2024-04/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();
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
}
]
}
},
},
});
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{
"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
}
]
}
}
}