Session

User sessions: a short-lived token for one user, safe to hand to a browser.

session = user.session(scopes=["agents", "humans"], ttl_s=3600)
token = session.token                       # your frontend uses it as its API key

client = noclick.Client.for_session(session)     # or act as that user from Python
class Session

A token pinned to one user with a subset of the minting key's scopes. Printing it never shows the token.

Attributes
tokenstring
idstring | null
userIdstring | null
scopesstring[]
expiresAtDate | null
rawJsonObject

The response JSON exactly as the API sent it.

baseUrlstring | undefined

The API the session was minted on.

expiredboolean

Whether expiresAt has passed (by this machine's clock).

client

client(options?: Omit<ClientOptions, "apiKey">): NoClick

A client that acts as this session: await Agent.list({ client: session.client() }).

Parameters
options.baseUrlstring

Defaults to NOCLICK_API_URL, then https://api.noclick.com.

options.timeoutMsnumber

Per-attempt request timeout (default 60s).

options.maxRetriesnumber

Retries for 408/429/5xx (never a POST's 500, which is replayed) and network errors (default 3).

options.backoffMsnumber

First backoff step; doubles per attempt with jitter (default 500ms).

options.maxBackoffMsnumber
options.headersRecord<string, string>
options.fetchtypeof fetch

A custom fetch (a proxy agent, a test double). Defaults to the global one.

Returns

A client holding the session's token, pointed at the API the session came from. Every call it makes acts as the session's user, with the session's scopes.