Shopify Inventory Reorder Agent for Accurate Stock Planning
Learn how a Shopify inventory reorder agent forecasts days of cover, weighs promotions and supplier lead times, and drafts purchase orders for review.

A Shopify inventory reorder agent reads inventory levels and recent orders to forecast stock needs, weighs promotions and lead times from email, and drafts purchase orders for a buyer to approve. Building this process clearly separates code, agent judgment, and human decisions to make reordering reliable and auditable.
This guide covers one Shopify process end to end. For the Shopify API guide, connection setup and the full list of Shopify use cases, see More Shopify use cases.
Why This Process Breaks Today
Manual inventory reorder planning stalls for several reasons:
- Inventory snapshots quickly go stale if sales pick up during a promotion.
- Staff must chase recent order data across systems, risking missed or double-counted items.
- Supplier lead times often arrive buried in email threads or as notes in spreadsheets, so buyers estimate them by memory.
- Promotions are not consistently captured in the logic, leading to under- or over-ordering.
- Drafting a purchase order typically means copying line items into spreadsheets or email, which is slow and error-prone.
- There is little traceability across tools if a reorder turns out to be off.
When Shopify, ShipStation, Gmail, and Google Sheets are not coordinated, buyers lose visibility and spend hours chasing data instead of reviewing and approving high-quality drafts.
The Systems and Data Involved
Shopify
- Inventory Levels: Read from the InventoryLevel API. This returns stock by location and SKU.
- Recent Orders: Collect using the Order API. This includes line items, fulfillments, and created/closed dates.
- Products and Variants: Product and Variant APIs for SKU info and associations.
ShipStation
- Shipments Data: For cross-checking stock position and fulfillment speed if needed.
- Status Sync: Helps align with physical movements.
Gmail
- Supplier Lead Times: Parsed from recent supplier emails, usually in the form of lead time updates, backorder notices, or estimated ship dates.
- Promotions: Occasionally communicated over email, affecting expected sales lift.
Google Sheets
- Promotions Calendar: Reference data for past and future events, lifts from prior campaigns, or manual overrides for expected demand.
- Buyer Notes: Historic lead times, preferred suppliers, or adjustment factors.
What Belongs to Code, Agent, and Human
Code
- Fetch Shopify inventory levels, recent orders, and variants.
- Calculate simple rolling averages or basic sales forecasts.
- Lookup planned promotions from a Google Sheet.
- Compile relevant emails from Gmail by keyword or sender.
Agent Judgment
- Read recent emails for updated supplier lead times, ambiguous language, or changes in product terms.
- Extract expected sales lift from promotions described in prose rather than a calendar field.
- Decide whether a given supplier lead time in email applies to the SKU in question.
- Flag edge cases, such as unusually large or small sales spikes, for human review.
Human Approval
- Final approval of generated purchase order drafts before transmission to suppliers.
- Manual override to adjust order quantities based on strategic or urgent needs.
Worked Example: A Realistic Record Step-Through
Consider this scenario:
- InventoryLevel API: SKU ABC123 at Warehouse X has current quantity 18.
- Order API: Past 14 days, ABC123 sold: 5, 4, 6, 7, 8, 6, 9, 5, 7, 8, 6, 10, 9, 7 (total: 97, daily avg: ~7).
- Google Sheets Promotions: Next week's Black Friday promotion is flagged. Last year, this lifted daily sales of similar SKUs by 60%.
- Gmail Email: Supplier "QuickParts" emailed two days ago, "Holiday shipping will extend lead times by 7 days for all widgets including ABC123. Total lead time 21 days."
- Google Sheets Notes: Supplier historically delivers in 14 days, now pulled to 21.
Process Walkthrough:
- System code pulls stock (18 units) and recent sales trends (7/day avg), expects Black Friday boost (7 x 1.6 = 11.2 per day).
- Agent reviews the Gmail lead time message, associates the new lead time of 21 days with SKU ABC123, and checks for promotion impact.
- Code forecasts needed units: 11.2 x 21 = 235.2 units required to cover the period until replenishment (round up as needed).
- On-hand: 18 units, shortfall: 235 - 18 = 217 units.
- Agent drafts a purchase order for 217 units, referencing the promotion date and supplier lead time, then routes it to the buyer.
- Human sees draft, notes the agent’s flagged comment on abnormal sales jump, and decides whether to raise or lower the order based on business context.
How to Build It on Major
App: Deterministic Code Layer
- Shopify Connector: Read
/admin/api/2024-01/inventory_levels.jsonand/admin/api/2024-01/orders.jsonfor stock and sales. - Google Sheets Connector: Query promo calendar (tab:
Promotions, columns:Date,SKU,Multiplier). - Gmail Connector: Fetch emails in last X days from supplier domains. Pass text to extraction agent.
Agent: Judgment Layer
- Input: Inventory, sales, proposed order qty, promo data, supplier email.
- Tasks:
- Determine if promotions or lead time updates apply to each SKU.
- Parse ambiguous supplier email text for updated lead time or other conditions.
- Flag anomalies (e.g., a sales spike not explained by a promotion).
- Assemble a purchase order draft, including all relevant context and supporting evidence from emails or sheets.
Workflow: Orchestration and Approval
- Trigger: Scheduled (e.g., every Monday morning) or triggered by low inventory alert from Shopify webhook
inventory_levels/update. - Steps:
- Run data pull app functions.
- Pass outputs to the agent for synthesis.
- Agent creates purchase order draft.
- Buyer is notified. Review queue is populated with draft and evidence.
- Human approval or manual adjustment before final order transmission.
- Logging: Each step is logged with context, making the process auditable.
What to Measure
- Coverage Accuracy: Track actual days of cover achieved vs. forecast (preventing both under- and over-ordering).
- Lead Time Variance: Compare supplier lead time assumptions extracted by the agent to real delivery dates.
- Promotion Prediction Accuracy: Check if the agent’s estimated sales lift aligns with the real outcome during promotion periods.
- Draft Approval Rate: Measure the percent of agent-drafted POs approved with minimal changes.
Guardrails
- Never Send POs Directly: Agent must only draft, never transmit, purchase orders to suppliers.
- No Irreversible Stock Movements: Agent cannot cancel Shopify inventory or trigger real fulfillment events.
- Always Surface Ambiguities: If the agent detects conflicting or unclear supplier lead times, or unexplained sales spikes, these are flagged for human review.
- Respect Scope: Only review Gmail threads within the dedicated purchase planning inbox, not all mail.
- Do Not Overwrite Originals: Agent-generated notes, calculations, and drafts must never overwrite source Google Sheets, emails, or order data.
Frequently asked questions
How does the agent identify supplier lead times in Gmail?
The agent scans emails from supplier addresses for phrases such as 'lead time', 'days to ship', or specific product mentions. It extracts dates or durations and links them to the relevant SKU, flagging ambiguous messages for buyer review.
What Shopify API endpoints provide inventory and sales data?
Inventory is read from the InventoryLevel endpoint, while sales and order information come from the Order endpoint. The Product and Variant endpoints help map SKUs to inventory records.
Can the agent adjust for sales due to upcoming promotions?
Yes, the agent reads Google Sheets for planned promotions and parses related emails. It adjusts its forecast for days of cover based on estimated sales lift from these sources.
Does the agent place orders automatically?
No, the agent only drafts purchase orders and routes them to a human buyer for approval. It never transmits orders directly or makes irreversible changes.
Start building on Major
Connect Shopify, describe the process, and Major builds the app that holds its state, the agent that makes the judgment call and the workflow that runs it, with scoped access and an audit log from the first deploy.
Frequently asked questions
- How do Shopify AI agents automate workflows with Shopify data?
- Shopify AI agents use the Shopify API to read, analyze, and act on data such as orders, customers, and products. They can trigger follow-ups, flag risks, and run cross-tool workflows that escalate issues or automate resolution.
- Do Shopify AI agents replace Shopify's built-in automation features?
- No, agents on Major complement Shopify's native automation by handling tasks that span multiple systems or require decision-making. Major orchestrates Shopify but does not replace it.
- Which APIs are required to build Shopify AI agents?
- Shopify AI agents work with objects and endpoints like `Orders`, `Customers`, and `Products`, accessed via the GraphQL Admin API or legacy REST Admin API.
- What authentication is needed for Shopify agents and Major apps?
- Shopify requires OAuth for public apps or an admin API access token for custom apps. Each access token must have only the scopes needed for app or agent tasks.
- What are common use cases for Shopify AI agents?
- Common use cases include fraud detection, abandoned cart monitoring, inventory alerts, customer follow-up, and syncing order data to other systems.