Skip to main content
Scoped access tokens let you give each end user only the access they need to a browser session. Every token is tied to one scope: watch only, watch and interact through the live view, or full CDP control. For example, share a read-only live view with a customer watching an agent work, give a support engineer an interactive live view to take over, and keep CDP control in your own backend. Token URLs don’t include the session id. Every token also has a non-secret id, so you can list and revoke tokens without storing their secrets.

Token scopes

A read-only viewer and an interactive viewer can watch the same session at the same time. A live view token only opens the live view: it cannot connect over CDP or call the browser’s APIs.

Enable at session creation

Set session.scoped_access.active to true when you create a session. The response then carries one URL per scope, each with its own token:
The response also lists the tokens in scoped_access_tokens, one per scope, each with its token id. Embed a live view URL in an iframe the same way as any other live view. If the session also sets live_view.read_only, no live view can interact: live_view_url is the same read-only URL as live_view_read_only_url, and cdp_url keeps full control.

Mint more tokens

To mint more token URLs for a running session, for example one per end user, call POST /v1/sessions/{session_id}/tokens. Pass scopes to choose which URLs to mint, or omit it for every URL the session can serve. Every call returns new tokens:
The response carries the URL fields and a tokens list with one entry per minted token:
When scopes is omitted:
  • A headful session gets all three URLs.
  • A headless session gets only cdp_url, because live view tokens require a headful browser.
  • A live_view.one_time_url session gets no live_view_url.

Restrict tokens to IP addresses

Pass allowed_ips to restrict tokens to the client IP addresses you list. A connection from any other address is refused with 403. Each entry is an IPv4 or IPv6 address (203.0.113.7) or a CIDR range (203.0.113.0/24), up to 50 entries. Set it under session.scoped_access to restrict the tokens returned when the session is created:
Or pass it when minting tokens, for example a different list per end user. It applies to every token minted in that call:
The response echoes allowed_ips when the restriction is applied. The client IP is checked when a connection opens: a connection that is already open stays up. Tokens minted without allowed_ips connect from any address. For a live view URL, the client is the end user’s browser, so list the addresses your end users connect from.

One-time tokens

Pass one_time_use: true to make each token work once, for example a link you send to one end user. It defaults to false. Set it under session.scoped_access for the tokens returned when the session is created:
Or pass it when minting tokens. It applies to every token minted in that call, and the response echoes one_time_use: true:
Each token opens one WebSocket connection: the CDP connection for a cdp_url, the live view stream for a live view URL. The token is removed when that connection opens, and any later connection with it is refused with 404. Reloading a live view page shows that the link is no longer valid. A connection that is already open stays up, but cannot reconnect if it drops. Requests that are not a WebSocket connection, such as GET /json/version, do not use up the token, and neither does a connection refused by allowed_ips. A used token is no longer listed.

Manage tokens by id

Every token returned in scoped_access_tokens or tokens has an id (tok_...) that is not a secret. When you hand a URL to an end user, keep only the token’s id, mapped to that end user on your side. You don’t need to store the secret to manage the token later. List a running session’s live tokens with GET /v1/sessions/{session_id}/tokens, or get one with GET /v1/sessions/{session_id}/tokens/{token_id}. Both return only id, scope, created_at, expires_at, allowed_ips and one_time_use, never the secret or URL. Revoked, expired and used one-time tokens are not listed. expires_at is the latest time a token works: every token also stops when its session ends. To revoke a token, pass its id to DELETE /v1/sessions/{session_id}/tokens/{token_id}. The URL stops opening new connections; a connection that is already open stays until it closes:
To close connections that are already open, end the session with DELETE /v1/sessions/{session_id}. This stops the browser and closes every connection to it, whichever token opened it.
Revoking by the token secret from a URL still works but is deprecated. Do not use it: always revoke by id.

Session id access

On a scoped session the session id is no longer a credential on its own: connecting to CDP or the live view with only ?sessionId= is refused. Connect with a token (?token=), or with the session id and a token (?sessionId=...&token=...). Any other session switches to tokens the same way as soon as you mint a token for it. Sessions that never use tokens keep working with the session id alone.
Minting a token on a session without scoped_access makes it token-only from then on: connections that are already open stay up, but new connections with only ?sessionId= are refused, so include cdp in scopes if your own code still connects. Revoking the tokens does not restore session id access.

Limitations

  • Tokens stop working when the session ends.
  • scoped_access requires a headful cloud browser and cannot be combined with live_view.one_time_url.
  • Batch and async session creation do not accept scoped_access. For those sessions, mint tokens with POST /v1/sessions/{session_id}/tokens once the session is running.
  • Tokens cannot be minted for sessions that run on a connector or a Mac.
  • allowed_ips applies to connections over the public internet. Through an Anchor Dock, it is checked against the Dock’s public address, not the client’s.
  • The DevTools URLs returned by GET /v1/sessions/{session_id}/pages are not IP-restricted, and their tokens have no id: they are not listed and can only be revoked by their secret.
  • Live view URLs of sessions created with live_view.read_only or live_view.one_time_url but without scoped_access carry no token id. Use scoped_access or POST /v1/sessions/{session_id}/tokens for tokens you can manage by id.
  • Revoking a token does not close connections that are already open.