# inventoryActivate - admin-graphql - MUTATION
Version: 2025-01

## Description
Activate an inventory item at a location.

### Access Scopes
`write_inventory` access scope. Also: The user must have a permission to activate an inventory item.


## Arguments
* [available](/docs/api/admin-graphql/2025-01/scalars/Int): Int - The initial available quantity of the inventory item being activated at the location.
* [inventoryItemId](/docs/api/admin-graphql/2025-01/scalars/ID): ID! - The ID of the inventory item to activate.
* [locationId](/docs/api/admin-graphql/2025-01/scalars/ID): ID! - The ID of the location of the inventory item being activated.
* [onHand](/docs/api/admin-graphql/2025-01/scalars/Int): Int - The initial on_hand quantity of the inventory item being activated at the location.
* [stockAtLegacyLocation](/docs/api/admin-graphql/2025-01/scalars/Boolean): Boolean - Allow activation at or away from fulfillment service location with sku sharing off. This will deactivate inventory at all other locations.


## Returns
* [inventoryLevel](/docs/api/admin-graphql/2025-01/objects/InventoryLevel): InventoryLevel The inventory level that was activated.
* [userErrors](/docs/api/admin-graphql/2025-01/objects/UserError): UserError! The list of errors that occurred from executing the mutation.


## Examples
### Activate an inventory item at a location with an initial available quantity
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } }\",\n \"variables\": {\n    \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n    \"locationId\": \"gid://shopify/Location/346779380\",\n    \"available\": 42\n  }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n  data: {\n    \"query\": `mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {\n      inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {\n        inventoryLevel {\n          id\n          quantities(names: [\"available\"]) {\n            name\n            quantity\n          }\n          item {\n            id\n          }\n          location {\n            id\n          }\n        }\n      }\n    }`,\n    \"variables\": {\n      \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n      \"locationId\": \"gid://shopify/Location/346779380\",\n      \"available\": 42\n    },\n  },\n});\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 ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {\n    inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {\n      inventoryLevel {\n        id\n        quantities(names: [\"available\"]) {\n          name\n          quantity\n        }\n        item {\n          id\n        }\n        location {\n          id\n        }\n      }\n    }\n  }\nQUERY\n\nvariables = {\n  \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n  \"locationId\": \"gid://shopify/Location/346779380\",\n  \"available\": 42\n}\n\nresponse = client.query(query: query, variables: variables)\n" 
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n  `#graphql\n  mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {\n    inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {\n      inventoryLevel {\n        id\n        quantities(names: [\"available\"]) {\n          name\n          quantity\n        }\n        item {\n          id\n        }\n        location {\n          id\n        }\n      }\n    }\n  }`,\n  {\n    variables: {\n      \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n      \"locationId\": \"gid://shopify/Location/346779380\",\n      \"available\": 42\n    },\n  },\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!, $available: Int) {\n  inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {\n    inventoryLevel {\n      id\n      quantities(names: [\"available\"]) {\n        name\n        quantity\n      }\n      item {\n        id\n      }\n      location {\n        id\n      }\n    }\n  }\n}"
#### Graphql Input
{
  "inventoryItemId": "gid://shopify/InventoryItem/43729076",
  "locationId": "gid://shopify/Location/346779380",
  "available": 42
}
#### Graphql Response
{
  "data": {
    "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"
        }
      }
    }
  }
}

