const session = await bb.sessions.create({
// Project ID (optional - inferred from API key if not provided)
projectId: "your-project-id",
// Proxy configuration
proxies: true, // Use default proxy
// Region where the session runs
region: "us-west-2",
// Keep session alive after disconnection
keepAlive: true,
// Session timeout in seconds (60-21600)
timeout: 3600,
// Extension ID (uploaded via Upload Extension API)
extensionId: "ext_abc123",
// Browser settings
browserSettings: {
// Toggle features
blockAds: true,
solveCaptchas: true,
recordSession: true,
logSession: true,
advancedStealth: true,
// Operating system (only available with advancedStealth)
// Controls user agent and environment signals
os: "windows",
// Context for session persistence
context: {
id: "my-context-id",
persist: true,
},
// Viewport configuration (ignored when advancedStealth is enabled)
viewport: {
width: 1920,
height: 1080,
},
// Custom captcha selectors
captchaImageSelector: "#captcha-image",
captchaInputSelector: "#captcha-input",
},
// Custom metadata for the session
userMetadata: {
userId: "user_123",
taskName: "scraping-job",
},
});