What is This Webhook For?¶
This webhook endpoint receives order events from Snipcart and automatically updates your inventory in Sanity CMS. When a customer completes an order, your inventory decreases. When a refund is issued, inventory increases.
Your Webhook Endpoint¶
Your site has a dedicated webhook endpoint for Snipcart:
https://yoursite.webfacemedia.dev/api/webhooks/snipcartReplace "yoursite" with your actual subdomain.
Setup Steps¶
1. Log into Snipcart Dashboard¶
Go to app.snipcart.com/dashboard
2. Navigate to Webhooks¶
Go to Settings → Webhooks
3. Add Your Webhook URL¶
Click Add webhook
Paste your webhook URL:
https://yoursite.webfacemedia.dev/api/webhooks/snipcart4. Select Events¶
Choose which events should trigger webhooks:
order.completed - Decreases inventory when order is paid
order.refund.created - Increases inventory when refund is issued
Note: These are the only two events needed for inventory sync.
5. Save Configuration¶
Click Save to activate the webhook
What Happens Automatically¶
Once configured, your site will automatically:
• Update product inventory in Sanity CMS when orders complete
• Restore inventory when refunds are issued
• Handle both simple products and product variants
• Prevent overselling by keeping inventory accurate
Testing Your Webhook¶
Test Mode¶
In Snipcart test mode:
1. Place a test order with a test credit card
2. Check Snipcart dashboard → Webhooks → Logs to see if webhook was sent
3. Go to Sanity Studio → Products and verify inventory decreased
4. Issue a refund and verify inventory increased
Common Issues¶
Webhook Not Receiving Events¶
Check:
• URL is correct (no typos, correct subdomain)
• Site is deployed and accessible (not localhost)
• Events are selected in Snipcart dashboard
• Check Snipcart webhook logs for error messages
Inventory Not Updating¶
Verify:
• Product SKUs in Snipcart match SKUs in Sanity
• Inventory tracking is enabled for the product in Sanity
• Check Vercel function logs for webhook processing errors
