inventory Bulk Toggle Activationmutation
Requires write
access scope. Also: The user must have a permission to update the activation status of an inventory.
Modify the activation status of an inventory item at locations. Activating an inventory item at a particular location allows that location to stock that inventory item. Deactivating an inventory item at a location removes the inventory item's quantities and turns off the inventory item from that location.
Arguments
The ID of the inventory item to modify the activation status locations for.
A list of pairs of locations and activate status to update for the specified inventory item.
InventoryBulkToggleActivationPayload returns
The inventory item that was updated.
The activated inventory levels.
The list of errors that occurred from executing the mutation.
Code examples for MUTATION: inventoryBulkToggleActivation
Query Reference for MUTATION: inventoryBulkToggleActivation
"mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n # InventoryItem fields\n }\n inventoryLevels {\n # InventoryLevel fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: inventoryBulkToggleActivation
"{\n \"inventoryItemId\": \"gid://shopify/<objectName>/10079785100\",\n \"inventoryItemUpdates\": [\n {\n \"activate\": true,\n \"locationId\": \"gid://shopify/<objectName>/10079785100\"\n }\n ]\n}"
Schema Reference for MUTATION: inventoryBulkToggleActivation
"input InventoryBulkToggleActivationInput {\n activate: Boolean!\n locationId: ID!\n}\n"
Display Examples for MUTATION: inventoryBulkToggleActivation
[ { "example": { "type_name": "inventorybulktoggleactivation", "title": "Activate an inventory item at a location", "query_string": "mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "inventoryItemUpdates": [ { "locationId": "gid://shopify/Location/648019273", "activate": true } ] }, "response": { "data": { "inventoryBulkToggleActivation": { "inventoryItem": { "id": "gid://shopify/InventoryItem/30322695" }, "inventoryLevels": [ { "id": "gid://shopify/InventoryLevel/30691503?inventory_item_id=30322695", "quantities": [ { "name": "available", "quantity": 0 } ], "location": { "id": "gid://shopify/Location/648019273" } } ], "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/inventory/test/unit/graph_api/admin/mutations/inventory_bulk_toggle_activation_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) { inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) { inventoryItem { id } inventoryLevels { id quantities(names: [\\\"available\\\"]) { name quantity } location { id } } userErrors { field message code } } }\",\n \"variables\": {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/648019273\",\n \"activate\": true\n }\n ]\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/648019273\",\n \"activate\": true\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [{\"locationId\"=>\"gid://shopify/Location/648019273\", \"activate\"=>true}]\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/648019273\",\n \"activate\": true\n }\n ]\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"inventoryItemId\" => \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\" => [{\"locationId\"=>\"gid://shopify/Location/648019273\", \"activate\"=>true}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "inventoryItemId", "description": "The ID of the inventory item to modify the activation status locations for.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "inventoryItemId", "argValue": " \"gid://shopify/InventoryItem/30322695\"", "typeKind": "MUTATION" }, { "arg": { "name": "inventoryItemUpdates", "description": "A list of pairs of locations and activate status to update for the specified inventory item.", "type": { "kind": "INPUT_OBJECT", "name": "InventoryBulkToggleActivationInput", "list": true, "non_null": true }, "defaultValue": null, "typeSignature": "[InventoryBulkToggleActivationInput!]!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "inventoryItemUpdates", "argValue": " [{\"locationId\":\"gid://shopify/Location/648019273\",\"activate\":true}]", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "inventorybulktoggleactivation", "title": "Deactivate an inventory item at a location", "query_string": "mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "inventoryItemUpdates": [ { "locationId": "gid://shopify/Location/124656943", "activate": false } ] }, "response": { "data": { "inventoryBulkToggleActivation": { "inventoryItem": { "id": "gid://shopify/InventoryItem/30322695" }, "inventoryLevels": [], "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/inventory/test/unit/graph_api/admin/mutations/inventory_bulk_toggle_activation_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) { inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) { inventoryItem { id } inventoryLevels { id } userErrors { field message code } } }\",\n \"variables\": {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/124656943\",\n \"activate\": false\n }\n ]\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/124656943\",\n \"activate\": false\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [{\"locationId\"=>\"gid://shopify/Location/124656943\", \"activate\"=>false}]\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/124656943\",\n \"activate\": false\n }\n ]\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"inventoryItemId\" => \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\" => [{\"locationId\"=>\"gid://shopify/Location/124656943\", \"activate\"=>false}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "inventoryItemId", "description": "The ID of the inventory item to modify the activation status locations for.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "inventoryItemId", "argValue": " \"gid://shopify/InventoryItem/30322695\"", "typeKind": "MUTATION" }, { "arg": { "name": "inventoryItemUpdates", "description": "A list of pairs of locations and activate status to update for the specified inventory item.", "type": { "kind": "INPUT_OBJECT", "name": "InventoryBulkToggleActivationInput", "list": true, "non_null": true }, "defaultValue": null, "typeSignature": "[InventoryBulkToggleActivationInput!]!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "inventoryItemUpdates", "argValue": " [{\"locationId\":\"gid://shopify/Location/124656943\",\"activate\":false}]", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "inventorybulktoggleactivation", "title": "Toggle an inventory item's activation at two locations", "query_string": "mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "inventoryItemId": "gid://shopify/InventoryItem/30322695", "inventoryItemUpdates": [ { "locationId": "gid://shopify/Location/124656943", "activate": false }, { "locationId": "gid://shopify/Location/648019273", "activate": true } ] }, "response": { "data": { "inventoryBulkToggleActivation": { "inventoryItem": { "id": "gid://shopify/InventoryItem/30322695" }, "inventoryLevels": [ { "id": "gid://shopify/InventoryLevel/30691503?inventory_item_id=30322695", "quantities": [ { "name": "available", "quantity": 0 } ], "location": { "id": "gid://shopify/Location/648019273" } } ], "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/inventory/test/unit/graph_api/admin/mutations/inventory_bulk_toggle_activation_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) { inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) { inventoryItem { id } inventoryLevels { id quantities(names: [\\\"available\\\"]) { name quantity } location { id } } userErrors { field message code } } }\",\n \"variables\": {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/124656943\",\n \"activate\": false\n },\n {\n \"locationId\": \"gid://shopify/Location/648019273\",\n \"activate\": true\n }\n ]\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/124656943\",\n \"activate\": false\n },\n {\n \"locationId\": \"gid://shopify/Location/648019273\",\n \"activate\": true\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [{\"locationId\"=>\"gid://shopify/Location/124656943\", \"activate\"=>false}, {\"locationId\"=>\"gid://shopify/Location/648019273\", \"activate\"=>true}]\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"inventoryItemId\": \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\": [\n {\n \"locationId\": \"gid://shopify/Location/124656943\",\n \"activate\": false\n },\n {\n \"locationId\": \"gid://shopify/Location/648019273\",\n \"activate\": true\n }\n ]\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation inventoryBulkToggleActivation($inventoryItemId: ID!, $inventoryItemUpdates: [InventoryBulkToggleActivationInput!]!) {\n inventoryBulkToggleActivation(inventoryItemId: $inventoryItemId, inventoryItemUpdates: $inventoryItemUpdates) {\n inventoryItem {\n id\n }\n inventoryLevels {\n id\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n location {\n id\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"inventoryItemId\" => \"gid://shopify/InventoryItem/30322695\",\n \"inventoryItemUpdates\" => [{\"locationId\"=>\"gid://shopify/Location/124656943\", \"activate\"=>false}, {\"locationId\"=>\"gid://shopify/Location/648019273\", \"activate\"=>true}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "inventoryItemId", "description": "The ID of the inventory item to modify the activation status locations for.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "inventoryItemId", "argValue": " \"gid://shopify/InventoryItem/30322695\"", "typeKind": "MUTATION" }, { "arg": { "name": "inventoryItemUpdates", "description": "A list of pairs of locations and activate status to update for the specified inventory item.", "type": { "kind": "INPUT_OBJECT", "name": "InventoryBulkToggleActivationInput", "list": true, "non_null": true }, "defaultValue": null, "typeSignature": "[InventoryBulkToggleActivationInput!]!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "inventoryItemUpdates", "argValue": " [{\"locationId\":\"gid://shopify/Location/124656943\",\"activate\":false},{\"locationId\":\"gid://shopify/Location/648019273\",\"activate\":true}]", "typeKind": "MUTATION" } ] } ]