Skip to navigation

Create a customer session

Returns a one-time link to a Runledger-hosted page where one customer sees their usage meters, pool balances, expiring credits and invoices, buys credits through checkout and, if you grant the scope, sets a spend limit or an auto top-up. The page carries your account’s name and branding, not Runledger’s. Set the look once in account_settings.customer_view_branding, or per session with branding. The link works for that customer and those scopes only, until expires_at, and it is not an API key. Create the session from your backend when the customer opens your billing screen, and redirect them to url. The link opens once: the browser that opens it first keeps the page, through a cookie, until expires_at, and the same link opened anywhere else shows a page that says it was used and sends the customer back to return_url. Don’t email it, since a mail scanner that follows links would use it up. A link that has expired shows a page that sends the customer back to return_url. Never put an API key in a browser. Agent keys can’t create sessions.

Authentication

AuthorizationBearer

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

This endpoint expects an object.
scopeslist of enumsRequired
Allowed values:
return_urlstringRequiredformat: "uri"
Where the page sends the customer when they leave, or when the link has expired.
customer_idstringOptional
external_customer_idstringOptional
expires_instringOptional
How long the link works, as an ISO 8601 duration. Default PT1H, maximum PT24H.
brandingobjectOptional
Branding for this session only. It overrides the account default field by field.
metadatamap from strings to stringsOptional
Up to 50 keys of your own, with keys up to 40 characters and values up to 500 characters.

Response

The session, with its link.
idstring
object"customer_session"
customerstring
scopeslist of enums
Allowed values:
urlstringformat: "uri"

The one-time link to send the customer to. Treat it as a secret until it is used.

return_urlstringformat: "uri"
expires_atdatetime
livemodeboolean
created_atdatetime
brandingobjectOptional
The branding the page uses, with the account default and this session's overrides applied.
metadatamap from strings to stringsOptional
Up to 50 keys of your own, with keys up to 40 characters and values up to 500 characters.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
422
Unprocessable Entity Error
429
Too Many Requests Error
500
Internal Server Error