Sage 100 Shopify integration: stock levels and web orders
How a Sage 100 Shopify integration works - publishing stock from Sage, matching SKUs, and getting web orders back into Sage as sales orders.
A Sage 100 Shopify integration has two jobs that move in opposite directions. Stock and prices flow from Sage to Shopify, so the store never sells what the warehouse does not have. Orders flow from Shopify to Sage, so the warehouse ships and accounting invoices without retyping. The first is a read from Sage and is easy. The second is a write and is where most of the work is.
The data that has to line up
| Shopify | Sage 100 | Notes |
|---|---|---|
| Variant SKU | CI_Item.ItemCode | The join key. Make them identical before you start |
| Inventory level at a location | IM_ItemWarehouse.QuantityOnHand minus committed | Pick one Sage warehouse per Shopify location |
| Variant price | CI_Item.StandardUnitPrice or a price level | B2B stores often need customer pricing instead |
| Customer | AR_Customer (division + customer number) | Many stores post all web orders to one cash customer |
| Order | SO_SalesOrderHeader + SO_SalesOrderDetail | Created through BOI so tax and pricing rules run |
Direction 1: stock from Sage to Shopify
Read item quantities from Sage on a schedule and set the matching inventory levels in Shopify. Every 15 minutes is a common compromise; faster is rarely needed for B2B volumes.
// Node 18+. Reads items from the Greenbar sandbox, then sets Shopify stock for matching SKUs.
const SAGE = "https://api.greenbar.octor.top/v1/companies/ABC";
const SHOP = `https://${process.env.SHOP}.myshopify.com/admin/api/2024-07/graphql.json`;
async function sageItems() {
const r = await fetch(`${SAGE}/items?limit=100`, { headers: { Authorization: "Bearer sk_test_demo" } });
return (await r.json()).data; // [{ item_code, quantity_on_hand, ... }]
}
async function shopify(query, variables) {
const r = await fetch(SHOP, {
method: "POST",
headers: { "X-Shopify-Access-Token": process.env.SHOPIFY_TOKEN, "Content-Type": "application/json" },
body: JSON.stringify({ query, variables }),
});
return r.json();
}
const SET_QTY = `mutation ($input: InventorySetQuantitiesInput!) {
inventorySetQuantities(input: $input) { userErrors { field message } }
}`;
const items = await sageItems();
const quantities = items
.filter((i) => skuToInventoryItem[i.item_code]) // your SKU -> inventoryItemId map
.map((i) => ({ inventoryItemId: skuToInventoryItem[i.item_code], locationId: process.env.LOCATION_ID,
quantity: Math.max(0, i.quantity_on_hand) }));
await shopify(SET_QTY, { input: { name: "available", reason: "correction", ignoreCompareQuantity: true, quantities } });Build the skuToInventoryItem map once from Shopify's product variants and cache it. Check the field names against the Shopify API version you use; the inventory mutations changed across 2024 releases.
Direction 2: orders from Shopify to Sage
Subscribe to Shopify's orders/create webhook. For each order:
- Find or create the Sage customer. Decide early whether consumer orders go to one cash customer.
- Create a Sage sales order with one line per item, using Sage item codes.
- Let Sage calculate tax and price, or pass Shopify's prices explicitly and mark the difference rule.
- Store the Sage sales order number on the Shopify order (as a note or metafield) so support can find it.
Step 2 is a write, so it goes through the Business Object Interface (SO_SalesOrder_bus) on the Sage server, or through an API that wraps BOI. In the Greenbar sandbox, POST /sales-orders answers 403 with a waitlist link: write access is in private beta.
Common problems
- SKUs that almost match.
BRK-1001in Sage andBRK1001in Shopify. Fix the data, not the code. - Selling committed stock. Quantity on hand includes stock already promised to open orders. Subtract committed quantities or keep a buffer.
- Duplicate orders. Webhooks can arrive twice. Use the Shopify order ID as an idempotency key before creating the Sage order.
- Tax differences. If Shopify calculates tax and Sage recalculates it, totals drift by cents. Pick one system as the tax authority.
Related: Sync Sage 100 stock levels with Node.js and WooCommerce integration.
curl "https://api.greenbar.octor.top/v1/companies/ABC/items?below_reorder=true" \ -H "Authorization: Bearer sk_test_demo"
A REST API for Sage 100, self-serve
One HTTPS endpoint and a typed SDK instead of BOI scripts and ODBC DSNs on every customer's server. Read access is free during the beta.
Join the waitlist