Inventory API Idempotency

Hello. I’m working with a very large merchant who occasionally has flash-sales and other high velocity sales events (>10k+orders/hr) - and when this happens, we have had big problems with oversells. This is because we do live availability synchronization, as inventory levels are constantly changing due to receiving, returns, etc. We have considered a number of different solutions to this, including turning off inventory level updating during the day, and only running it during the wee hours to reduce the likelihood of collision with any material volume of order events. This near-realtime inventory synchronization is highly desirable for our merchant(s) because a single nightly bulk synchronization loses an average of 12 hours of sales potential for items which have just come back into stock (Also note that international sales may make the time-based approach less effective)

The mechanism of action here is that orders and the automatic availability deductions come in fast, and it is literally impossible to pull all the orders and allocate inventory in our system before more orders come in. Crucially with any latency in this process whatsoever, the inventory levels we send throughout the day as inventory arrives/moves through our warehouses are sent to shopify without visibility into those orders which we have not yet seen.

As such, simply setting inventorylevel on any schedule is unworkable. I don’t know if there are any unpublished APIs we could use which might help us address this (like asserting physical inventory, or deducting uncollected orders, etc)

But my assumption is that there are not. As such, the only remaining options that I can see pertain to the inventory adjustment API. This is a logical choice, as expressing deltas would seem to be highly robust against this scenario.

However, unlike some other parts of the Shopify API, I don’t see any idempotence semantics advertised on the inventory api, nor is there any way for us to implement idempotence ourselves by comparing an inventory transaction history to our expected history, because no such API surface seems to exist.
I believe this is important, because a single api call which fails (or experiences an indeterminate result) will cause the delta in question to be unapplied/misapplied, and the numbers will drift, leading to over (or under) selling.

I have attempted to reach out via our support channels, but haven’t had much luck.

Any suggestions for how we might address this / and how we get ahold of a person to talk to this about?

Thank you

Hi RetailOps,

It sounds like you’re dealing with a fairly complex issue. Since real-time inventory synchronization is critical for your merchant due to high sales volume and constantly shifting inventory, it makes sense to look for a solution that can handle this kind of dynamic environment.

Here are some suggestions:

  1. Webhooks: Instead of polling Shopify for order updates, consider using webhooks. Webhooks can notify your app whenever an order is created, updated, or deleted. This way, your system can immediately react to new orders and adjust the inventory accordingly.

  2. Inventory APIs: You’re correct in thinking that leveraging the inventory adjustment API is a good way to handle this. The inventoryAdjustQuantitiesmutation can be used to increment or decrement the available inventory for an inventory item at a specific location. However, as you pointed out there’s no way to check the transaction history against your records.

  3. Bulk Operations API: Another option to consider is the Bulk Operations API. This API allows you execute a large number of API calls asynchronously, which might help manage the volume of transactions.

Please feel free to DM too if you have specific questions that I can help with.