SOP 001: Create & Manage Sessions
Fresh| Field | Value |
|---|---|
| SOP ID | SOP-001 |
| Version | 1.0 |
| Status | Active |
| Source | Steel Sessions API |
Overview
Sessions are the atomic unit of the Steel API. Each session is an isolated browser instance running in Steel's cloud, maintaining its own state, cookies, and storage.
Prerequisites
- Steel account with API key
steel-sdkinstalled (npm install steel-sdk)
Session Lifecycle
Procedure
Step 1: Initialize the Steel Client
typescript
import Steel from 'steel-sdk';
const client = new Steel({
steelAPIKey: process.env.STEEL_API_KEY,
});Step 2: Create a Session
typescript
// Basic session (5-minute default timeout)
const session = await client.sessions.create();
// Session with options
const session = await client.sessions.create({
useProxy: true, // Residential proxy
solveCaptcha: true, // Auto CAPTCHA solving
timeout: 600000, // 10 minutes (milliseconds)
userAgent: 'custom-ua', // Custom user agent
});Step 3: Use the Session
Connect via Playwright, Puppeteer, or Selenium using the WebSocket URL:
wss://connect.steel.dev?apiKey=YOUR_KEY&sessionId=SESSION_IDStep 4: Release the Session
typescript
// Release single session
await client.sessions.release(session.id);
// Release ALL active sessions
await client.sessions.releaseAll();Always Release Sessions
Sessions are billed by the minute. Always release explicitly rather than waiting for timeout.
Session States
| State | Description | Next States |
|---|---|---|
| Live | Active, accepting commands | Released, Failed |
| Released | Intentionally shut down | Terminal |
| Failed | Crashed or connection lost | Terminal (auto-cleaned) |
Verification Checklist
- [ ] Session created successfully with valid
session.id - [ ]
session.sessionViewerUrlaccessible in browser - [ ] Automation connects via WebSocket
- [ ] Session released after use
- [ ] No orphaned sessions (check dashboard)
Troubleshooting
| Issue | Solution |
|---|---|
| Session creation fails | Check API key, verify account plan limits |
| Session times out quickly | Increase timeout parameter (ms) |
| Cannot connect to session | Verify WebSocket URL format, check API key |
| Orphaned sessions | Use client.sessions.releaseAll() |