### Activate an inventory item at a location without setting an available quantity
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!) { inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) { inventoryLevel { id quantities(names: [\\\"available\\\"]) { name quantity } item { id } location { id } } } }\",\n \"variables\": {\n    \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n    \"locationId\": \"gid://shopify/Location/346779380\"\n  }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n  data: {\n    \"query\": `mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!) {\n      inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n        inventoryLevel {\n          id\n          quantities(names: [\"available\"]) {\n            name\n            quantity\n          }\n          item {\n            id\n          }\n          location {\n            id\n          }\n        }\n      }\n    }`,\n    \"variables\": {\n      \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n      \"locationId\": \"gid://shopify/Location/346779380\"\n    },\n  },\n});\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 ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!) {\n    inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n      inventoryLevel {\n        id\n        quantities(names: [\"available\"]) {\n          name\n          quantity\n        }\n        item {\n          id\n        }\n        location {\n          id\n        }\n      }\n    }\n  }\nQUERY\n\nvariables = {\n  \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n  \"locationId\": \"gid://shopify/Location/346779380\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" 
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n  `#graphql\n  mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!) {\n    inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n      inventoryLevel {\n        id\n        quantities(names: [\"available\"]) {\n          name\n          quantity\n        }\n        item {\n          id\n        }\n        location {\n          id\n        }\n      }\n    }\n  }`,\n  {\n    variables: {\n      \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n      \"locationId\": \"gid://shopify/Location/346779380\"\n    },\n  },\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation ActivateInventoryItem($inventoryItemId: ID!, $locationId: ID!) {\n  inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n    inventoryLevel {\n      id\n      quantities(names: [\"available\"]) {\n        name\n        quantity\n      }\n      item {\n        id\n      }\n      location {\n        id\n      }\n    }\n  }\n}"
#### Graphql Input
{
  "inventoryItemId": "gid://shopify/InventoryItem/43729076",
  "locationId": "gid://shopify/Location/346779380"
}
#### Graphql Response
{
  "data": {
    "inventoryActivate": {
      "inventoryLevel": {
        "id": "gid://shopify/InventoryLevel/523463154?inventory_item_id=43729076",
        "quantities": [
          {
            "name": "available",
            "quantity": 0
          }
        ],
        "item": {
          "id": "gid://shopify/InventoryItem/43729076"
        },
        "location": {
          "id": "gid://shopify/Location/346779380"
        }
      }
    }
  }
}

### Connects an inventory item to a location
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation InventoryActivate($inventoryItemId: ID!, $locationId: ID!) { inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) { inventoryLevel { id canDeactivate createdAt item { id } location { id } quantities(names: [\\\"available\\\"]) { name quantity } updatedAt } } }\",\n \"variables\": {\n    \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n    \"locationId\": \"gid://shopify/Location/346779380\"\n  }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n  data: {\n    \"query\": `mutation InventoryActivate($inventoryItemId: ID!, $locationId: ID!) {\n      inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n        inventoryLevel {\n          id\n          canDeactivate\n          createdAt\n          item {\n            id\n          }\n          location {\n            id\n          }\n          quantities(names: [\"available\"]) {\n            name\n            quantity\n          }\n          updatedAt\n        }\n      }\n    }`,\n    \"variables\": {\n      \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n      \"locationId\": \"gid://shopify/Location/346779380\"\n    },\n  },\n});\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 InventoryActivate($inventoryItemId: ID!, $locationId: ID!) {\n    inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n      inventoryLevel {\n        id\n        canDeactivate\n        createdAt\n        item {\n          id\n        }\n        location {\n          id\n        }\n        quantities(names: [\"available\"]) {\n          name\n          quantity\n        }\n        updatedAt\n      }\n    }\n  }\nQUERY\n\nvariables = {\n  \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n  \"locationId\": \"gid://shopify/Location/346779380\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" 
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n  `#graphql\n  mutation InventoryActivate($inventoryItemId: ID!, $locationId: ID!) {\n    inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n      inventoryLevel {\n        id\n        canDeactivate\n        createdAt\n        item {\n          id\n        }\n        location {\n          id\n        }\n        quantities(names: [\"available\"]) {\n          name\n          quantity\n        }\n        updatedAt\n      }\n    }\n  }`,\n  {\n    variables: {\n      \"inventoryItemId\": \"gid://shopify/InventoryItem/43729076\",\n      \"locationId\": \"gid://shopify/Location/346779380\"\n    },\n  },\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation InventoryActivate($inventoryItemId: ID!, $locationId: ID!) {\n  inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId) {\n    inventoryLevel {\n      id\n      canDeactivate\n      createdAt\n      item {\n        id\n      }\n      location {\n        id\n      }\n      quantities(names: [\"available\"]) {\n        name\n        quantity\n      }\n      updatedAt\n    }\n  }\n}"
#### Graphql Input
{
  "inventoryItemId": "gid://shopify/InventoryItem/43729076",
  "locationId": "gid://shopify/Location/346779380"
}
#### Graphql Response
{
  "data": {
    "inventoryActivate": {
      "inventoryLevel": {
        "id": "gid://shopify/InventoryLevel/523463154?inventory_item_id=43729076",
        "canDeactivate": true,
        "createdAt": "2024-11-07T20:59:45Z",
        "item": {
          "id": "gid://shopify/InventoryItem/43729076"
        },
        "location": {
          "id": "gid://shopify/Location/346779380"
        },
        "quantities": [
          {
            "name": "available",
            "quantity": 0
          }
        ],
        "updatedAt": "2024-11-07T20:59:45Z"
      }
    }
  }
}