Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Bulk Inventory Updates for a location via API

Bulk Inventory Updates for a location via API

Luke_f
Shopify Partner
9 0 2

Hi all,

 

I'm trying to workout how to bulk update inventory via API for a single location.

 

I've tried the rest API and can update one item at one location, but it won't allow multiple inventory_item_ID updates at a location.

 

I also found the below mutation here: https://www.shopify.com/ca/partners/blog/multi-location_and_graphql 

 

 

 

mutation {
  inventoryBulkAdjustQuantityAtLocation(
    locationId: "gid://shopify/Location/1",
    inventoryItemAdjustments: [
      {inventoryItemId: "gid://shopify/InventoryItem/1", availableDelta: 1},
      {inventoryItemId: "gid://shopify/InventoryItem/2", availableDelta: 10}
      ]) {

    inventoryLevels {
      available
    }
  }
}

 

 

 

 

have edited it to my location IDs and inventory, but am getting the below response without updates.

 

 

 

mutation {
  inventoryBulkAdjustQuantityAtLocation(
    locationId: "gid://shopify/Location/67933143202",
    inventoryItemAdjustments: [
      {inventoryItemId: "gid://shopify/InventoryItem/7085453803682", availableDelta: 99},
      {inventoryItemId: "gid://shopify/InventoryItem/7085453508770", availableDelta: 99}
      {inventoryItemId: "gid://shopify/InventoryItem/7085453476002", availableDelta: 99}
      {inventoryItemId: "gid://shopify/InventoryItem/7085453410466", availableDelta: 99}
      ]) {
    inventoryLevels {
      available
    }
  }
}

 

 

 

 

{
  "data": {
    "inventoryBulkAdjustQuantityAtLocation": {
      "inventoryLevels": null
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1990,
        "restoreRate": 100
      }
    }
  }
}

 

Any ideas on what I'm missing here?

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 527

Hi Luke_f,

 

When testing that format of updating multiple items at once in a test store it worked ok. That "inventoryLevels": null value was replicable by doing a couple different things intentionally as a test which leads to these suggestions:

 

  • confirm the location id number to be the value that shows in the web admin in the Settings > Locations area in the URL bar when viewing the specific location, as using a random number for the location id produced that null value
  • make sure that each of those inventory items is already stocked/activated at the specified location, because if even one of the items in the list wasn't then the null value was produced. In GraphQL that can be done with the [inventoryActivate] mutation

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog