Skip to main content
Sessions are the foundation of Uplink’s security and connection model. Understanding how to create, manage, and secure sessions is essential for production use.

What is a session?

A session is an authenticated connection that allows your JavaScript code to communicate with mobile devices. Sessions are created programmatically using your project API key and enable secure, real-time bidirectional communication.

Creating sessions

Sessions are created programmatically in your code using your project API key. The session is automatically scoped to the project the API key belongs to.
1

Get your API key

In Uplink Console, navigate to SettingsAPI Keys to find your project API key. Keep it secure.
2

Create a session in code

Use the uplink.session() method to create a session with your API key:
3

Connect a client to the session

Create a client from your session to interact with connected devices:
4

Deliver the session to your device

The session object exposes two URLs for connecting a device. Use the one that matches your integration:
Display session.qrUrl as a QR code in your UI. When your user scans it, the Uplink Connect app opens and joins the session automatically.

API keys and session security

Sessions are authenticated using your project API key, which provides:
  • Project identity: Each API key belongs to exactly one project — sessions created with it are scoped to that project automatically.
  • Secure communication: Encrypted connections between your code and devices
  • Access control: Manage permissions through Console settings

Token security best practices

Treat API keys like passwords. Never commit them to source control or expose them in client-side code.
Create and destroy sessions as needed for your use case. For automated testing, create a new session for each test run and close it when complete.
Use separate API keys (and projects) to isolate different environments or use cases. This helps organize your automations and manage access control.
Regularly rotate API keys, especially after team member changes or security incidents. You can manage keys in the Uplink Console.

Session lifecycle

Connection

When you connect to a session, the client establishes a WebSocket connection to the Uplink relay server:

Active session

During an active session:
  • Devices can connect and disconnect
  • Browsers can be launched and managed
  • Commands are sent in real-time
  • Events are emitted for device state changes

Closing a session

Always close the client when you’re done to properly clean up resources:

Session expiration

Sessions end when:
  • The connection is closed by the client (client.close())
  • The session is terminated in the Console
  • The API key used to create the session is revoked
  • Network connectivity is lost
When a session expires, all connected devices are disconnected and browsers are closed. Plan for graceful handling of session expiration in long-running automations.

Multi-session patterns

Load distribution

For high-volume automation, distribute load across multiple sessions:

Next steps

Device management

Learn how to manage devices in sessions

Client API

Explore the Client API reference