Anchor to section titled 'undefined'

inventoryActivate
mutation

Requires write_inventory access scope. Also: The user must have a permission to activate an inventory item.

Activate an inventory item at a location.


The initial available quantity of the inventory item being activated at the location.

Anchor to inventoryItemId
inventoryItemId
required

The ID of the inventory item to activate.

Anchor to locationId
locationId
required

The ID of the location of the inventory item being activated.

The initial on_hand quantity of the inventory item being activated at the location.


Was this section helpful?

The inventory level that was activated.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
Copy
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-01/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();
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)
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
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$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]);
Hide code
Input variables
Copy
{
  "inventoryItemId": "gid://shopify/InventoryItem/43729076",
  "locationId": "gid://shopify/Location/346779380",
  "available": 42
}
Hide code
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"
      }
    }
  }
}