Skip to content

Stripe inventory management: how to prevent overselling

Stripe doesn't track inventory. Products and Prices have no quantity field, Checkout and Payment Links sell whatever quantity they're asked to sell, and a Checkout Session stays open for up to 24 hours with nothing holding the unit. To stop overselling on Stripe, you keep the count in your own database, hold stock when a session starts, and release the hold when the session expires or its expiry event goes missing. On Flint, the stock check is part of the payment: a sold-out item fails before the card is charged.
Verified against official documentationReviewed Send a correction (opens in a new tab)

Everything a Checkout Session knows about what it sells is a price and a quantity:

cURL
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

Where you areYour path
You sell through Checkout or Payment Links and keep the count in a spreadsheet, or nowhere yetBuild the counter properly
A tutorial told you to create SKUs or set sku.inventoryThat API is gone
You want a Payment Link to stop selling after a fixed number of salesPayment limits, and what they miss
Your Payment Link kept taking payments after the last unit soldMake a Payment Link say sold out
You already decrement on webhooks and oversold during a spikeThe five race windows
You'd rather not build any of thisStock checked at payment, on Flint

What Stripe gives you instead

Four Stripe features come up in every search for Stripe stock management. None of them is a count.

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:

Shell
# 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.

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:

Shell
# 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

Shell
# 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 stores a number and enforces nothing

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.

Selling the last unit with Stripe and your own countResponse
BuyerYour serverStripeBuy 2 mugsCreate a Checkout SessionSession URL for the buyerPay: the card is chargedcheckout.session.completed, seconds to days laterRefund, if the count already hit zero
  1. Buyer sends Buy 2 mugs to Your server
  2. Your server sends Create a Checkout Session to Stripe
  3. Stripe returns Session URL for the buyer to Your server
  4. Buyer sends Pay: the card is charged to Stripe
  5. Stripe sends checkout.session.completed, seconds to days later to Your server
  6. Your server sends Refund, if the count already hit zero to Stripe

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

    JavaScript
    // 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.

    JavaScript
    // 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:

    JavaScript
    // 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

    JavaScript
    // 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

  1. Nothing holds the unit between the cart and the charge#

    Two buyers checked out the last unit minutes apart, both cards were charged, and one order can't ship.

    Stripe accepts any payment for any quantity. Nothing reads a stock count when the session is created, while the buyer types a card number, or when the charge succeeds, so your system can't object until both charges have landed. Checking availability before you create the session narrows the window but can't close it: ten buyers can pass the same check before any of them pays.

    Confirm it

    For one busy hour, count sessions created per SKU against the stock you had when the hour started. If there were more sessions than stock, the check only held by luck.

    Fix

    Record a hold when you create the session and subtract open holds from availability, as in step 3 of the recipe. The refusal moves from after the charge to before the payment form renders.

  2. The decrement lands when the event arrives, not when the buyer pays#

    During a spike, the storefront kept selling on a count that was minutes old.

    Stripe delivers checkout.session.completed asynchronously and in no guaranteed order. On a good day it arrives seconds after the charge. If your endpoint errors or times out, Stripe retries with exponential backoff for up to three days in live mode. Your count is wrong for as long as the event is late, and events run latest when traffic is heaviest.

    Confirm it

    For a launch hour, compare the charge times in the Dashboard with your decrement times. The gap is your overselling window.

    Fix

    You can't make delivery synchronous. Enforce stock before payment with holds, so a late event delays bookkeeping instead of availability.

  3. Read-then-write loses sales#

    Two handlers both read 5, both wrote 4, and the count has been wrong ever since.

    Events for different sessions arrive concurrently. A handler that selects the count, subtracts in application code, and writes the result back interleaves with another handler under load, and one of the two writes is lost. Testing with one buyer never shows it.

    Confirm it

    Since your last physical count, compare recorded sales per SKU with total decrements. A gap that grows during busy hours is this trap.

    Fix

    Decrement in one statement with the guard inside it, UPDATE stock SET quantity = quantity - $1 WHERE sku = $2 AND quantity >= $1, then check the affected row count. The database serializes what your code can't.

  4. The same sale can arrive twice#

    Stock drained faster than sales, and nobody bought the missing units.

    Delivery is at least once. Stripe retries whenever your endpoint responds slowly or with an error, and its webhook docs say endpoints might receive the same event more than once. A handler that decrements without remembering event IDs subtracts those sales twice.

    Confirm it

    Log processed event IDs for a week and count unique-constraint conflicts. Every duplicate that reached the decrement was a phantom sale.

    Fix

    Insert the event ID into a processed-events table with a unique constraint, in the same transaction as the decrement, and stop on conflict. A dedupe check outside that transaction can still double-count across a crash.

  5. Holds that never release sell you out with a full shelf#

    The site says sold out. The shelf disagrees.

    Once you add holds, releasing them is your job too. An abandoned session expires at expires_at, 24 hours after creation by default, and the checkout.session.expired event that should trigger your release can be lost like any other delivery. Nothing else frees the units.

    Confirm it

    Query for holds older than your session window. Every row is stock you have and can't sell.

    Fix

    Do all three: create sessions with the 30-minute minimum expires_at, release on checkout.session.expired, and run a scheduled sweep for the events that never arrive.

    This machinery is what the recipe really costs. None of it sells anything, and all of it has to hold up during your busiest minute of the year.

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.

Selling the last unit through a Flint payment linkResponse
BuyerFlintYour serverOpen the payment linkCheckout, or Sold outPay for 2 mugsStock held, then charged; or no chargeorder.paid, with the stock committed
  1. Buyer sends Open the payment link to Flint
  2. Flint returns Checkout, or Sold out to Buyer
  3. Buyer sends Pay for 2 mugs to Flint
  4. Flint returns Stock held, then charged; or no charge to Buyer
  5. Flint sends order.paid, with the stock committed to Your server

A payment link for a tracked product is one request:

cURL
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

WhenWhat happensLevel fields
A payment for 2 mugs beginsFlint holds 2 at the Locationheld_quantity up 2, available_quantity down 2
The payment succeedsThe hold becomes a commitmentheld_quantity down 2, committed_quantity up 2
The payment fails or is canceledThe hold is releasedheld_quantity down 2, available_quantity up 2
The fulfillment hands the mugs offThe commitment is consumedcommitted_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
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
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 }]
  }'
JSON
{
  "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
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 databaseFlint
Where the count livesA column you maintain; Stripe stores noneLevels per item and Location, derived from a movement ledger
Hold between cart and paymentA holds table, an expiry handler, and a sweep jobPlaced when payment begins, or a reservation Flint releases at its deadline
Two buyers, one unit leftBoth can be charged unless your holds stop the secondOne payment succeeds; the other fails before the card is charged
Payment link when stock runs outStays active until your handler deactivates itShows Sold out on its own and sells again after you restock
Abandoned checkoutYour hold pins the stock until the session expires, up to 24 hoursHolds nothing until payment begins
A retried event or requestYour dedupe tableIdempotency keys on stock commands; cumulative targets on lifecycle actions
Restocking a returnCode you writeThe return's disposition, by condition, capped at the returned quantity
Several locationsRouting logic you writeAllocation policies with priority groups and split rules
Low stock signalA query you pollinventory_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.