Quick Overview
This workflow receives a stock feed via webhook, validates and expands SKU rows, then syncs per-location inventory levels to Medusa by matching inventory items by SKU and returning a JSON report of synced and missing items.
How it works
- Receives a POST webhook request containing a
stock_location_id and an items array of SKUs and quantities.
- Validates the payload and converts each item into a normalized row with
sku, stocked_quantity, and stock_location_id.
- For each row, queries Medusa for an inventory item that matches the SKU.
- If a matching Medusa inventory item exists, sets the absolute inventory level for that item at the provided stock location in Medusa.
- If no matching inventory item exists, records a
not_found result for the SKU without creating any new inventory records.
- Aggregates all row results into a sync report and responds to the webhook with HTTP 200 when all items sync, or HTTP 207 when some SKUs are missing.
Setup
- Configure Medusa credentials in n8n for the Medusa nodes (Medusa backend URL and an API token/secret).
- Copy the production webhook URL for the “medusa-inventory-sync” endpoint and configure your WMS/ERP to POST stock updates to it.
- Ensure your sender posts
stock_location_id and an items array with sku and non-negative integer stocked_quantity values.
- Verify the target Medusa store already contains Inventory Items for every SKU you plan to send and that the referenced stock location IDs exist.