Most multichannel ecommerce backends are built the same way: a cron job polls each channel's API every 10–15 minutes, syncs inventory and moves on. It works at low volume. At scale it silently destroys you.
Here's why, and how webhook-driven architecture fixes it.
The polling problem in one scenario
You sell on Shopify, Amazon, and eBay. You have 3 units left of your best-selling SKU. At 11:52pm three customers buy simultaneously — one per channel. Your polling job last ran at 11:45. It runs again at 12:00. By then all three orders are confirmed. You have 3 oversells, 3 cancellation emails, and 2 marketplace penalties. Nothing threw an error. Everything "worked."
Webhook-driven sync fixes the race condition
Instead of your system asking each channel "anything new?" on a schedule, each channel tells your system the moment something happens.
javascript
// Register webhook on channel connect
await shopify.webhook.create({
topic: 'orders/create',
address: 'https://your-oms.com/webhooks/shopify',
format: 'json'
});
// Handle incoming webhook
app.post('/webhooks/shopify', async (req, res) => {
const order = req.body;
// Verify signature first
const hmac = req.headers['x-shopify-hmac-sha256'];
if (!verifySignature(hmac, req.rawBody)) {
return res.status(401).send('Unauthorized');
}
// Decrement inventory across all channels immediately
await inventory. decrementAllChannels (order.line_items);
res.status(200).send('OK');
});
Every channel fires its webhook the moment an order lands. Your system decrements inventory across all other channels within seconds. The oversell window shrinks from 15 minutes to near zero.
Handle failures properly
Webhooks fail. Channels retry but your system needs to be idempotent:
javascript
async function processOrder(orderId, lineItems) {
// Idempotency check — don't process the same order twice
const existing = await db.orders.findOne({ externalId: orderId });
if (existing) return;
await db.orders.create({ externalId: orderId, status: 'processing' });
await inventory.decrementAllChannels(lineItems);
}
The result
Webhook-driven multichannel selling infrastructure means inventory accuracy in seconds not minutes, zero recurring API polling load, and race conditions eliminated at the architectural level not patched around.
If you'd rather not build this yourself, Nventory handles exactly this architecture across 30+ channels out of the box - webhook-driven, idempotent, retry-safe. Free plan available.
Top comments (0)