Client class is your main entry point for Uplink automation. It manages the WebSocket connection to the Uplink relay server and provides methods for worker and browser management.
Key concepts:
- Device: A physical iOS or Android device
- Worker: A worker created using the native Uplink SDK (a device can create multiple workers)
- Address: A hex-encoded identifier for workers
Connection
uplink.session()
Creates an Uplink session using your project credentials.
auth: Your OAuth client credentials from Uplink Console —{ clientId, clientSecret }. The session is automatically scoped to the project the client belongs to. See Authentication, or the Auth type below for the accepted shapes.options(optional): Session configurationinclude: Cryptographic key optionsecdsa: Boolean, include ECDSA keys (default: false)ecdh: Boolean, include ECDH keys (default: false)
restrict:{ verifier: string }— a secret value you choose to keep the session secure. Only your code knows this value; anyone trying to use the session without it will be rejected. Recommended for any production use.
Promise<Session> - Session object with the shape { sessionId, sessionUrl, qrUrl, credential?, keys? }. Pass it directly to uplink.client.fromSession() to connect.
Example:
Uplink never stores your verifier. That means you must reuse the same secret on later calls (for example, with
uplink.getSession()) without re-fetching it from Uplink.uplink.getSession()
Looks up an existing session by ID and returns the same Session shape that uplink.session() returns — including a fresh sessionUrl. Useful when you already have a sessionId (for example, persisted across runs) and want to keep using the original session instead of creating a new one, or recover the keys that were generated when it was created.
auth: Your OAuth client credentials from Uplink Console —{ clientId, clientSecret }sessionId: The ID of an existing session belonging to the client’s projectoptions(optional):include: Cryptographic key optionsecdsa: Boolean, include the project ECDSA key pair (default: false)ecdh: Boolean, include the session ECDH key pair if one was created at session-create time (default: false)
Promise<Session> - Same shape as uplink.session(), but without a credential field. If the session was created with a restrict.verifier, merge the same secret back in before passing the session to fromSession().
You only need to worry about merging
credential when you’re picking a session up later through getSession(). If you call fromSession() directly with the object returned by uplink.session(), the credential is already attached for you.The
include.ecdh / include.ecdsa flags only re-export keys that Uplink generated for the session. If you brought your own key pair instead, getSession() won’t return anything in keys — you’re expected to re-attach your own.Returns
404 if the session does not exist or does not belong to the client’s project.uplink.sessionDetails()
Fetches a richer view of an existing session for display in dashboards or admin views — including paired devices, total bytes streamed, total connection duration, tags, and the parent project and organization. Use this when you need to inspect a session, not to reconnect to it.
auth: Your OAuth client credentials from Uplink Console —{ clientId, clientSecret }sessionId: The ID of an existing session belonging to the client’s project
Promise<SessionDetails> - Session metadata. See the SessionDetails type below.
Example:
uplink.token()
Exchanges your OAuth client credentials for an access token. You don’t normally need this — passing credentials directly to the methods above lets the SDK obtain and renew tokens for you. Reach for it when you want to hold the token yourself, for example to share one across processes.
auth: Your OAuth client credentials from Uplink Console —{ clientId, clientSecret }options(optional):host: Override the Uplink API hostsignal: AnAbortSignalto cancel the exchange
Promise<Token> - { token, expiresAt }. Pass it anywhere an Auth is accepted.
Example:
uplink.client.fromSession()
Creates a client from an Uplink session.
session: Session object created withuplink.session()options(optional): Connection optionsagent: Optional AI agent for natural language automation (requires@uplink-code/ai)
Promise<Client> - Connected client instance
Complete example:
uplink.client.connect() (Alternative)
Connects directly to an Uplink session via WebSocket URL. This is an alternative to using uplink.session() + fromSession().
url: WebSocket URL in the formatwss://relay.uplink.build/session/<jwt>options(optional): Connection optionsagent: Optional AI agent for natural language automation (requires@uplink-code/ai)
Promise<Client> - Connected client instance
Example:
Recommended approach: Use
uplink.session() + fromSession() for better credential management and project organization. Use connect() when you need to work with pre-generated session URLs.Browser operations
client.launch()
Launches a new browser on a worker. If no worker address is provided, uses the first available worker.
address(optional): Worker address to launch browser on
Promise<Browser> - New browser instance
Example:
client.connect()
Connects to an existing browser by its handle.
handle: Browser handle identifieraddress(optional): Worker address where browser is running
Promise<Browser> - Connected browser instance
Example:
client.browsers()
Lists all browsers on a worker.
address(optional): Worker address to query. If not provided, queries first available worker.
Promise<Browser[]> - Array of browser instances
Example:
Worker operations
client.workers()
Returns list of currently connected workers.
ClientWorker[] - Array of connected workers
Example:
client.terminate()
Terminates a worker connection.
address(optional): Worker address to terminate. If not provided, terminates first available worker.
Promise<void>
Example:
Connection management
client.close()
Closes the client connection and cleans up resources.
Promise<void>
Example:
Events
The client emits events for worker connection lifecycle.worker-connected
Emitted when a new worker connects to the session (i.e., when a device running the Uplink SDK joins).
worker-disconnected
Emitted when a worker disconnects from the session (i.e., when a device leaves or loses connection).
Types
Auth
Accepted byuplink.session(), uplink.getSession(), uplink.sessionDetails(), and uplink.token(). Either your client credentials, or an access token you already hold.
ClientCredentials
Token
Returned byuplink.token().
ClientOptions
Address
Worker identifier - a hex-encoded address:SessionDetails
Returned byuplink.sessionDetails(). Aggregates session-level metadata across the API, devices, billing, and tags.
Complete example
Related
ClientWorker
Device-specific operations
Browser
Browser management
Core concepts
Architecture overview
Sessions
Session management