Relationship between product webhooks and inventory_item webhooks

I’m trying to get a better understanding of the relationship between the products and inventory_items webhooks, more specifically the inventory_items/create webhook. I was hoping to find a breakdown of different scenarios in the docs, but I didn’t see any.

Is there any scenario where one might receive an inventory_items/create webhook without a corresponding products/create or products/update webhook message? It seems like a reasonable assumption that creating an inventory_item would HAVE to trigger one of those 2 product webhooks since inventory_items have a 1-to-1 relationship with product variants, and creating a new inventory_item would generate a new inventory_item_id, which would have to initialize or update the inventory_item_id on a product variant. However, I can’t find anything that confirms that assumption.

Can someone please confirm whether the creation of an InventoryItem will always trigger a products/update or products/create webhook?

1 Like

I think that is a reasonable assumption, but Shopify does not guarantee that webhooks are delivered and does also not guarantee the order of webhook delivery, so I think you’d be better off presuming that you can get them in the wrong order or you might not get one.

About webhooks.
Best practices for webhooks

1 Like

Yeah, now that you mention it I remember reading about the non-guarantees so I guess I’ll just assume the worst and hope for the best. In the webhook topics reference they have example payloads for products/create and products/update where the variant.inventory_item_id is null and I wish they would at least update the docs to provide examples of situations where that might actually be the case. I’ve never seen a product webhook in the real world with null inventory_item_ids, but the fact that they have it as an example payload gives me pause…

1 Like

To second what @Mike_Parkin said, I don’t think there’s a situation where you’d get an inventory_items/create webhook without a products/update or products/create message. If you’re just interesting in keeping track of the inventory item ID listening on the product webhooks should be sufficient.

The docs say that inventoryItem is non-null for the variants so I think that’s a safe assumption. The webhook payload docs don’t include the inventory item ID but just looking at them they also omit values for fields like options which should be present.

If you are going to use inventory_items/create though one thing to keep in mind is that occasionally you’ll receive it before a products webhook so you’ll need to be able to handle those cases too

1 Like

Yeah, it’s a bit concerning there’s so much disconnect between related sections of the docs. That makes it pretty hard to trust anything I see or read. I’ve left doc feedback in several spots in relation to this, but who knows if any will ever read that feedback.

Good thing this community exists :grinning:

Added inventory