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 Settings → API 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:- Connect app
- Native SDK
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
Keep API keys secret
Keep API keys secret
Treat API keys like passwords. Never commit them to source control or expose them in client-side code.
Manage session lifecycle
Manage session lifecycle
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 project-specific keys
Use project-specific keys
Use separate API keys (and projects) to isolate different environments or use cases. This helps organize your automations and manage access control.
Rotate API keys regularly
Rotate API keys regularly
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
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