Anchor to section titled 'undefined'

inventoryDeactivate
mutation

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

Removes an inventory item's quantities from a location, and turns off inventory at the location.


Anchor to inventoryLevelId
inventoryLevelId
required

The ID of the inventory level to deactivate.


Was this section helpful?

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
Copy
mutation inventoryDeactivate($inventoryLevelId: ID!) {
  inventoryDeactivate(inventoryLevelId: $inventoryLevelId) {
    userErrors {
      message
    }
  }
}
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 inventoryDeactivate($inventoryLevelId: ID!) { inventoryDeactivate(inventoryLevelId: $inventoryLevelId) { userErrors { message } } }",
 "variables": {
    "inventoryLevelId": "gid://shopify/InventoryLevel/820859520?inventory_item_id=826867926"
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation inventoryDeactivate($inventoryLevelId: ID!) {
    inventoryDeactivate(inventoryLevelId: $inventoryLevelId) {
      userErrors {
        message
      }
    }
  }`,
  {
    variables: {
      "inventoryLevelId": "gid://shopify/InventoryLevel/820859520?inventory_item_id=826867926"
    },
  },
);

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 inventoryDeactivate($inventoryLevelId: ID!) {
    inventoryDeactivate(inventoryLevelId: $inventoryLevelId) {
      userErrors {
        message
      }
    }
  }
QUERY

variables = {
  "inventoryLevelId": "gid://shopify/InventoryLevel/820859520?inventory_item_id=826867926"
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation inventoryDeactivate($inventoryLevelId: ID!) {
      inventoryDeactivate(inventoryLevelId: $inventoryLevelId) {
        userErrors {
          message
        }
      }
    }`,
    "variables": {
      "inventoryLevelId": "gid://shopify/InventoryLevel/820859520?inventory_item_id=826867926"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation inventoryDeactivate($inventoryLevelId: ID!) {
    inventoryDeactivate(inventoryLevelId: $inventoryLevelId) {
      userErrors {
        message
      }
    }
  }
QUERY;

$variables = [
  "inventoryLevelId" => "gid://shopify/InventoryLevel/820859520?inventory_item_id=826867926",
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "inventoryLevelId": "gid://shopify/InventoryLevel/820859520?inventory_item_id=826867926"
}
Hide code
Response
JSON
{
  "inventoryDeactivate": {
    "userErrors": []
  }
}