Skip to main content

Overview

Multi-task workflows allow you to reuse a single browser session for multiple sequential tasks. This is more efficient than creating a new session for each task, as the browser state persists between tasks. When to use:
  • Multiple related tasks on the same website
  • Workflows that build on previous actions (e.g., login → search → checkout)
  • Scenarios where maintaining browser state (cookies, local storage) is important
For workflows that span multiple sessions (e.g., daily recurring tasks that need to stay logged in), use environments to persist cookies, files, and browser data between sessions.
When not to use:
  • Single, isolated tasks (use /start/run-task instead)
  • Unrelated tasks across different websites

Creating Persistent Sessions

Use the /start/start-session endpoint to create a session that remains active for multiple tasks.
Response:
Save the sessionId from the response: you’ll need it for all follow-up tasks.

Sending Follow-Up Tasks

After creating a session, send additional tasks using the /start/send-message endpoint with actionType: "newTask".
Response (completed within 50 seconds):
Response (still running):

Complete Working Example

This example demonstrates a complete multi-task workflow: creating a session, sending multiple tasks, polling for results, and terminating the session.

Single vs Multi-Task Comparison

Use /start/run-task for Single Tasks

When you only need to execute one task and don’t need session persistence:
  • Session automatically terminates when task completes
  • No need to manage sessionId
  • terminateOnCompletion: true is set automatically
  • More cost-effective for isolated tasks

Use /start/start-session for Multi-Task Workflows

When you need to:
  • Execute multiple related tasks
  • Maintain browser state between tasks
  • Potentially interact manually between tasks
  • Have control over session lifecycle

Session Parameters

Configure your session behavior with these parameters: Top-level parameters: task parameters: Example with parameters:
  • maxDuration is the max task duration (default and max: 5 minutes). Session inactivity timeout is fixed at 5 minutes
  • prompt can be empty if you plan to send tasks later via /start/send-message
  • Always terminate sessions when done to avoid unnecessary charges

Best Practices

1. Always Terminate Sessions

Don’t forget to terminate sessions when your workflow completes:
Or use terminateOnCompletion on your final task:

2. Handle Errors Gracefully

Always check for errors and handle guardrails:

3. Poll with Reasonable Intervals

Don’t poll too frequently:

4. Use WebSocket for Real-Time Updates

For better UX and efficiency, consider WebSocket instead of polling: