Track inventory
You sell physical goods and need every sale to come out of real stock: no selling the last mug twice, no counts that drift from the shelf. Flint keeps stock per Location, holds units while a buyer pays, and records every change as a movement you can trace.
This guide follows one mug from arriving at a warehouse to leaving on a shipment. Then it covers what most integrations add next: syncing counts from another system, holding stock for a cart you run yourself, selling from several Locations, and stock operations such as counts and transfers. The Inventory API reference has the full quantity model and every rule.
How Flint models stock#
An inventory item is the thing you stock. A Location is where you stock it. An inventory level is one item at one Location, and it carries the quantities. A catalog variant points at an inventory item instead of holding its own count, so several variants can sell from one pool of stock.
A level has more than one number, because stock can be on the shelf and already promised to someone:
| Quantity | Meaning |
|---|---|
on_hand_quantity | Physically present, in any condition |
quality_control_quantity, damaged_quantity, quarantined_quantity | On hand but not sellable |
held_quantity | Claimed by an open hold, such as a buyer who is paying |
committed_quantity | Paid for and still on the shelf until it ships |
backordered_quantity | Units waiting for stock. Separate from held and committed units, so it never changes available_quantity or shortage_quantity |
safety_stock_quantity | Withheld from sale on purpose |
available_quantity | What you can still sell: on hand, less the unsellable conditions, holds, commitments, and safety stock. Never below 0 |
You never write a level directly. You record what happened, such as "25 arrived" or "the WMS counted 40", and Flint works out the change against the level as it is when your command commits. Quantity states lists every field, including shortage_quantity for claims that stock no longer covers.
Backordered units are tentative while their reservation is on a hold and carry the hold's deadline. They become firm when the order that owns them is paid in full. Partial funding, such as one tender of a split payment, doesn't make them firm, but the payment that completes the order does. A level with firm backordered units has available_quantity 0, while tentative ones can sit beside available stock. When stock arrives, Flint fills firm units first, oldest payment first. An item that allows backorders lets direct orders and payment links sell past available stock, and backordered_quantity counts the units waiting; see Sell past available stock and Backorders.
1. Make a Location that can hold stock#
Every Location can hold stock. For Flint to route orders and pickup to that stock, the Location must be active and have inventory_allocation_enabled: true. The flag defaults to false.
curl -X POST https://api.withflintpay.com/v1/locations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Brooklyn warehouse",
"status": "active",
"timezone": "America/New_York",
"address": {
"line1": "120 Kent Avenue",
"city": "Brooklyn",
"state": "NY",
"postal_code": "11249",
"country": "US"
},
"inventory_allocation_enabled": true
}'
Sending inventory_allocation_enabled, even as false, needs the commerce.inventory.allocation.write scope as well as merchants.locations.write. Change it later with PATCH /v1/locations/{location_id}.
Turning allocation off stops routing, not record keeping. Adjustments, counts, transfers, and receipts still work at an inactive Location or one with allocation off; only an archived Location refuses them. Reservations, allocation policies, and routing sources that name a Location with allocation off return 409 ACTION_NOT_ALLOWED with details[0].reason configuration_required.
2. Make a variant that consumes stock#
A variant tracks inventory exactly when it is linked to an inventory item. A variant with no inventory item sells without a stock check, even if it is a physical good. Create the item inline when you create the product:
curl -X POST https://api.withflintpay.com/v1/products \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: product-mug-12-white" \
-H "Content-Type: application/json" \
-d '{
"variant_mode": "simple",
"name": "Ceramic mug",
"product_type": "physical",
"default_variant": {
"sku": "MUG-12-WHT",
"unit_price_money": { "amount": 1800, "currency": "USD" },
"inventory_item": { "name": "Ceramic mug, 12oz, white", "sku": "mug-12-white" }
}
}'
{
"data": {
"product_id": "prod_1kmn0aExample",
"name": "Ceramic mug",
"product_type": "physical",
"default_variant_id": "var_1kmn0aExample",
"default_variant": {
"variant_id": "var_1kmn0aExample",
"sku": "MUG-12-WHT",
"inventory_tracking": "tracked",
"inventory_item_id": "invi_1kmn0aExample"
}
}
}
The response is abridged. inventory_tracking is tracked and inventory_item_id names the new item: keep it, because every stock command uses it. Catalog setup covers the rest of the product model.
- Share one pool of stock. Send
inventory_item_idinstead ofinventory_itemto link a variant to an item you already have. Two variants on one item sell from the same stock, such as a single mug and the same mug in a gift box. - Keep SKUs separate. The inventory item's
skuand the variant'sskuare different fields. Flint doesn't copy or sync one to the other, and the catalog'sskufilters search only variant SKUs. - Find what sells from an item.
GET /v1/products?inventory_item_id=invi_...returns each product with a non-archived variant on that item, once, with the first such variant inmatched_variant. To read every variant of one product that uses the item, pageGET /v1/products/{product_id}/variants?inventory_item_id=invi_....
Catalog order lines inherit tracking from their variant or bundle. An ad hoc order line ("type": "custom") tracks stock only when you give it inventory_demands, each with an inventory_item_id and the quantity_per_line_item_unit that one unit of the line uses. A catalog line can't carry inventory_demands. Every order line reports the result in inventory_snapshot.inventory_tracking.
3. Put stock on the shelf#
Twenty-five mugs arrive at the warehouse. Record that with an adjustment whose reason says what happened:
curl -X POST https://api.withflintpay.com/v1/inventory-adjustments \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: receiving-1842" \
-H "Content-Type: application/json" \
-d '{
"reason": "received",
"occurred_at": "2026-07-21T14:18:00Z",
"source_system": { "type": "wms", "external_source_id": "east-coast-wms" },
"lines": [{
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"quantity": 25
}]
}'
{
"data": {
"inventory_adjustment": {
"inventory_adjustment_id": "invadj_1kmn0aExample",
"reason": "received",
"occurred_at": "2026-07-21T14:18:00Z",
"source_system": { "type": "wms", "external_source_id": "east-coast-wms" },
"lines": [{
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"on_hand_quantity_delta": 25,
"quality_control_quantity_delta": 0,
"damaged_quantity_delta": 0,
"quarantined_quantity_delta": 0,
"inventory_movement_id": "invm_1kmn0aExample"
}]
},
"inventory_levels": [{
"inventory_level_id": "invl_1kmn0aExample",
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"on_hand_quantity": 25,
"held_quantity": 0,
"committed_quantity": 0,
"available_quantity": 25
}]
}
}
The response is abridged. Three things about this request hold for every stock command:
Idempotency-Keyis required. Adjustments, receipts, and reservation creates each move stock every time they run, so a request without the header returns400 INVALID_REQUESTwithdetails[0].paramIdempotency-Key. Flint won't generate a key, because a generated key can't protect the retry that matters: the one where your first request succeeded and the response never reached you. Retry with the same key, and see Idempotency.occurred_atis when the stock moved, not when you told Flint. It is required, along withsource_system.external_source_id, whensource_system.typeispos,wms,erp, orother, and can be at most 5 minutes in the future. A feed that batches overnight still records when each change happened. Provenance has the full rules for these fields andexternal_actor_id.- The response carries the result. Every stock command returns its own resource beside
inventory_levels, the state of each level it touched after it committed, so you don't need a follow-up read. A replay with the same key returns the levels as they were then. Each adjustment line carries theinventory_movement_idit wrote.
The reason decides which fields a line carries. You never send a signed change:
reason | Line fields | Effect |
|---|---|---|
received, returned | quantity, optional condition | Adds quantity to on hand, in condition |
sold, theft, loss | quantity, optional condition | Removes quantity from on hand, from condition |
condition_changed | quantity, to_condition, optional from_condition | Moves units between conditions; on hand stays the same |
counted, correction | Any of on_hand_quantity, quality_control_quantity, damaged_quantity, quarantined_quantity | Sets those quantities to the values you send |
condition and from_condition default to sellable; the other conditions are quality_control, damaged, and quarantined. A correction requires a note. An adjustment holds up to 100 lines, and each line names a different item and Location pair, so stock that arrives in two conditions is a received adjustment followed by a condition_changed one.
received is for stock that is new to you, such as a supplier delivery. returned is for a customer return of units no Flint order or reservation consumed; returned stock covers the rest. Which call records what maps every physical event to its call.
4. Sell it#
Give the order an inventory_routing_source that says where its stock comes from. Orders, quick pay invoices, payment links, and subscription plans use the same input shape. Send type and only the ID for that branch:
type | Required ID |
|---|---|
fixed_location | location_id |
policy | inventory_allocation_policy_id |
policy_revision | inventory_allocation_policy_revision_id |
A missing branch ID returns 400 INVALID_REQUEST with detail REQUIRED at that ID's path. An ID from another branch returns detail INVALID_VALUE, even when its value is empty or null. For quick pay invoices, the path starts with quick_pay.inventory_routing_source.
With one Location, use fixed_location:
curl -X POST https://api.withflintpay.com/v1/orders \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"line_items": [{ "type": "variant", "variant_id": "var_1kmn0aExample", "quantity": 2 }],
"inventory_routing_source": { "type": "fixed_location", "location_id": "loc_1kmn0aExample" }
}'
If most of your sales route the same way, set a default once instead of repeating the source. Send it as inventory.default_routing_source with PATCH /v1/settings, in the same shape:
curl -X PATCH https://api.withflintpay.com/v1/settings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "inventory": { "default_routing_source": { "type": "fixed_location", "location_id": "loc_1kmn0aExample" } } }'
The Location, policy, or policy revision must exist in this environment, or the update returns 404 RESOURCE_NOT_FOUND at its path, such as inventory.default_routing_source.location_id. From then on, an order, added line, quick pay invoice, payment link, subscription plan, inventory reservation, or delivery preview that has tracked demand and omits inventory_routing_source uses the default. Previews use the default; resources the other requests create or change store it as if you had sent it, so changing or clearing the default later doesn't move stock routing for orders, links, plans, or reservations that already exist. A source you send always wins. Send "default_routing_source": null to clear it.
To set a fixed Location as the default, first turn on its inventory_allocation_enabled. If it is off, the update returns 409 ACTION_NOT_ALLOWED with reason configuration_required and names the Location.
From there, the order's payment and fulfillment move the stock. You don't call the inventory API yourself:
| When | What happens to the stock | Level fields |
|---|---|---|
| A buyer selects delivery in a checkout | Flint holds 2 mugs for the selection until its expires_at | held_quantity up 2, available_quantity down 2 |
| An order change releases the selection, such as a new quantity | The selection's hold is released in the same request | held_quantity down 2, available_quantity up 2 |
| A payment for the order begins | Flint holds 2 mugs at the Location, or the payment takes over the selection's hold | held_quantity up 2, available_quantity down 2, unless the selection already holds them |
| The payment succeeds | The hold becomes a commitment | held_quantity down 2, committed_quantity up 2 |
| The payment fails or the attempt is canceled, and the delivery selection is still valid | The hold goes back to the selection until its expires_at | No change |
| The payment fails or the attempt is canceled, with no valid delivery selection | The hold is released | held_quantity down 2, available_quantity up 2 |
| The fulfillment hands the goods off | The commitment is consumed | committed_quantity down 2, on_hand_quantity down 2 |
| An order edit removes the units before any fulfillment claims them | The commitment is released | committed_quantity down 2, available_quantity up 2 |
The order's inventory_reservation_id names the reservation that holds its stock, and GET /v1/inventory-reservations/{inventory_reservation_id} reads it. Reservations Flint holds for orders are read-only through the inventory API.
If a buyer leaves during 3D Secure, Flint holds the stock until the payment attempt ends. The attempt gives the buyer 30 minutes from the start of payment. The reservation's expires_at shows that deadline if it comes before the stock hold's own deadline. If the payment outcome is still unclear, Flint keeps the stock held until it can safely release it.
While that reservation is a delivery selection's hold, a new quantity on a tracked line, a new or removed tracked line, or a new inventory_routing_source releases the selection and its hold together, and the change returns the order with inventory_reservation_id: null. After part of the order is paid, the reservation keeps the stock for the rest of the order, and the same changes return 409 RESOURCE_IN_USE with the reservation in details[0].blocking_resources.
Two checks protect the sale before money moves:
- Tracked demand needs routing. With no default set, orders, payment links, and subscription plans use the active Location in the current environment that has had inventory allocation enabled the longest. Links and plans resolve this implicit source again on use. With no eligible Location and no default, creating an order with a tracked line and no
inventory_routing_sourcereturns400 INVALID_REQUESTwith detailREQUIREDandparaminventory_routing_source, and no order is created. Adding a tracked line to an existing order that has no source returns409 ACTION_NOT_ALLOWEDwith reasonconfiguration_required. Send a source, or setinventory.default_routing_source. - Stock must cover the order, unless the item allows backorders. If no eligible Location can supply the demand at the payment preflight check, Flint refuses the request with
409 INVENTORY_INSUFFICIENTbefore creating a payment attempt. Nothing is charged. Sell past available stock covers items that backorder.
Another buyer can take the last units after preflight but before Flint acquires the hold. Once a payment attempt exists, losing that race returns 200 with the attempt's status: "failed" and status_reason: "inventory_unavailable". Nothing is charged. Read the attempt's status even when the HTTP request succeeds. Replaying the same Idempotency-Key returns the same failed attempt; after correcting the cart or stock, start a new request with a new key.
The failed attempt does not carry per-line shortage quantities. Refresh the order's quote or read inventory levels for current availability. A 409 INVENTORY_INSUFFICIENT response includes shortage details instead.
Each shortage detail names the order_id and order_line_item_id, plus bundle_component_id for a bundle component. It includes requested_quantity, available_quantity, and shortage_quantity. Merchant credentials also receive inventory_item_id. Treat demand_key as opaque. Pay and quote omit param because their requests don't supply the short line's quantity. See Shortage details for reservation requests.
A fixed Location with allocation turned off returns 409 ACTION_NOT_ALLOWED with reason configuration_required, naming the Location, before payment creates an attempt. Turn on its inventory_allocation_enabled and try again with a new Idempotency-Key.
Payment links, quick pay invoices, and subscription plans take an inventory_routing_source too, and Flint holds and commits their stock the same way. A payment link also reports is_sold_out from its source, as an advisory check that takes no hold; the check when payment begins is the one that decides.
When payment succeeds but stock can't be committed#
Rarely, a payment succeeds and its stock still can't be committed. The order then reports an inventory exception:
| Field | Meaning |
|---|---|
inventory_exception_status | paid_inventory_failed while it needs attention, resolved once it's handled |
inventory_exception_reason | What went wrong, such as inventory_deduction_failed, or auto_refund_required and auto_refund_failed when Flint refunds for you. It keeps the original cause after resolution |
inventory_exception_resolution_message | The note you sent when resolving. Buyers can't read it |
A new exception sends order.inventory_exception_created. Fix the stock, then resolve the exception with an optional note of up to 500 characters:
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/resolve-inventory-exception \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "reason_message": "Moved two mugs from the Oakland store and shipped from there." }'
The response is the order, with inventory_exception_status set to resolved and the note in inventory_exception_resolution_message. Resolving an order that has no open exception returns 409 ACTION_NOT_ALLOWED with reason unsupported_state. Refunding the order in full also resolves the exception, without a note. Either way, Flint sends order.inventory_exception_resolved with the updated order.
To have Flint refund instead of waiting for you, set post_payment_inventory_failure_action to auto_refund under inventory.origin_policies in settings. You can choose it per order source, such as checkout or payment_link. Flint handles the exception while inventory_exception_reason is auto_refund_required. If the refund fails and the reason changes to auto_refund_failed, you can resolve the exception yourself.
When an order edit releases stock#
Editing a paid order to remove units releases the stock behind them in the same step that refunds them. Units still on backorder are released first, then committed ones. For committed units, the Location's committed_quantity goes down and available_quantity goes up by the removed quantity. on_hand_quantity doesn't change, because nothing left the shelf. A removed bundle unit releases each of its components, and the release sends inventory_level.updated.
An edit can remove only units that no fulfillment has claimed, so no stock that was handed off is involved. An order with an unresolved inventory exception can't be edited until you resolve it. A refund on its own still never restocks anything: use an edit when the units won't ship, and a Return when goods come back.
Sell past available stock#
An order can't take more than available_quantity unless the item allows backorders. To keep selling a tracked variant past zero, set backorder.enabled to true on its inventory item with PATCH /v1/inventory-items/{inventory_item_id}. The buyer pays now, and the units stock can't cover are backordered: they wait for stock. backorder.limit_quantity caps how many units can wait at once across the item's Locations, and backorder.expected_ship_date is the date lines show for them.
To sell before a launch, give the variant a release_date; see Release dates and pre-orders. Selling a pre-order past stock also needs backorder.enabled. Without it, a pre-order is held from stock like any other order.
How an order backorders:
- One Location per order. An order keeps one Location, so it has one tax origin. Flint prefers a Location that covers every line from stock. Otherwise it takes the first eligible Location, in policy order, that covers every line that can't backorder. There it holds what stock it has and backorders the rest.
- The limit counts every waiting unit, tentative and firm. Concurrent orders can't push the item past
limit_quantity. - A shortfall past the limit fails the payment. The order returns
409 INVENTORY_INSUFFICIENTand nothing is charged.available_quantityin the detail counts the stock available plus the room left under the limit.
A backordered unit is tentative while it sits on a hold, and firm once the order is paid in full:
| When | What happens to the backordered units | Level fields |
|---|---|---|
| A hold begins, at delivery selection or when payment starts | Flint holds the stock it has and backorders the rest. The backordered units are tentative and carry the hold's deadline | held_quantity up by the units in stock, backordered_quantity up by the rest |
| A payment for part of the order succeeds | Held units are committed. Backordered units stay tentative | held_quantity down, committed_quantity up |
| The order is paid in full | Units that stock now covers are committed. The rest become firm | backordered_quantity down by the units committed |
| The payment fails or the hold expires | The hold is released, backordered units included | held_quantity and backordered_quantity down |
| Stock arrives | Firm units are filled, oldest payment first | backordered_quantity down and committed_quantity up by the units filled |
A level with firm backordered units reports available_quantity 0, so a new order can't jump ahead of buyers who already paid. Tentative units can sit beside available stock until their order is paid.
Every stock command that raises sellable stock fills firm units in the same transaction: an adjustment, a transfer receive, an applied count, a return receipt, a release, or a safety stock or condition change. The command's inventory_levels show the levels after the fill, and the movement shows the units in backordered_quantity_delta and committed_quantity_delta. Flint then updates each affected order's lines and version and sends order.updated. Backordered and pre-ordered lines shows what the order reports.
Backordered units can't ship until stock fills them. Fulfill unassigned_quantity minus the line's backordered_quantity; a fulfillment that claims more returns 409 INVENTORY_INSUFFICIENT. Flint creates the fulfillments for a delivery choice only when all of the remaining units are in stock, so create a fulfillment yourself to ship the units you have sooner; Automatic creation waits for stock has the rule. A release date doesn't hold shipping back either: Flint doesn't block a fulfillment before release_date.
A payment link reports is_sold_out: false while the item's limit has room, even with nothing available.
Three kinds of demand never backorder. A bundle component and a reservation you create with POST /v1/inventory-reservations return 409 INVENTORY_INSUFFICIENT when stock falls short. A subscription renewal that stock can't cover keeps waiting in inventory_wait.
5. Ship it#
Committed stock stays in on_hand_quantity until the fulfillment hands the goods off: at dispatch for a shipment or local delivery (or at complete, if it skips dispatch), and at complete for pickup, digital, and service fulfillments. Canceling a fulfillment before that point releases the commitment and moves nothing physically. Refunding money never restocks anything on its own.
A fulfillment draws on stock committed at one Location, so an order routed to two Locations ships as two fulfillments. Fulfill and ship orders covers creating fulfillments, tracking packages, and the emails the buyer receives.
Put returned stock back#
A returned unit re-enters stock when you record what arrived and its condition, never as a side effect of a refund. Which call you use depends on how the units went out:
| How the units went out | How they come back |
|---|---|
| A Flint order, returned through a Flint Return | Record the disposition on the Return. Flint writes the receipt for you at the Location you name, and the Return caps the quantity |
| A Flint order or reservation, returned outside a Return | POST /v1/inventory-receipts, naming the reservation line that consumed the units |
| Sold outside Flint | An adjustment with reason: "returned" |
A receipt line names both inventory_reservation_id and inventory_reservation_line_id, and Flint caps its quantity at what that line consumed less what earlier receipts put back. For an order, the reservation ID is the order's inventory_reservation_id, and the line IDs are on that reservation.
curl -X POST https://api.withflintpay.com/v1/inventory-receipts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: rma-5521-receipt" \
-H "Content-Type: application/json" \
-d '{
"occurred_at": "2026-07-24T09:12:00Z",
"source_system": { "type": "wms", "external_source_id": "east-coast-wms" },
"lines": [{
"inventory_item_id": "invi_1kmn0aExample",
"receiving_location_id": "loc_1kmn0aExample",
"quantity": 1,
"disposition": "sellable",
"inventory_reservation_id": "invr_1kmn0aExample",
"inventory_reservation_line_id": "invrln_1kmn0aExample"
}]
}'
disposition picks the bucket: sellable restocks available stock; quality_control, damaged, and quarantined add stock that is on hand but not sellable; and lost records that the unit never came back and moves no stock. A line missing either reservation field returns 400 INVALID_REQUEST with details[0].code REQUIRED and the field in param. A receipt never adds new stock; a supplier delivery is a received adjustment.
Keep counts in sync with a WMS, POS, or ERP#
When another system also changes stock, send Flint what that system observed or did, with its source_system, so each movement says where it came from.
Report what another system counted#
When another system owns the count, read its Flint inventory level before taking the count and keep the level's physical_version. Send that value as expected_physical_version with the counted adjustment. Flint sets the quantities you send and leaves the others unchanged:
curl -X POST https://api.withflintpay.com/v1/inventory-adjustments \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: wms-count-1842" \
-H "Content-Type: application/json" \
-d '{
"reason": "counted",
"occurred_at": "2026-07-22T06:00:00Z",
"source_system": { "type": "wms", "external_source_id": "east-coast-wms" },
"lines": [{
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"on_hand_quantity": 40,
"source_observation_sequence": 1842,
"expected_physical_version": 7
}]
}'
- Omitted quantities stay as they are. Sending only
on_hand_quantitykeeps damaged, quality control, and quarantined stock. A value below what those conditions already hold returns409 INVENTORY_INSUFFICIENT; send the condition quantities too. source_observation_sequenceorders observations from the same source. Flint refuses a value that isn't greater than the last one it accepted for the same source, item, and Location with409 VERSION_CONFLICTandparamsource_observation_sequence, and applies nothing. Drop that observation. A sequence needs asource_systemwith anexternal_source_id.- A line that matches the level changes nothing. It writes no movement, its
inventory_movement_idisnull, and the level still appears ininventory_levels.
Every counted or correction adjustment with an explicit occurred_at requires expected_physical_version on each line, even with a source sequence. A timestamp cannot prove that a count includes a shipment that was still in progress when the count was taken. Missing or stale physical versions return 409 VERSION_CONFLICT at lines[i].expected_physical_version. Nothing is applied, and the sequence remains available for a corrected request.
Read GET /v1/inventory-levels/{inventory_level_id} before taking the warehouse count. Use its physical_version as the line's expected_physical_version; use 0 for a level that does not exist yet. If stock moves while counting or before the adjustment arrives, take a fresh count after reading the level again and retry with a new Idempotency-Key. Never refresh only the version while reusing an old count. Holds and commitments do not change the physical version, so they do not invalidate the count.
Without a sequence, observations are not ordered against earlier observations from that source. The physical-version check still applies.
Record a sale made outside Flint#
When a sale has already happened at a known Location, such as a POS sale or a marketplace order that has shipped, record it as sold:
curl -X POST https://api.withflintpay.com/v1/inventory-adjustments \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: pos-sale-77310" \
-H "Content-Type: application/json" \
-d '{
"reason": "sold",
"occurred_at": "2026-07-22T15:41:00Z",
"source_system": { "type": "pos", "external_source_id": "front-counter" },
"lines": [{
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"quantity": 2
}]
}'
The stock is already gone, so Flint doesn't check holds or commitments. If the sale takes stock that buyers had claimed, the level reports a shortage_quantity, the affected reservation lines report at-risk quantity, and Flint sends inventory_level.shortage_detected; When stock is promised but missing covers recovery. Flint refuses only a sale that would take on hand, or the named condition, below zero, with 409 INVENTORY_INSUFFICIENT: correct the count with counted and retry. For an order you accepted but haven't shipped, hold the stock instead.
Edit a level you just read#
A stock editor reads a level, shows it to someone, and writes back what they decide. To refuse the write if stock moved in between, send the level's physical_version as expected_physical_version on a counted or correction line; a level that doesn't exist yet reads as 0. A stale value returns 409 VERSION_CONFLICT. Holds and commitments don't change physical_version, so a level that is selling doesn't trip the check.
Holding stock outside a Flint order#
If you run your own cart, storefront, or POS, hold stock yourself before you take payment. POST /v1/inventory-reservations routes the demand and holds it in one step, and holds nothing if the whole request can't be met. Creating and changing reservations needs commerce.inventory.write.
expires_at must be after now and at most 24 hours ahead, so the sample sets it from the clock. This sample holds the stock for 30 minutes. GNU date sets it below; on macOS, use date -u -v+30M +%Y-%m-%dT%H:%M:%SZ.
expires=$(date -u -d '30 minutes' +%Y-%m-%dT%H:%M:%SZ)
curl -X POST https://api.withflintpay.com/v1/inventory-reservations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: cart-1842-hold" \
-H "Content-Type: application/json" \
-d '{
"owner": { "key": "cart_1842" },
"expires_at": "'"$expires"'",
"inventory_routing_source": { "type": "fixed_location", "location_id": "loc_1kmn0aExample" },
"demands": [{ "inventory_item_id": "invi_1kmn0aExample", "quantity": 2 }]
}'
{
"data": {
"inventory_reservation": {
"inventory_reservation_id": "invr_1kmn0aExample",
"owner": { "type": "merchant", "key": "cart_1842" },
"status": "active",
"expires_at": "2026-07-21T15:30:00Z",
"version": 1,
"supported_actions": ["commit", "release"],
"inventory_routing_source": { "type": "fixed_location", "location_id": "loc_1kmn0aExample" },
"lines": [{
"inventory_reservation_line_id": "invrln_1kmn0aExample",
"demand_key": "invi_1kmn0aExample",
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"allocated_quantity": 2,
"held_quantity": 2,
"committed_quantity": 0,
"consumed_quantity": 0
}]
},
"inventory_levels": [{
"inventory_level_id": "invl_1kmn0aExample",
"on_hand_quantity": 25,
"held_quantity": 2,
"available_quantity": 23
}]
}
}
The response is abridged.
owner.keyis your identifier for what holds the stock, such as a cart ID. A key can have one active reservation; a second create returns409 ALREADY_EXISTSwith the existing one indetails[0].current_resource.expires_atis the hold deadline. It defaults to 15 minutes after creation and can be at most 24 hours from now. Once the deadline passes, you can no longer extend or commit the hold. Stock remains held until Flint processes the expired reservation. Flint checks for expired reservations every five seconds and releases any remaining held quantity when it processes the reservation. Committed quantity stays. To give a buyer more time or free stock sooner,PATCH /v1/inventory-reservations/{inventory_reservation_id}with a newexpires_atbefore the hold lapses. Create a new reservation if the hold has lapsed.demandstake 1 to 100 entries. Eachdemand_keydefaults to itsinventory_item_id, so when one item appears twice, such as two cart lines for the same mug, send your owndemand_keyon every demand.splitting_behavior: "single_location"keeps one demand at one Location.
Move the quantity forward with the reservation's lifecycle actions. Each action has its own route and takes cumulative line targets, never deltas:
| When | Route | Line target |
|---|---|---|
| The buyer paid | POST /v1/inventory-reservations/{inventory_reservation_id}/commit | target_committed_quantity |
| You handed the goods off | POST /v1/inventory-reservations/{inventory_reservation_id}/consume | target_consumed_quantity |
| The buyer left, or you canceled after payment | POST /v1/inventory-reservations/{inventory_reservation_id}/release | target_released_from_held_quantity or target_released_from_committed_quantity |
curl -X POST https://api.withflintpay.com/v1/inventory-reservations/invr_1kmn0aExample/commit \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"expected_version": 1,
"lines": [{ "inventory_reservation_line_id": "invrln_1kmn0aExample", "target_committed_quantity": 2 }]
}'
A target says how much should have reached that state by now, so resending a target you already applied succeeds and changes nothing, even after the reservation closes. That makes a retry safe without a key. expected_version is optional; send it to refuse the action if the reservation changed since you read it. Every action returns inventory_reservation and inventory_levels.
supported_actionslists what can change the reservation right now, so a screen can show only the buttons that work. Each value names its route:commitis/commit. An action that isn't listed returns409 ACTION_NOT_ALLOWEDwithsupported_actionsindetails[0].- Commit before
expires_at. After the deadline,commitdrops out ofsupported_actionsand returns409 ACTION_NOT_ALLOWEDwith reasonterminal_status. Committed quantity can still be consumed or released. consumeacceptsprovenancedescribing the handoff, with the sameoccurred_at,source_system, andexternal_actor_idrules as an adjustment.commitandreleasedon't take it.
Your merchant server can carry a cart hold into checkout by sending its ID in inventory_reservation_ids on both POST /v1/delivery-quotes and POST /v1/delivery-selections:
{ "inventory_reservation_ids": ["invr_1kmn0aExample"] }
Add that field to the quote and selection bodies in Collect delivery. Quoting counts your held stock as available to this checkout without changing the reservation. The merchant server selects delivery to transfer matching cart units into the order's hold in one transaction. The order holds those units for up to two minutes. Payment takes over the hold or tries to reserve the stock again if it expired.
The reservations must be active, unexpired, and merchant-created in the same merchant and environment. Both inputs require a merchant credential with delivery write access. A checkout credential sending the field, including an empty array, gets 400 INVALID_REQUEST before Flint looks up any reservation. Each reservation must hold stock matching the selection's inventory items and locations. Unused units stay held; if the cart hold covers only part of the selection, Flint acquires the rest from available stock. Unknown or ineligible IDs return 404 RESOURCE_NOT_FOUND; stock that can no longer cover the selection returns 409 INVENTORY_INSUFFICIENT. Partial adoption keeps the cart reservation active and emits inventory_reservation.updated with its previous line quantities. Full adoption closes it with closed_reason: adopted and emits inventory_reservation.released. A selection that changes the credited IDs, or omits them without an eligible session binding, must acquire its stock again; it cannot rely on the quote's credit. Retrying the same selection with its idempotency key doesn't release or hold more stock.
For buyer-driven delivery checkout, your merchant server can instead bind the IDs when creating the session: send inventory_reservation_ids on POST /v1/checkout-sessions with type: order and an existing order_id. The binding accepts at most 100 unique IDs and cannot be changed. Merchant delivery requests that omit IDs also use it; explicit merchant IDs replace it for that request, including an empty array to disable cart credit. First adopter wins when sessions share a hold. The buyer's quote and selection then use only eligible holds from that session, without receiving or sending reservation IDs. Released, expired, or fully adopted holds drop out of implicit use; stock acquisition and the quote's selection checks still apply. Collect delivery covers the requests and lifecycle.
Without a session binding or merchant-server adoption, release the cart hold before quoting. Order and pay requests don't accept reservation IDs, so an order without delivery still needs this fallback before payment. Without either adoption or release, the cart hold counts against the buyer's availability and can cause 409 INVENTORY_INSUFFICIENT:
curl -X POST https://api.withflintpay.com/v1/inventory-reservations/invr_1kmn0aExample/release \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"lines": [{ "inventory_reservation_line_id": "invrln_1kmn0aExample", "target_released_from_held_quantity": 2 }]
}'
From the delivery selection, Flint holds the selected stock for the order, and payment commits it. An order change that releases the selection, such as a promotion code, releases its hold in the same request: the order the change returns has inventory_reservation_id: null, and the stock is available again. An order write also releases the hold when the provisional selection has expired or is otherwise unusable, including on a subscription renewal order without a checkout session. Without delivery, Flint holds the stock when payment starts. Collect delivery covers the selection.
Reserving stock has the full rules, including the list filters for holds that have lapsed.
Selling from more than one location#
With several Locations, route with an allocation policy instead of fixed_location. The policy ranks Locations into priority groups and says whether an order may be split. Creating and editing policies needs commerce.inventory.policies.write.
curl -X POST https://api.withflintpay.com/v1/inventory-allocation-policies \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "US retail routing",
"status": "active",
"configuration": {
"location_groups": [
{ "location_id": "loc_1kmn0aBrooklyn", "group_priority": 1 },
{ "location_id": "loc_1kmn0aOakland", "group_priority": 2 }
],
"splitting_behavior": "split_when_required",
"maximum_locations_per_assignment": 2
}
}'
Then send {"type": "policy", "inventory_allocation_policy_id": "invp_..."} as the routing source on orders, payment links, and reservations. Routing is deterministic and keeps an order together when it can:
- Eligible Locations are ordered by
group_priority, lowest first, then by location ID. - If one Location can supply the whole request, the first such Location takes all of it.
- Otherwise, with
split_when_required, Flint walks the same order and takes what each Location can supply, using at mostmaximum_locations_per_assignmentLocations. That limit defaults to 10.
single_location fails instead of splitting. Constraints only narrow routing: a demand marked single_location, or a line that must ship whole, stays whole even under split_when_required.
A tracked variant order line currently needs its full quantity at one eligible Location, including checkout and payment, even when its delivery profile uses quantity_split_allowed. A split_when_required policy does not remove this limit. Merchant reservation demands can split when their own splitting_behavior permits it.
To change the routing, PATCH /v1/inventory-allocation-policies/{inventory_allocation_policy_id} with the new configuration and the policy's current expected_version, which is required when you replace configuration. Each configuration is saved as an immutable revision, and the change affects only future routing: reservations and quotes keep the revision they already use, so editing a policy never reroutes stock that is already claimed. To pin one configuration, route with {"type": "policy_revision", "inventory_allocation_policy_revision_id": "invpv_..."}. See Policy revisions.
Show stock on a storefront#
A storefront can read stock from each variant to show "Sold out", "Only 2 left", or a disabled Add to cart button. Variant reads use the same routing as orders. Flint uses inventory.default_routing_source when it is set. With no default, Flint uses the active Location in the current environment that has had inventory allocation enabled the longest.
curl https://api.withflintpay.com/v1/products/prod_1kmn0aExample/variants \
-H "Authorization: Bearer YOUR_API_KEY"
Each variant in the response includes inventory_availability:
{
"variant_id": "var_1kmn0aExample",
"inventory_tracking": "tracked",
"is_available_for_sale": true,
"inventory_availability": {
"status": "in_stock",
"available_quantity": 2,
"inventory_routing_source": { "type": "fixed_location", "location_id": "loc_1kmn0aExample" }
}
}
in_stock: one order line can buy at least one unit now.available_quantityis the most one line could buy, up to 9,999. Pay supplies each line from one Location, so the read counts stock from one usable Location. The quantity also includes any remaining backorder capacity for shipping.out_of_stock: nothing can be routed now. Stock that a checkout or order holds is already counted out, so if another cart holds the last 2 units and no shipping backorder capacity remains, the read showsout_of_stockwithavailable_quantity: 0.not_tracked: the variant doesn't consume stock.routing_source_requiredmeans the default can't be used, or no default is set and there are no active Locations with inventory allocation enabled. An order that relies on this routing selection cannot route stock in these cases. Set a usable default as in step 4.
Use expand=variants on GET /v1/products to get every variant's availability with its product. Flint checks stock for the whole page together. To show "any size in stock" for a product, check whether any of its variants is in_stock. Combine the answer with is_available_for_sale, which reports whether the variant and its product are active.
available_quantity needs commerce.inventory.read (or commerce.inventory.write). A key or partner token with only product access still gets status, without the number.
The check holds nothing. Two buyers can see in_stock for the last unit, and the second payment still fails with 409 INVENTORY_INSUFFICIENT. Variants don't send an event when availability changes: read them again after inventory_level.updated, which every hold, commitment, and stock change sends.
Safety stock, counts, and transfers#
Record a backorder policy#
An inventory item can record whether it may carry units on backorder, how many at most, and when you expect to ship them. The backorder object is a patch: send the fields you want to change.
curl -X PATCH https://api.withflintpay.com/v1/inventory-items/invi_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "backorder": { "enabled": true, "limit_quantity": 50, "expected_ship_date": "2026-12-15" } }'
enabled defaults to false. limit_quantity is at least 1, or null for no cap, and counts every unit on backorder across the item's levels. expected_ship_date is YYYY-MM-DD or null. Sending null clears the cap or the date.
With enabled set to true, tracked orders you create directly and payment link checkouts backorder the units stock can't cover, up to the limit; Sell past available stock walks through it. A reservation you create never backorders. Backorders covers how backordered units are counted.
Withhold safety stock#
Safety stock keeps units out of available_quantity without moving them, such as display stock or a buffer against count errors. Find the level with GET /v1/inventory-levels?inventory_item_id=invi_...&location_id=loc_..., then set its safety_stock_quantity:
curl -X PATCH https://api.withflintpay.com/v1/inventory-levels/invl_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "expected_version": 4, "safety_stock_quantity": 5 }'
expected_version is optional. A level's version changes on every hold, commit, and release, so on a level that is selling, read it right before you write. The PATCH returns the updated level in data. A level exists only once stock has been recorded for that item and Location; to set safety stock before any stock arrives, first send a counted adjustment with on_hand_quantity set to 0, which creates the level.
Count a shelf#
A physical count compares what's on the shelf with what Flint expects, then applies the differences in one step:
POST /v1/inventory-countswith alocation_idand up to 100inventory_item_ids. Each count line shows the quantities Flint expects.- Read each count line's live
physical_versionalongside its expected quantities, then count the shelf. - Save every observation with
PATCH /v1/inventory-counts/{inventory_count_id}: the count's currentexpected_version, and for each item itscounted_on_hand_quantityand thephysical_versionyou read asexpected_physical_version. Leave out a condition quantity you didn't count, and Flint keeps the quantity it expects. POST /v1/inventory-counts/{inventory_count_id}/apply, orPOST /v1/inventory-counts/{inventory_count_id}/cancelto discard the count.
curl -X PATCH https://api.withflintpay.com/v1/inventory-counts/invc_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"expected_version": 1,
"observations": [
{ "inventory_item_id": "invi_1kmn0aExample", "counted_on_hand_quantity": 23, "expected_physical_version": 4 }
]
}'
supported_actions lists apply once every line has an observation; applying earlier returns 409 ACTION_NOT_ALLOWED with reason status_not_reached. If a counted item's stock moved after you read its physical_version, through a sale, a receipt, or a correction, the save or the apply returns 409 VERSION_CONFLICT and changes nothing. details lists each stale line with its captured_physical_version and current_physical_version. Count those items again, save the complete set, and apply with a new Idempotency-Key; you don't need a new count. Holds and commitments never make a count stale. Operations has every count rule.
Move stock between Locations#
A transfer moves stock from one Location to another through a draft you can edit:
POST /v1/inventory-transferswithorigin_location_id,destination_location_id, andlines, each with aninventory_item_id, an optionalcondition, and arequested_quantity. The draft moves no stock, soIdempotency-Keyis optional, and each request without one creates a separate draft.- Call the route for an action in the transfer's
supported_actions, with cumulative line targets:POST /v1/inventory-transfers/{inventory_transfer_id}/departtakes stock off the origin; then/receive,/return-to-origin, or/report-lossresolves what's in transit. A draft can also/cancel.
curl -X POST https://api.withflintpay.com/v1/inventory-transfers/invtr_1kmn0aExample/depart \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"lines": [{ "inventory_transfer_line_id": "invtrln_1kmn0aExample", "target_departed_quantity": 12 }]
}'
Each action can carry provenance and an optional expected_version, and returns inventory_transfer and inventory_levels. Until a transfer closes, PATCH /v1/inventory-transfers/{inventory_transfer_id} replaces its lines with the current expected_version, or changes only note and external_reference_id. Set external_reference_id to your purchase order number and find the transfer with GET /v1/inventory-transfers?external_reference_id=PO-1042. Operations covers editing lines that have already departed.
Trace a number back to its cause#
Every change to a level is an immutable movement. GET /v1/inventory-movements filters by inventory_item_id, location_id, type, reason, and source, and each movement's source_reference names the adjustment, reservation, transfer, count, receipt, level, or fulfillment that caused it. To list what one command wrote, send source_reference_type and source_reference_id together, such as GET /v1/inventory-movements?source_reference_type=inventory_transfer&source_reference_id=invtr_1kmn0aExample. Add expand=inventory_item to show each item beside its ID. See Reading the ledger.
Staying in sync#
Poll changed levels#
GET /v1/inventory-levels returns levels in ascending updated_at order, with inventory_level_id breaking ties. Level timestamps have whole-second precision. A page token saves the timestamp and ID as they appeared on the previous page, so changing that level does not move the cursor. Continuation returns matching levels whose timestamp and ID sort after that saved pair.
A timestamp checkpoint is not a lossless change feed. If page 1 ends at 17:52:47Z, a lower-ID level changed later in that same second still sorts behind the cursor and will not appear on a later page. This can happen even when the write commits before you request page 2. A write can also receive its updated_at before it waits or commits, then become visible after your scan has advanced past that timestamp. An overlap rereads timestamp boundaries; it cannot cover every delayed commit.
For a warehouse sync that runs every 15 minutes, use incremental windows to process recent changes first:
- Keep a checkpoint from the last completed scan. Before the first page, record a new scan boundary in UTC, rounded down to a whole second. Exclude that boundary's entire second from this scan; do not scan through the current second.
- Request
GET /v1/inventory-levels?updated_after=CHECKPOINT&updated_before=BOUNDARY.updated_afterincludes its instant;updated_beforeexcludes its instant. Start one second before the saved checkpoint to overlap timestamp boundaries. For the first sync, omitupdated_after. - Follow every
next_page_tokenwith the same time bounds and filters. Upsert each level byinventory_level_id; use itsversionto avoid replacing a newer result with an older one. A level can appear again if it changes while you scan. - Save the boundary as the new checkpoint only after every page is stored durably. If the scan fails, restart with the old checkpoint. Do not advance the checkpoint to the largest
updated_atin a page.
A write with updated_at at or after the boundary belongs to a later window, including writes in the same second as the boundary. Accept duplicates, since several writes can share a timestamp. A scan returns every matching level whose timestamp and filter membership stay unchanged throughout that scan. It does not return every intermediate version or guarantee that every write made during the scan appears in that run.
To recover same-second writes behind a cursor and writes that commit late, use the inventory events below as the durable change source. Subscribe before the initial complete scan, durably record incoming events, and reconcile by level ID and version. Incremental polling can then refresh current state between events. If you rely on polling alone, finish each scheduled sync with a complete paginated scan without updated_after or updated_before. Store the newest version of every level. A reconciliation started after a write commits includes that level if its timestamp and filter membership stay unchanged during the scan, even when its timestamp falls behind the incremental checkpoint. Keep reconciling on every scheduled sync; a full scan is also subject to changes made while it runs.
Receive inventory events#
Subscribe to the events your integration acts on. Events fire for every qualifying change, including ones your own requests caused, so deduplicate by event ID instead of trying to filter out your own writes.
Reservation events cover reservations you create. Stock that Flint holds for orders and checkout shows up through inventory_level.updated and the order events. The event catalog lists all inventory events, including count, receipt, and transfer events, and the values enabled_events accepts.
Common errors#
The error reference lists every code.
Endpoints#
Moving from Stripe#
If your stock count lives in your own database next to Stripe Checkout or Payment Links, Stripe inventory management maps the webhook decrement and the reservation table onto the calls above.
Draft count lines include the level's live physical_version alongside the expected quantities (0 when no level exists, null once applied or canceled). Use it as evidence of current stock; creating a count does not capture a version or fence the level. captured_physical_version is null until you save an observation for that line. When saving an observation, send the version you observed as expected_physical_version.
For both adjustment lines and count observations, source_observation_sequence must be an integer from 1 to 9007199254740991. Send it only with source_system.type of pos, wms, erp, or other and a non-empty external_source_id.
Stock held for a paid-order edit#
A pending paid-order edit holds stock for its tracked added items until payment completes it. Completion commits that stock and releases stock for the removed units. Canceling or expiring the edit releases the added stock hold and leaves the original order unchanged. Added backordered units take their place in line at completion. An unpaid edit expires 24 hours after creation. Processing payments and payment reviews defer expiry until they resolve.