Skip to main content
A Checkout Session is one purchase attempt. Create it from your backend when you know who’s buying, then redirect the customer to its url. Sessions expire after 24 hours. For a permanent URL that needs no code, use a Checkout Link. See Checkout for how the two compare.
API only. Not available from the CLI or MCP server. You can list and inspect sessions from both, see Inspect sessions.
The examples use the sandbox client from the quickstart overview, on API version 2026-10.

Create a session

Pass the products to offer and your user’s ID, then redirect to url:
With several IDs in products, the checkout shows each product as an option, in that order, with the first one preselected. The customer buys one of them. Products aren’t bundled into a single order.

Redirect and return

The redirect to success_url isn’t proof of payment. Grant access from webhooks or the customer state.

External customer ID

Set external_customer_id to your user’s ID. If a customer with that external ID exists, the order is linked to them. Otherwise Polar creates the customer with that external ID when the checkout succeeds. To use Polar’s ID instead, pass customer_id. When the session resolves to an existing customer, their email is prefilled and the email field is locked. An external_customer_id that matches no customer leaves the email editable. See External ID.

Prefill customer details

Discounts

Set discount_id to apply a discount automatically. allow_discount_codes controls whether the customer can enter a code. With a preset discount and codes turned off, the customer can’t change the discount. See Discounts.

Trials

A product’s trial applies by default. Set allow_trial: false to remove it for this session, or set trial_interval and trial_interval_count to override its length. See Trials.

Seats, units and amounts

Ad-hoc prices

Ad-hoc prices exist only for one session. Use them for per-customer pricing without changing your catalog. Pass prices, keyed by product ID:
The amount_type is one of fixed, custom (pay what you want), seat_based, unit_based, metered_unit or metered_tiers. A free price is fixed with price_amount: 0. Combine at most one fixed and one seat_based price, or use one custom price alone, plus any number of metered prices. Ad-hoc prices have source: "ad_hoc" in responses. Catalog prices have source: "catalog".

Currency and customer IP address

Without currency, Polar picks it from the customer’s country, based on their IP, and falls back to your organization’s default currency. The IP also prefills the billing country, which drives tax. See Products for multi-currency prices. When you create sessions from a backend, proxy or edge function, Polar sees your server’s IP. Forward the customer’s IP as customer_ip_address:
The header depends on your runtime: CF-Connecting-IP on Cloudflare Workers, X-Forwarded-For behind most proxies. With customer_ip_address set, you don’t need to set the billing country yourself.

Metadata

Upgrade a free subscription

Set subscription_id to the ID of a subscription on a free price. When the checkout succeeds, Polar upgrades that subscription instead of creating a new one.

Embedding and language

  • embed_origin: the origin of the page that embeds the checkout, like https://example.com. Required to embed a session. See Embedded checkout.
  • locale: the checkout language, when localization is enabled.
  • Append ?theme=dark or ?theme=light to the session url to force a theme.

Update a session

Change an open session from your backend with PATCH /v1/checkouts/{id}, for example to switch the product or apply a discount:
The /v1/checkouts/client/{client_secret} endpoints are what Polar’s checkout page calls. They take the session’s client_secret instead of an access token. Use them only to build your own checkout UI.

Session lifecycle

A session starts open and expires 24 hours after creation (expires_at). Paying moves it to confirmed, then succeeded or failed. A session never completed becomes expired.

Inspect sessions

Find sessions in the dashboard, from the CLI or with your agent:
  • Open Sales → Checkouts
  • Filter by Status, Product or Customer, or search
  • Select a session

Learn more