Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
    Overview
    Quickstarts
    Customize look and feel
    Collect additional information
    Collect taxes
    Dynamically update checkout
    Manage your product catalog
      Manage limited inventory
      Make line item quantities adjustable
      Let customers decide what to pay
    Subscriptions
    Manage payment methods
    Let customers pay in their local currency
    Add discounts, upsells, and optional items
    Set up future payments
    Save payment details during payment
    Manually approve payments on your server
    After the payment
    Elements with Checkout Sessions API beta changelog
    Migrate from legacy Checkout
    Migrate Checkout to use Prices
Build an advanced integration
Build an in-app integration
Payment methods
Add payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Elements
Payment scenarios
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Other Stripe products
Financial Connections
Crypto
Climate
HomePaymentsBuild a checkout pageManage your product catalog

Manage limited inventory

Prevent customers from holding inventory in carts by expiring Checkout Sessions.

Copy page

For some types of limited-inventory businesses, it’s necessary to prevent customers from reserving items for a long time without completing the purchase. For example, an event ticket seller wants to allow customers only a few minutes to buy their selected tickets before cancelling the sale and making those tickets available again. You can cancel a pending sale by expiring the Checkout Session.

Checkout supports both manual and timed session expiration. When a Checkout Session expires, its status property changes to expired.

Manual expiration

To immediately expire an open Checkout Session and cancel any pending purchase, use the expire endpoint.

Command Line
cURL
curl -X POST https://api.stripe.com/v1/checkout/sessions/
{{SESSION_ID}}
/expire
\ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"

Set an expiration time

When you create a Checkout Session, specify an expiration timestamp by setting the expires_at parameter. The value must be between 30 minutes and 24 hours after the current time. If you don’t specify expires_at, the default value is 24 hours after the current time.

Command Line
cURL
curl https://api.stripe.com/v1/checkout/sessions \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d customer=
{{CUSTOMER_ID}}
\ -d "line_items[0][price]"=
{{PRICE_ID}}
\ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d success_url="https://example.com/success" \ -d expires_at="{{NOW_PLUS_TWO_HOURS}}"

Return items to your inventory

When a Checkout Session expires, Stripe sends the checkout.session.expired event. Configure your webhook endpoint to listen for this event so your webhook handler can return to inventory any items reserved in the expired session. For more information, see Expire a Session.

Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc