Everything a Checkout Session knows about what it sells is a price and a quantity:
curl https://api.stripe.com/v1/checkout/sessions \
-u "sk_test_...:" \
-d mode=payment \
-d "line_items[0][price]=price_..." \
-d "line_items[0][quantity]=2" \
--data-urlencode "success_url=https://example.com/thanks"
The 2 is what the buyer is buying, not what you have. Nothing in this request, the Product behind it, or your account stores a count to check it against, so Stripe creates the session just as readily for the eleventh unit of ten. The Product object's only physical fields are shippable and package_dimensions.
Where to start
What Stripe gives you instead
Four Stripe features come up in every search for Stripe stock management. None of them is a count.
A Payment Link can stop after N payments
restrictions[completed_sessions][limit] deactivates a link once that many Checkout Sessions complete, and inactive_message is what later buyers see. Stripe's Payment Links docs suggest it for limited inventory:
# Deactivates the link after 50 completed sessions, not 50 units
curl https://api.stripe.com/v1/payment_links \
-u "sk_test_...:" \
-d "line_items[0][price]=price_..." \
-d "line_items[0][quantity]=1" \
-d "restrictions[completed_sessions][limit]=50" \
--data-urlencode "inactive_message=Sold out."
The limit counts sessions, not units. With adjustable quantity on, 50 sessions can take 500 units. The limit is a fixed number: restocking means raising it by hand, and a refund doesn't give a completed session back.
Making a Payment Link say sold out
A Payment Link has no sold-out state, only an inactive state and a message. Set inactive_message to your sold-out wording, then deactivate the link when your own count reaches zero:
# From your webhook handler, once your own count reaches zero
curl https://api.stripe.com/v1/payment_links/plink_... \
-u "sk_test_...:" \
-d active=false
Buyers who open the link afterward see your message. The update runs only after a checkout.session.completed event reaches your handler, so any payment that completes between the last unit selling and your update is an oversell you refund. To sell again after restocking, you set active=true yourself. Stripe's developer blog puts it directly: "Payment Links do not natively allow for backend inventory checks to conditionally facilitate the payment based on stock availability."
Adjustable quantity caps one buyer, not your stock
# A per-session cap, read from this request, never from stock
-d "line_items[0][adjustable_quantity][enabled]=true" \
-d "line_items[0][adjustable_quantity][minimum]=1" \
-d "line_items[0][adjustable_quantity][maximum]=10"
maximum defaults to 99 and accepts up to 999999. It bounds what one session can take, and Checkout reads it from the request that created the session, never from a count. Stripe's docs assume the count lives elsewhere: they tell you to reserve inventory for the session's maximum, in whatever system holds your inventory.
Metadata on a Product will hold "stock": "14", and nothing acts on it. Stripe's metadata docs say Stripe doesn't use metadata unless you write Radar rules on it, so Checkout never consults it before selling. It also has no atomic increment: two handlers that both read 14 both write 13. Use it as a label, such as a SKU or a pointer into the system that holds the real count.
The API that did track stock is gone
Stripe used to track inventory. The legacy Orders API's SKU objects carried an inventory attribute with three types: finite, with a quantity Stripe decremented; bucket, with in_stock, limited, or out_of_stock; and infinite. Stripe deprecated that API in October 2019 because it doesn't work with Strong Customer Authentication, SDK support ended in the releases that followed, and the SKU reference no longer resolves publicly. Tutorials built on it still rank, which is why a search for Stripe inventory returns instructions for an API you can't call. A guide that sets sku.inventory predates 2020. Both Orders APIs, including the 2022 beta, are covered in Does Stripe have an Orders API?
What Stripe's own team built
In December 2024, Stripe's developer blog described the stock system behind the developer relations team's conference swag store. The store sells through Payment Links, and the count lives outside Stripe: Stripe events go to Amazon EventBridge, a Lambda function decrements a DynamoDB table with a condition expression so the count can't go negative, and the link is turned off once a product sells out. That's four AWS services (DynamoDB, EventBridge, Lambda, and IoT Core) running next to the payment to keep one number correct.
The stock check in that build runs after the payment. When the count is already zero, the post says, "we automatically initiate a refund for the transaction," and "issuing refunds in this way can lead to losses from non-refundable transaction fees collected by Stripe." Its alternative is to leave Payment Links for a custom flow that checks stock before creating a PaymentIntent, which leaves the chance of running out between the check and the payment "greatly reduced." Reduced isn't closed. Closing it takes the rest of the recipe below.
The counter everyone builds
With no count in Stripe, the standard pattern keeps stock in your own database and moves it on Stripe's events. Built properly, it has four parts.
- 1
Check your count and create a short session
// Your database is the source of truth; Stripe never sees this check.
const available = await db.available("mug-12-white");
if (available < qty) return soldOut();
const session = await stripe.checkout.sessions.create({
mode: "payment",
line_items: [{ price: priceId, quantity: qty }],
// 30 minutes is the shortest expiry Stripe allows. The default is
// 24 hours, which is how long an abandoned cart would pin a hold.
expires_at: Math.floor(Date.now() / 1000) + 30 * 60,
metadata: { sku: "mug-12-white", qty: String(qty) },
success_url: "https://example.com/thanks?session_id={CHECKOUT_SESSION_ID}",
});
- 2
Decrement once the money is in
Handle checkout.session.completed with the two safeguards that make it survive production: an event ID dedupe and a guarded update in one transaction.
// Inside the checkout.session.completed handler, after you verify
// the signature against the raw body.
const { sku, qty } = session.metadata;
await db.tx(async (t) => {
// Delivery is at least once: record the event ID in the same
// transaction as the decrement, or a retry sells the unit twice.
const dedupe = await t.result(
`INSERT INTO processed_events (event_id) VALUES ($1)
ON CONFLICT DO NOTHING`,
[event.id],
);
if (dedupe.rowCount === 0) return; // already handled
// One atomic statement with the guard inside it. Never SELECT
// the count and UPDATE the result; concurrent handlers interleave.
const row = await t.oneOrNone(
`UPDATE stock SET quantity = quantity - $1
WHERE sku = $2 AND quantity >= $1
RETURNING quantity`,
[Number(qty), sku],
);
// The buyer has already paid when this branch runs.
if (!row) await markOversold(t, session);
});
The handler runs after the buyer paid. When it finds the shelf empty, what's left is a refund or a backorder email.
- 3
Hold stock before the payment form
Anything between your availability check and the charge, such as another buyer, a slow webhook, or a retry, lands in that refund branch. A hold closes the gap:
// At session creation, in one transaction with the availability check:
// available = on hand - open holds - paid but unshipped
// INSERT INTO holds (session_id, sku, qty, expires_at)
//
// On checkout.session.completed: delete the hold and decrement,
// inside the same transaction as the event dedupe.
- 4
Release every hold, including the ones whose event never came
// On checkout.session.expired: delete the hold.
//
// On a schedule, forever: delete holds past expires_at, because
// the expired event can be lost like any other delivery.
Every part defends the same gap: the time between the buyer paying and your database finding out. Here are the five ways that gap still wins, each with the fix.
The five places the counter lies
What a working stock system has to do
Built out, the recipe becomes a stock system. To hold up in your busiest hour, it has to:
- Hold stock before money moves, with a deadline that releases the hold without your code.
- Give a claim everything it asked for or nothing, across items and locations, so a split cart can't half succeed.
- Survive retries, so the same command applied twice changes nothing.
- Keep apart what's on the shelf, what carts are holding, what paid orders own, and what's damaged or set aside. One number can't answer both the storefront's question and the stockroom's.
- Keep a ledger of every movement, each tied to the record that caused it, so any count can be explained.
- Restock from what physically came back and its condition, not as a side effect of a refund.
- Report when claims outrun stock instead of quietly going negative.
You can build all of it next to Stripe. You then maintain it through every schema change and every traffic spike.
Questions, answered
Does Stripe track inventory?
No. Products and Prices carry no stock quantity, Checkout and Payment Links don't read or decrement a count, and no Stripe object records how many units you have. Stock lives in a system you run, and Stripe never sees it.
Can Stripe Checkout limit how many of an item are sold?
Not against stock. Adjustable quantity caps how many units one session can take, and a Payment Link can deactivate after a set number of completed sessions. Both are fixed configuration values that never consult a count, so overselling across sessions stays possible.
What happened to the Stripe Orders API and SKU inventory?
Stripe deprecated the legacy Orders API in October 2019 because it doesn't work with Strong Customer Authentication, and SDK support ended in the releases that followed. SKU objects and their inventory types went with it, with no replacement inside Stripe, so a tutorial that sets sku.inventory describes an API you can no longer call.
How do I prevent overselling with Stripe?
Keep the count in your own database, hold stock when a checkout starts, decrement with a single guarded update on checkout.session.completed, deduplicate by event ID, and release holds on expiry with a sweep for missed events. Stripe enforces none of it, so the guarantee is only as strong as the weakest of those parts.
How do I show a Stripe Payment Link as sold out?
Set inactive_message on the link to your sold-out wording, then deactivate the link by updating it with active=false when your own count reaches zero. Stripe can also deactivate a link after a set number of completed sessions, but that limit counts sessions, not units. Either way, payments that complete before the link deactivates are oversells you refund.
How long does a Stripe Checkout Session stay open?
24 hours by default. expires_at accepts anywhere from 30 minutes to 24 hours after the session is created. A hold you place for a session has to last as long as the session can, so set the 30-minute minimum on anything with limited stock.
Can I store stock quantities in Stripe metadata?
You can write a number there, and nothing will read or enforce it: Stripe's docs say it doesn't use metadata except with Radar. Metadata also has no atomic increment, so two handlers that both read 14 both write 13. Use it as a label that points at the system holding the real count.
Does Stripe restock inventory when I refund a payment?
No. A refund moves money only. Whether the unit goes back into sellable stock is a separate decision your inventory system records, ideally from the condition the item came back in rather than from the refund.
Does Stripe send low stock alerts?
No. Stripe holds no stock to watch. Alerts have to come from the system that holds the count, either as a threshold you check yourself or as an event from an inventory API that reports each change.
Is there a payments API that tracks inventory?
Flint does. Stock is tracked per item and per Location, a payment for a tracked item holds the stock before the card is charged, and when nothing is left the payment fails with INVENTORY_INSUFFICIENT and the buyer isn't charged. Payment links show Sold out on their own and sell again once you restock.
On Flint, the stock check is part of the payment
Flint is a payments API with inventory built in. Stock is tracked per item and per Location. When a payment for a tracked item begins, Flint holds the stock; when the payment succeeds, the hold becomes a commitment; when it fails, the hold is released. If nothing is left, the payment fails with 409 INVENTORY_INSUFFICIENT and the buyer isn't charged. You don't write a holds table, an expiry handler, a sweep job, or a dedupe table.
A payment link that knows when it's sold out
A payment link for a tracked product is one request:
curl -X POST https://api.withflintpay.com/v1/payment-links \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: payment-link-ceramic-mug" \
-H "Content-Type: application/json" \
-d '{
"name": "Ceramic mug",
"line_items": [{
"type": "variant",
"variant_id": "var_1kmn0aExample",
"quantity": 1,
"allow_quantity_adjustment": true,
"max_quantity": 4
}],
"inventory_routing_source": {
"type": "fixed_location",
"location_id": "loc_1kmn0aExample"
}
}'
variant_id points at a catalog variant that tracks stock, and inventory_routing_source names the Location it ships from. With several Locations, send an allocation policy instead. When the Location can't supply the line's starting quantity, the hosted page shows Sold out, the link's public read reports is_sold_out: true, and starting a checkout returns 409 INVENTORY_INSUFFICIENT. The link stays active, so it sells again as soon as you record more stock, with no update to the link.
An open checkout that nobody pays holds nothing, because Flint holds stock only once payment begins. When two buyers reach for the last mug, one payment succeeds and the other fails before money moves, whatever quantity each picked. For a capped drop, max_completions counts payments in progress as well as completed ones, so a burst of buyers can't pass the cap. The same hold runs for orders you create through the API, quick pay invoices, and subscription plans, so a storefront on Flint's ecommerce API can't oversell either.
What moves the stock
| When | What happens | Level fields |
|---|
| A payment for 2 mugs begins | Flint holds 2 at the Location | held_quantity up 2, available_quantity down 2 |
| The payment succeeds | The hold becomes a commitment | held_quantity down 2, committed_quantity up 2 |
| The payment fails or is canceled | The hold is released | held_quantity down 2, available_quantity up 2 |
| The fulfillment hands the mugs off | The commitment is consumed | committed_quantity down 2, on_hand_quantity down 2 |
A refund moves money only. Returned units go back on the shelf when you record the return's disposition: sellable restocks them, and damaged keeps them on hand but out of what you can sell. In the rare case a payment succeeds and its stock still can't be committed, the order reports an inventory exception and Flint sends order.inventory_exception_created. You resolve it, or set your inventory settings to refund automatically.
Putting stock on the shelf
You never write a level directly. You record what happened, such as a delivery, a count, or a damaged unit, and Flint works out the levels and keeps the ledger:
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-10-28T14:18:00Z",
"source_system": { "type": "wms", "external_source_id": "east-coast-wms" },
"lines": [{
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"quantity": 25
}]
}'
Idempotency-Key is required here, so a retry of a delivery that already landed changes nothing. The response carries the resulting level for every level it touched, so you don't need a follow-up read. Every change also lands in the ledger as a movement whose source_reference names the adjustment, reservation, count, or other record that produced it, and whose created_by names the credential that recorded it.
Holding stock from your own cart
If you run your own cart or point of sale and take payment elsewhere, claim the stock when checkout starts:
curl -X POST https://api.withflintpay.com/v1/inventory-reservations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: hold-cart-1842" \
-H "Content-Type: application/json" \
-d '{
"owner": { "key": "cart_1842" },
"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-10-28T14:33:00Z",
"version": 1,
"supported_actions": ["commit", "release"],
"lines": [{
"inventory_reservation_line_id": "invrln_1kmn0aExample",
"inventory_item_id": "invi_1kmn0aExample",
"location_id": "loc_1kmn0aExample",
"held_quantity": 2,
"committed_quantity": 0
}]
},
"inventory_levels": [{
"inventory_level_id": "invl_1kmn0aExample",
"on_hand_quantity": 25,
"held_quantity": 2,
"committed_quantity": 0,
"available_quantity": 23
}]
}
}
The response is abridged. The hold has its own deadline: 15 minutes by default, or an expires_at you send, up to 24 hours out. Move it with a PATCH while the hold is live. Each owner.key has one active reservation, and the claim is all or nothing: every demand is held, or none is. When two buyers reach for the last unit, the second claim fails with 409 INVENTORY_INSUFFICIENT before a payment form renders. Commit the reservation after payment succeeds:
curl -X POST https://api.withflintpay.com/v1/inventory-reservations/invr_1kmn0aExample/commit \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: commit-cart-1842" \
-H "Content-Type: application/json" \
-d '{
"expected_version": 1,
"lines": [{
"inventory_reservation_line_id": "invrln_1kmn0aExample",
"target_committed_quantity": 2
}]
}'
target_committed_quantity is cumulative, the total that should be committed by now, so a retried commit succeeds and changes nothing. expected_version rejects a stale writer instead of overwriting. Those two fields replace the dedupe table and the guarded UPDATE from the recipe. When a deadline passes without a commit, Flint releases the hold, refuses later commits, and sends inventory_reservation.hold_expired. To stay in sync, inventory_level.updated fires on every quantity change with the new available_quantity, and inventory_level.shortage_detected fires when claims outrun physical stock.
Stripe and Flint stock control, side by side
| Stripe plus your own database | Flint |
|---|
| Where the count lives | A column you maintain; Stripe stores none | Levels per item and Location, derived from a movement ledger |
| Hold between cart and payment | A holds table, an expiry handler, and a sweep job | Placed when payment begins, or a reservation Flint releases at its deadline |
| Two buyers, one unit left | Both can be charged unless your holds stop the second | One payment succeeds; the other fails before the card is charged |
| Payment link when stock runs out | Stays active until your handler deactivates it | Shows Sold out on its own and sells again after you restock |
| Abandoned checkout | Your hold pins the stock until the session expires, up to 24 hours | Holds nothing until payment begins |
| A retried event or request | Your dedupe table | Idempotency keys on stock commands; cumulative targets on lifecycle actions |
| Restocking a return | Code you write | The return's disposition, by condition, capped at the returned quantity |
| Several locations | Routing logic you write | Allocation policies with priority groups and split rules |
| Low stock signal | A query you poll | inventory_level.updated on every change |
The inventory guide follows one unit from receiving through a paid order to shipment. The Inventory, Payment Links, and Locations references have every field on the requests above.
Sources
All sources accessed October 28, 2026.