Create a checkout session
Creates a hosted payment page at your payment provider and returns its url. Redirect the customer there. top_up buys credits for a prepaid plan, subscription starts a plan, and payment_method saves a card for postpaid invoices. The provider is the customer’s own payment_provider if set, then the first matching routing rule, then the account default, unless the request names one. When payment succeeds, Runledger grants the credits or starts the subscription and sends checkout_session.completed. Top-up credits expire one year after payment completes unless the plan’s top_up.credits_expire_in or this request’s credits_expire_in sets another length. That holds whether the session comes from your API call or from the customer view.
Authentication
A secret key (rl_sk_test_..., rl_sk_live_...) or a restricted key with limited scopes (rl_rk_test_..., rl_rk_live_...). A restricted key can carry agent: true and an expires_at, and is what a coding agent should hold. Keys end in a checksum so secret scanners can recognize them. People create, roll and revoke keys in the dashboard; GET /v1/api_keys lists them, masked.
Request
top_up buys credits, subscription starts a plan, payment_method saves a card for postpaid invoices.
top_up only: credits to buy, as a decimal string, within the plan’s top-up limits. The credits join the plan’s top-up pool.
top_up only: how long the purchased credits last, as an ISO 8601 duration. Overrides the plan’s top_up.credits_expire_in. Leave it out to use the plan’s, which is one year when the plan sets none.
subscription only: the plan (ID or key) to start.
Use this connected provider (by name) for this session instead of the one routing picks. Fails if the customer already saved a method at another provider.
Response
top_up buys credits, subscription starts a plan, payment_method saves a card for postpaid invoices.
The provider-neutral payment record (pay_...), once the customer has paid.