Sync Inventory Across Platforms
Keep stock levels synchronized between SyncBooks and your e-commerce store, warehouse system, or other platforms.
Strategy: Webhook-Driven Sync
The most reliable approach:
1
SyncBooks POS sale → webhook fires pos.sale_completed
2
Your server receives the event → extracts products & quantities sold
3
Updates stock on your e-commerce platform (Shopify, WooCommerce, etc.)
Reading Current Stock
Get Product Stock
curl https://api.syncbooksapp.com/api/v1/products?search=WM-001 \
-H "Authorization: Bearer sk_live_YOUR_KEY"
# Response includes:
# "currentStock": 23,
# "reorderLevel": 10,
# "trackInventory": trueUpdating Stock from External Systems
When stock changes externally (new shipment received, warehouse transfer):
Stock Adjustment
curl -X POST https://api.syncbooksapp.com/api/v1/products/PRODUCT_ID/stock-adjustment \
-H "Authorization: Bearer sk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "increase",
"quantity": 100,
"reason": "New shipment from supplier - PO-2026-0042"
}'Full Sync Example (Node.js)
Sync SyncBooks → Shopify
// Listen for SyncBooks webhook
app.post('/webhooks/syncbooks', async (req, res) => {
const { event, data } = req.body;
if (event === 'pos.sale_completed') {
// For each product in the sale, update Shopify stock
for (const item of data.lineItems) {
const sku = item.sku;
// Get current SyncBooks stock
const products = await fetch(
`https://api.syncbooksapp.com/api/v1/products?search=${sku}`,
{ headers: { Authorization: `Bearer ${SYNCBOOKS_KEY}` } }
).then(r => r.json());
const currentStock = products.data[0]?.currentStock ?? 0;
// Update Shopify
await updateShopifyInventory(sku, currentStock);
}
}
res.status(200).send('OK');
});
// Reverse: Shopify order → Update SyncBooks
app.post('/webhooks/shopify/order-created', async (req, res) => {
const { line_items } = req.body;
for (const item of line_items) {
// Find product by SKU in SyncBooks
const products = await fetch(
`https://api.syncbooksapp.com/api/v1/products?search=${item.sku}`,
{ headers: { Authorization: `Bearer ${SYNCBOOKS_KEY}` } }
).then(r => r.json());
const productId = products.data[0]?._id;
if (!productId) continue;
// Decrease stock
await fetch(`https://api.syncbooksapp.com/api/v1/products/${productId}/stock-adjustment`, {
method: 'POST',
headers: { Authorization: `Bearer ${SYNCBOOKS_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'decrease',
quantity: item.quantity,
reason: `Shopify order #${req.body.order_number}`
})
});
}
res.status(200).send('OK');
});Low Stock Alerts
Use the product.low_stock webhook event to get notified when products hit their reorder level. Then auto-create purchase orders or notify your team.