Skip to content

SOP 001: Create & Manage Sessions

Fresh
FieldValue
SOP IDSOP-001
Version1.0
StatusActive
SourceSteel 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-sdk installed (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_ID

Step 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

StateDescriptionNext States
LiveActive, accepting commandsReleased, Failed
ReleasedIntentionally shut downTerminal
FailedCrashed or connection lostTerminal (auto-cleaned)

Verification Checklist

  • [ ] Session created successfully with valid session.id
  • [ ] session.sessionViewerUrl accessible in browser
  • [ ] Automation connects via WebSocket
  • [ ] Session released after use
  • [ ] No orphaned sessions (check dashboard)

Troubleshooting

IssueSolution
Session creation failsCheck API key, verify account plan limits
Session times out quicklyIncrease timeout parameter (ms)
Cannot connect to sessionVerify WebSocket URL format, check API key
Orphaned sessionsUse client.sessions.releaseAll()

See Also

SOP Documentation Hub - Built from Steel.dev Official Docs