Everything you need to know about how FreshGuard AI works under the hood โ data storage, webhooks, API, and CSV format.
FreshGuard AI is a Shopify-embedded app built with React Router v7 and @shopify/shopify-app-react-router. It uses Shopify Metaobjects as its primary datastore, meaning all your batch data lives directly on Shopify's infrastructure โ not on a third-party server. This gives you:
Data Flow:
Shopify order โ orders/create webhook โ FreshGuard FEFO engine โ Metaobject update โ Order tag + metafield write
Each inventory batch is stored as a Shopify Metaobject of type $app:inventory_batch. The schema fields are:
| Field Key | Type | Description | Required |
|---|---|---|---|
| batch_number | single_line_text_field | Unique lot/batch identifier (e.g. LOT-2026A) | โ |
| expiry_date | date | Expiry date in ISO format (YYYY-MM-DD) | โ |
| initial_quantity | number_integer | Stock quantity when the batch was first created | โ |
| current_quantity | number_integer | Current remaining stock (decremented by FEFO) | โ |
| batch_status | single_line_text_field | Active | Out of stock | Expired | โ |
| location_id | single_line_text_field | Shopify Location GID for multi-location tracking | |
| barcode | single_line_text_field | Standard barcode string | |
| gtin | single_line_text_field | GS1 GTIN barcode for industry compliance | |
| invoice_number | single_line_text_field | Supplier invoice or reference number | |
| cost_per_unit | number_decimal | Unit cost for financial analytics and wastage | |
| supplier | single_line_text_field | Supplier or vendor name |
Batch-to-variant association is stored as a JSON array in a productVariant.metafield(namespace: "$app:inventory", key: "batches_data") field.
Use the bulk CSV feature in the Batches tab โ Import or Analytics โ Export. The file must use these exact column headers:
| Column Name | Format / Example | Required? |
|---|---|---|
| sku | STRING โ e.g. APPLE-RED-001 | โ for import |
| batch_number | STRING โ e.g. LOT-2026A | โ |
| expiry_date | DATE โ YYYY-MM-DD (e.g. 2026-09-30) | โ |
| initial_quantity | INTEGER โ e.g. 500 | โ |
| current_quantity | INTEGER โ e.g. 320 | โ |
| batch_status | Active | Out of stock | Expired | โ |
| barcode | STRING โ optional barcode value | |
| gtin | STRING โ GS1 GTIN (e.g. 00012345678905) | |
| cost_per_unit | DECIMAL โ e.g. 2.50 | |
| location_id | Shopify Location GID | |
| invoice_number | STRING โ e.g. INV-2024-0012 | |
| supplier | STRING โ e.g. FreshFoods Ltd. |
FreshGuard subscribes to the following Shopify webhooks automatically upon installation:
orders/createTriggers FEFO engine. Deducts batch quantities, tags the order with the Batch Number, and writes the consumed_batches metafield for traceability.
app/uninstalledTriggers automatic deletion of all session data and store configuration from FreshGuard's database within 48 hours.
shop/redact (GDPR)Triggers full erasure of all store data from FreshGuard systems, as required by Shopify's GDPR compliance.
customers/redact (GDPR)Triggers erasure of any identifiable customer data FreshGuard may hold.
customers/data_request (GDPR)Provides any customer data FreshGuard holds upon request.
FreshGuard exposes a public JSON endpoint via Shopify's App Proxy at /apps/freshguard/expiry. This endpoint is callable from Liquid themes and JavaScript without authentication.
REQUEST
GET /apps/freshguard/expiry?variant_id={shopify_variant_id}
RESPONSE (200 OK)
{
"expiry_date": "2026-09-30",
"batch_number": "LOT-2026A",
"days_remaining": 113,
"is_expiring_soon": false
}Free
$0/month
Pro
$9.00/month
Every batch event is stored as a JSON array in a shop-level metafield at namespace $app:settings, key batch_history. The array is capped at the most recent 500 events to stay within Shopify's metafield size limits.
Each event object contains: { batchNumber, action, quantityChange, orderId, timestamp, note }. Action types: batch_created, batch_deducted, batch_expired, batch_updated.
The Recall Report cross-references the consumed_batches order metafield (written by the FEFO webhook) against all Shopify orders. Given a batch number, it returns a list of orders containing that batch, including: Order ID, Customer Name, Customer Email, Order Date, and Quantity Consumed. The result can be exported as a CSV for food safety and regulatory outreach. This feature requires FEFO order tagging to have been active when orders were placed.
ยฉ 2026 Sumadroid ยท Privacy Policy ยท sumadroid.com