Create a managed browser session that can be reused across multiple browser actions. Sessions have a configurable TTL (time-to-live) up to 24 hours and are automatically cleaned up when they expire.
Your API key for authentication
Request Body
UUID of a browser profile to use for this session. When provided, the session will load the profile’s saved cookies, login sessions, and browser state.
Whether to save cookies and browser state changes back to the profile. Only applicable when profile_id is provided.
true (default): Changes ARE saved to the profile
false: Use profile’s current state but don’t save changes
Optional external Chrome DevTools Protocol WebSocket URL to bring your own browser. If not provided, a managed browser instance is created automatically.
Optional window configuration with width and height keys; defaults to {"width": 1280, "height": 720}
Time-to-live in seconds. Maximum 86400 (24 hours). Defaults to 600 (10 minutes).
Optional custom metadata to attach to the session for tracking purposes
Response Fields
Unique identifier for the created session
Chrome DevTools Protocol WebSocket URL for the browser session (if managed)
The configured screen dimensions
Session status: active, terminated, or expired
ISO 8601 timestamp when the session will expire
Custom metadata attached to the session Browser view URL to open in your browser for manual interaction
UUID of the browser profile being used (if applicable)
Whether changes will be saved to the profile (if applicable)
ISO 8601 timestamp when the session was created
ISO 8601 timestamp when the session was last updated
from dari import Dari
client = Dari( api_key = "YOUR_API_KEY" )
# Create a session with custom configuration
session = client.create_session(
screen_config = { "width" : 1920 , "height" : 1080 },
ttl = 3600 , # 1 hour
metadata = { "purpose" : "workflow-automation" , "user" : "john" }
)
print ( f "Session ID: { session[ 'session_id' ] } " )
print ( f "Expires at: { session[ 'expires_at' ] } " )
# Create a session with a browser profile (with persistence)
session = client.create_session(
profile_id = "550e8400-e29b-41d4-a716-446655440000" ,
persist_changes = True ,
ttl = 3600
)
print ( f "Session ID: { session[ 'session_id' ] } " )
print ( f "Live URL: { session[ 'metadata' ][ 'live_url' ] } " )
# Create a session with a browser profile (without persistence)
session = client.create_session(
profile_id = "550e8400-e29b-41d4-a716-446655440000" ,
persist_changes = False ,
ttl = 3600
)
Success Response
Success Response (with Browser Profile)
{
"session_id" : "sess_a1b2c3d4e5f6" ,
"cdp_url" : "ws://browser-proxy.usedari.com/devtools/browser/a1b2c3d4" ,
"screen_config" : {
"width" : 1920 ,
"height" : 1080
},
"status" : "active" ,
"expires_at" : "2024-11-26T10:34:00Z" ,
"metadata" : {
"purpose" : "workflow-automation" ,
"user" : "john"
},
"created_at" : "2024-11-26T09:34:00Z" ,
"updated_at" : "2024-11-26T09:34:00Z"
}
Usage Notes
Sessions are automatically cleaned up when they expire
Use the returned session_id with Run Single Action to execute actions in this session
Maximum TTL is 24 hours (86400 seconds)
Bring your own browser by providing a cdp_url parameter
Create sessions with sufficient TTL for your workflow - sessions cannot be extended after creation
Browser Profiles
When using profile_id, the session loads saved cookies, login sessions, and browser state from the profile
Set persist_changes: true (default) to save any changes made during the session back to the profile
Set persist_changes: false to use the profile’s state without modifying it (useful for testing or read-only operations)
Use the metadata.live_url to open the browser in your own browser for manual interaction (e.g., logging into websites)
After manually logging in, terminate the session to save the authentication state to the profile
See Create Browser Profile and List Browser Profiles for profile management
Error Responses
{
"detail" : "Invalid API key"
}
{
"detail" : "TTL cannot exceed 86400 seconds (24 hours)"
}