Anchor to inventoryActivateinventory
inventoryActivate
mutation
Requires access scope. Also: The user must have a permission to activate an inventory item.
Activate an inventory item at a location.
Anchor to Arguments
Arguments
- Anchor to availableavailable•
The initial available quantity of the inventory item being activated at the location.
- Anchor to inventoryItemIdinventory•
Item Id ID!required The ID of the inventory item to activate.
- Anchor to locationIdlocation•
Id ID!required The ID of the location of the inventory item being activated.
- Anchor to onHandon•
Hand The initial on_hand quantity of the inventory item being activated at the location.
Was this section helpful?
Anchor to InventoryActivatePayload returnsInventoryActivatePayload returns
- Anchor to inventoryLevelinventory•
Level The inventory level that was activated.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Activate an inventory item at a location with an initial available quantity
- Activate an inventory item at a location without setting an available quantity
- Connects an inventory item to a location
- inventoryActivate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {
inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
item {
id
}
location {
id
}
}
}
}`,
{
variables: {
"inventoryItemId": "gid://shopify/InventoryItem/43729076",
"locationId": "gid://shopify/Location/346779380",
"available": 42
},
},
);
const data = await response.json();
mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {
inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
item {
id
}
location {
id
}
}
}
}
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 ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) { inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) { inventoryLevel { id quantities(names: [\"available\"]) { name quantity } item { id } location { id } } } }",
"variables": {
"inventoryItemId": "gid://shopify/InventoryItem/43729076",
"locationId": "gid://shopify/Location/346779380",
"available": 42
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {
inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
item {
id
}
location {
id
}
}
}
}`,
{
variables: {
"inventoryItemId": "gid://shopify/InventoryItem/43729076",
"locationId": "gid://shopify/Location/346779380",
"available": 42
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {
inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
item {
id
}
location {
id
}
}
}
}`,
"variables": {
"inventoryItemId": "gid://shopify/InventoryItem/43729076",
"locationId": "gid://shopify/Location/346779380",
"available": 42
},
},
});
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 ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {
inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
item {
id
}
location {
id
}
}
}
}
QUERY
variables = {
"inventoryItemId": "gid://shopify/InventoryItem/43729076",
"locationId": "gid://shopify/Location/346779380",
"available": 42
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"inventoryItemId": "gid://shopify/InventoryItem/43729076",
"locationId": "gid://shopify/Location/346779380",
"available": 42
}
Response
JSON{
"inventoryActivate": {
"inventoryLevel": {
"id": "gid://shopify/InventoryLevel/523463154?inventory_item_id=43729076",
"quantities": [
{
"name": "available",
"quantity": 42
}
],
"item": {
"id": "gid://shopify/InventoryItem/43729076"
},
"location": {
"id": "gid://shopify/Location/346779380"
}
}
}
}