انتقل إلى المحتوى الرئيسي

inventory.updated

Fired when an inventory record is updated in the store.

Event Structure

{
"event_type": "inventory.updated",
"payload": { ... }
}

Payload

{
"id": "6753a1b2c3d4e5f6a7b8c9d0",
"product_id": "6753a1b2c3d4e5f6a7b8c9d1",
"product": {
"_id": "6753a1b2c3d4e5f6a7b8c9d1",
"title": "Classic Cotton T-Shirt",
"handle": "classic-cotton-t-shirt",
"pricing": {
"price": 4500,
"compareAtPrice": 6000
},
"images": [
{
"_id": "img_001",
"file": "tshirt-front.jpg",
"fileUrl": "https://cdn.example.com/images/tshirt-front.jpg"
}
]
},
"variant_id": "6753a1b2c3d4e5f6a7b8c9d2",
"variant": {
"_id": "6753a1b2c3d4e5f6a7b8c9d2",
"options": [
{
"_id": "val_001",
"label": "Black",
"type": "color",
"value": "Black",
"colorCode": "#000000"
}
],
"pricing": {
"price": 4500,
"compareAtPrice": 6000
},
"quantity": 50,
"images": [
{
"_id": "img_002",
"file": "tshirt-black.jpg",
"fileUrl": "https://cdn.example.com/images/tshirt-black.jpg"
}
]
},
"store_id": "store_abc123",
"warehouse": {
"_id": "wh_001",
"name": "Main Warehouse",
"location": "Riyadh"
},
"quantity": 85,
"status": "in_stock",
"lowStockThreshold": 10,
"expiryDate": null,
"createdAt": "2025-12-01T10:30:00.000Z",
"updatedAt": "2025-12-05T14:15:00.000Z"
}

Payload Fields

FieldTypeDescription
idstringUnique inventory record ID
product_idstringAssociated product ID
productobjectPopulated product data
product._idstringProduct ID
product.titlestringProduct title
product.handlestringProduct URL slug
product.pricingobjectProduct pricing info
product.imagesarrayProduct images
variant_idstring | nullAssociated variant ID
variantobject | nullPopulated variant data
variant._idstringVariant ID
variant.optionsarraySelected option values
variant.pricingobjectVariant pricing
variant.quantitynumberVariant quantity
variant.imagesarrayVariant images
store_idstringStore ID
warehouseobject | nullWarehouse info
warehouse._idstringWarehouse ID
warehouse.namestringWarehouse name
warehouse.locationstringWarehouse location
quantitynumberInventory quantity
statusstringInventory status (e.g. in_stock, out_of_stock)
lowStockThresholdnumberLow stock alert threshold
expiryDatestring | nullExpiry date if applicable
createdAtstringISO 8601 creation timestamp
updatedAtstringISO 8601 last update timestamp

Example Handler

app/routes/webhooks.inventory.tsx
import { authenticate } from "~/qumra.server";

export async function action({ request }: { request: Request }) {
const { payload, topic, storeId } =
await authenticate.admin(request);

if (topic === "inventory.updated") {
console.log(`Inventory updated: ${payload.id} - Qty: ${payload.quantity}`);

if (payload.quantity <= payload.lowStockThreshold) {
console.log(`Low stock alert for: ${payload.product.title}`);
// Send low stock notification, trigger reorder, etc.
}
}

return Response.json({ success: true });
}