To automate order fulfillment and inventory updates with n8n, start by creating a webhook node that captures new order events from Shopify's REST API. When an order is placed, the webhook triggers a series of nodes: a HTTP Request node fetches the order details in JSON, a Set node extracts line items, and a second HTTP Request node calls your inventory management system's API to decrement stock levels. After the inventory is adjusted, use another HTTP Request node to update the order's fulfillment status in Shopify, then add a Send Email node (or a Slack node) to notify the fulfillment team. By looping this process with a "Wait" or "IF" node you can handle back-order logic, ensuring both sales channels and inventory remain synchronized in real time.
What you need
| Tool | Plan/Price | Role |
|---|---|---|
| n8n | Free (self-hosted) or $49/month (cloud) | Orchestrator, workflow editor |
| Shopify | Starter plan $29/mo | e-commerce platform, API source |
| Zapier | Free tier (limited runs) or paid | Optional comparison for reference |
| Make.com | Free tier (limited operations) or paid | Optional comparison for reference |
| https://getaab.com/blog/ | N/A | Reference blog for additional n8n examples |
How to build it
- Set up credentials: In n8n, create a new HTTP Request node named "Shopify Auth". Go to Shopify Admin > Settings > Apps and sales channels > Develop apps. Create a custom app with Admin API access scopes:
read_orders,write_orders,read_products, andwrite_products. Grant the app access to your development store. Copy the Admin API access token. In n8n, add a new Credential of type "Header Auth" or "Basic Auth" (depending on your n8n version) and store this token.
- Configure the Webhook Receiver: Add an n8n Webhook node. Set the HTTP Method to
POST. Set the Path toshopify_order_webhook. This endpoint listens for incoming events from Shopify. When enabled, n8n generates a unique URL. Copy this URL.
- Register the Webhook in Shopify: In Shopify Admin, navigate to the custom app you created. Under "Webhooks," add a new subscription. Set the topic to
orders/created. Set the format toJSON. Paste the n8n Webhook URL into the "URL" field. Save. Shopify will now send a signedorders/createdevent to your n8n instance whenever a customer places an order.
- Map and Validate Data: Add an n8n Code node after the Webhook node. This step is critical for filtering noise and normalizing the
jsonpayload. Shopify sends the entire order object, which can be over 50KB. Extract only the fields needed for inventory synchronization:order_id,line_items(sku, quantity), andtotal_price. Use the following snippet to ensure you only act on valid, paid orders:
Note: In the actual Code node, you would use `$('Webhook').item.json.body.order` to access the root order object and filter `line_items` where `sku` is not null.
- Update Inventory via REST API: Add an n8n HTTP Request node. Set the Method to
PUT. Set the URL tohttps://[your-shop-domain].myshopify.com/admin/api/2024-01/products/[product_id].json. Replace[product_id]with the dynamic value from the previous step. In the Body section, selectjsonand construct the payload to decrease the inventory level. For example:{"product": {"inventory_items": [{"inventory_item_id": "[id]", "quantity": -2}]}}. This action directly updates the inventory management dashboard in Shopify.
- Handle Errors and Retry Logic: Add an n8n Error Trigger. If the Shopify API returns a 400-series error (such as insufficient stock), the workflow fails. Connect the Error Trigger to a Slack node to alert your ops team. Do not use silent retries for inventory decrements, as this can lead to overselling. Instead, log the specific
skuandorder_idthat failed.
- Bidirectional Sync Considerations: This workflow currently handles
orders/createdto decrement stock. To make it truly bidirectional, you must handle manual inventory adjustments in Shopify (e.g., if a warehouse worker manually updates stock). Listen for theproducts/updatewebhook topic as well. When a product is manually edited, pause the automated decrement logic for that specific SKU for a short window to prevent race conditions.
- Testing and Deployment: Use the "Execute Workflow" button in n8n to test with a dummy order. Verify that the inventory count in Shopify Admin decreases by the correct amount. Check the execution details in n8n to ensure the HTTP status code is 200. Once verified, activate the workflow. Unlike zapier or make.com, n8n allows you to inspect the raw
jsonresponse at every step, which is essential for debugging complex API interactions. For more advanced routing logic, consider reviewing our guide on advanced workflow patterns.