Store API guide
Use Foil & Fils for stock and your website for checkout, payment and fulfilment. Create a key in Workspace settings under Online store. Map each website variant to its exact Foil & Fils item and allocate the copies you can sell online.
Connect your server
Use HTTPS and send the key in the Authorization header from your store backend. Keep it out of storefront JavaScript. Each key belongs to one vendor. Replacing the key retains order history.
Authorization: Bearer YOUR_STORE_KEY
Read available stock
GET /api/store/v1/inventory
The response contains mapped variants, available quantities and the AED currency code. Vendors can also share an asking price in fils and their chosen image. Image kind identifies card art, packaging or vendor photography. Resolve relative image URLs against the Foil & Fils API origin. For a mapped sealed product, incomingAvailable counts unpromised units in confirmed incoming deliveries after pack openings. Show that figure as preorder availability. Use available for stock that can ship now. Keep zero-quantity variants sold out for immediate purchase.
Refresh from your server about every ten seconds while the shop is active. Reuse the ETag in If-None-Match and keep your last result on HTTP 304. Always reserve at checkout. If Foil & Fils is unreachable, pause checkout for these items.
Reserve before charging
PUT /api/store/v1/orders/YOUR_ORDER_ID
Send application/json. Use a stable order ID of up to 100 letters, digits, dots, dashes or underscores, starting with a letter or digit. Each update is the complete order with an increasing integer version. Reuse the same version and body on retries.
{
"version": 1,
"status": "reserved",
"currency": "AED",
"lines": [
{
"variantId": "ace9-215",
"quantity": 1
}
]
}Proceed only on a reserved receipt with an unexpired expiresAt. A hold lasts ten minutes. Insufficient stock returns 409. A repeated request keeps its original expiry. Send a higher reserved version to change or renew the cart before charging.
Record payment
{
"version": 2,
"status": "paid",
"currency": "AED",
"lines": [
{
"variantId": "ace9-215",
"quantity": 1
}
],
"totalFils": 41000,
"feeFils": 1000
}Here the buyer paid AED 410 for the item and processing cost AED 10. Send the merchandise total after discounts, excluding tax and shipping. Omit unknown fees and supply them in a later version. Foil & Fils does not process the payment. A paid receipt commits the physical sale once. HTTP 202 with needs_review means the payment is awaiting a vendor stock or mapping correction. Keep the order available for reconciliation.
Cancel, refund or return
For an unpaid cancellation send the next version with status cancelled, currency AED and empty lines. After payment keep status paid and send the original lines and total plus cumulative refundedFils. A financial refund leaves physical quantities unchanged.
When the vendor actually receives an item in the same condition, send cumulative restocked on that line and inspectedReturns true. It returns to unallocated inventory. The vendor can allocate it to the website again.
Reconcile an order
GET /api/store/v1/orders/YOUR_ORDER_ID
Compare the returned status and version with your store. Older deliveries return the latest receipt. Conflicting bodies at the same version return 409. Retry transient server failures using the original order ID and version. Website adapters should authenticate their platform notifications before calling Foil & Fils and periodically reconcile orders and inventory.