FROM CACHE - en_header

Rest API Create an Item and Update Inventory Levels

Solved
Akoehler
New Member
2 0 0

I am trying to create an item using the Rest API which I can successfully do. I was wondering how do I update inventory as well for that item. My issue is I am not sure of what my Item Id is as it gets created at run time and there is no way via the interface to see the ID's assigned to items unless you pull them through the API. How would I add an item via Rest and then update the inventory? 

Accepted Solution (1)

Accepted Solutions
SBD_
Shopify Staff
Shopify Staff
1098 146 224

This is an accepted solution.

Hey @Akoehler,

 

This is a two step process:

 

1. Create the product, the response will contain variant ID(s).

2. Use the variant ID to update the inventory.

Scott | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

View solution in original post

Replies 2 (2)
SBD_
Shopify Staff
Shopify Staff
1098 146 224

This is an accepted solution.

Hey @Akoehler,

 

This is a two step process:

 

1. Create the product, the response will contain variant ID(s).

2. Use the variant ID to update the inventory.

Scott | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

Zap1798
New Member
2 0 0

Hello! 

I am trying too bulk update variants in my Shopify store via their inventory levels. I update them one at a time, each in their own request. However, when I perform the action of passing all the products that need to be updated with their location id, inventory item id and available quantity using a PUT request to the url ending with

/admin/api/2022-01/inventory_levels/set.json and according to these instructions: Manage product inventory with the Admin API (shopify.dev)

every variant that is associated with a product, gets deleted. For example, before updating quantities, Variant A will have a quantity of 8, Variant B will have a quantity of 18, and Variant C will have a quantity of 4. After running the workflow to set each quantity to 5, Variant A will have a quantity of 5 but Variant B and C will not exist. I have seen threads of this happening to people before but am looking for a more updated solution as those threads are quite old. Any help is appreciated!