A browser session represents a single browser instance running in the cloud. It’s the fundamental building block of Browsers, providing an isolated environment for your web automation tasks.
Creating a session
Create browser sessions through the Sessions API, which gives you full control over configuration and features. After creation, you’ll receive a connection URL to use with your preferred automation framework.
import { Browsers } from "@agentmq/browsers";
const browsers = new Browsers({ apiKey: process.env.AGENTMQ_TOKEN! });
const session = await browsers.sessions.create({
// Add configuration options here
});import os
from agentmq.browsers import Browsers
browsers = Browsers(api_key=os.environ["AGENTMQ_TOKEN"])
session = browsers.sessions.create(
# Add configuration options here
)curl --request POST \
--url "https://api.agent.mq/v1/browsers/sessions" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $AGENTMQ_TOKEN" \
--data '{
// Add configuration options here
}'Configuration options
When creating a session, you can configure various settings. For complete API details, see:
- Create Session API Reference
- Node.js SDK Reference
- Python SDK Reference
Basic settings
- Region: Decrease latency by choosing where your browser runs using browser regions
- Viewport - Set custom screen dimensions for your browser window.
- Keep alive: Enable longer-running sessions that run even after disconnection
- Recording - Enable/disable session replay (enabled by default)
- Logging - Enable/disable session logging for debugging (enabled by default)
Advanced features
-
Session identity - Configure browser identity:
- Automatic fingerprinting (devices, locales, operating systems)
- Proxy settings
- Captcha solving (enabled by default)
- Allowed domains
-
Extensions - Load custom browser extensions to enhance functionality
-
Browser Context - Configure isolated browsing contexts for session persistence
-
User Metadata - Attach custom data for session organization and filtering
Next steps
Once you’ve created a session, you can:
- Connect to it using your preferred automation framework - see Using a browser session
- Monitor it through the Session Inspector
- End it manually or let it timeout - see Manage a browser session
When to use Browsers
Reach for a session when the page requires interaction, the data sits behind a login or client-side JavaScript, or accuracy matters more than speed. A session logs in to portals with a managed identity, navigates complex pages, and extracts the data that a plain HTTP fetch never sees.