Anchor to section titled 'undefined'

inventoryBulkToggleActivation
mutation

Requires write_inventory 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.


Anchor to inventoryItemId
inventoryItemId
required

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.


Was this section helpful?

The inventory item that was updated.

The activated inventory levels.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
Copy
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
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"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 } } }",
 "variables": {
    "inventoryItemId": "gid://shopify/InventoryItem/30322695",
    "inventoryItemUpdates": [
      {
        "locationId": "gid://shopify/Location/648019273",
        "activate": true
      }
    ]
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  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
      }
    }
  }`,
  {
    variables: {
      "inventoryItemId": "gid://shopify/InventoryItem/30322695",
      "inventoryItemUpdates": [
        {
          "locationId": "gid://shopify/Location/648019273",
          "activate": true
        }
      ]
    },
  },
);

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 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
      }
    }
  }
QUERY

variables = {
  "inventoryItemId": "gid://shopify/InventoryItem/30322695",
  "inventoryItemUpdates": [{"locationId"=>"gid://shopify/Location/648019273", "activate"=>true}]
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "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
        }
      }
    }`,
    "variables": {
      "inventoryItemId": "gid://shopify/InventoryItem/30322695",
      "inventoryItemUpdates": [
        {
          "locationId": "gid://shopify/Location/648019273",
          "activate": true
        }
      ]
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<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
      }
    }
  }
QUERY;

$variables = [
  "inventoryItemId" => "gid://shopify/InventoryItem/30322695",
  "inventoryItemUpdates" => [{"locationId"=>"gid://shopify/Location/648019273", "activate"=>true}],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "inventoryItemId": "gid://shopify/InventoryItem/30322695",
  "inventoryItemUpdates": [
    {
      "locationId": "gid://shopify/Location/648019273",
      "activate": true
    }
  ]
}
Hide code
Response
JSON
{
  "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": []
  }
}