Checkout sessions give you full programmatic control over what a customer sees at checkout — pre-filled fields, customer identity, metadata, custom pricing, and more. You create the session from your server, then redirect the customer to the session URL. Sessions expire after one hour if not completed.Documentation Index
Fetch the complete documentation index at: https://docs.spairehq.com/llms.txt
Use this file to discover all available pages before exploring further.
When to use sessions
Use sessions over checkout links when you need to:- Pre-identify the customer using their account in your system
- Attach metadata to the order (e.g., plan tier, referral source, internal IDs)
- Apply a discount automatically without exposing a code
- Create dynamic or ad-hoc pricing per customer
- Control the success redirect URL per transaction
Create a session
url field. Redirect the customer there to complete payment.
Key parameters
Identify the customer
Link the checkout to a customer in your system usingexternal_customer_id. After a successful checkout, the Spaire customer will have this ID set as external_id, making it easy to look up billing state without storing Spaire IDs.
Attach metadata
Metadata is copied from the checkout to the resulting order and subscription. Use it for attribution, internal references, or anything you want to correlate later.Control the success redirect
{CHECKOUT_ID} is replaced with the actual checkout session ID after payment.
Apply a discount automatically
Allow or block discount code entry
Multiple products
Pass multiple product IDs to let the customer choose between them at checkout — useful for presenting monthly and yearly pricing side by side.Ad-hoc prices
For dynamic pricing — individual customer deals, calculated tiers, or custom enterprise quotes — you can attach temporary prices to a checkout session. These prices exist only for the session and never appear in your product catalog.fixed, free, custom, seat_based, and metered_unit. They are marked with source: "ad_hoc" in API responses.
Embedded checkout with sessions
To use a session URL inside an embedded checkout, setembed_origin to the origin of the page that will host the checkout frame:
embed_origin, the embedded checkout will be blocked by the browser’s iframe security policy.
Custom fields
Pre-fill custom field values when you already have the data:Localization
Set the checkout language using thelocale field. See Localized Checkout for the full list of supported locales.
What’s next
Localized Checkout
Serve checkout in 10 languages — set once or per-session.
Discounts
Create percentage and fixed-amount discounts to apply at checkout.
Handle webhooks
React to
order.paid and subscription.active in your backend.
