Skip to main content
POST
/
browser
/
{sessionId}
/
execute
Execute code in a browser session
curl --request POST \
  --url https://api.firecrawl.dev/v2/browser/{sessionId}/execute \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "<string>",
  "language": "node",
  "timeout": 150
}
'
{
  "success": true,
  "stdout": "<string>",
  "result": "<string>",
  "stderr": "<string>",
  "exitCode": 123,
  "killed": true,
  "error": "<string>"
}

Headers

HeaderValue
AuthorizationBearer <API_KEY>
Content-Typeapplication/json

Request Body

ParameterTypeRequiredDefaultDescription
codestringYes-Code to execute (1-100,000 characters)
languagestringNo"node"Language of the code: "python", "node", or "bash" (for agent-browser CLI commands)
timeoutnumberNo-Execution timeout in seconds (1-300)

Response

FieldTypeDescription
successbooleanWhether the code executed successfully
stdoutstringStandard output from the code execution
resultstringStandard output from the code execution
stderrstringStandard error output from the code execution
exitCodenumberExit code of the executed process
killedbooleanWhether the process was killed due to timeout
errorstringError message if execution failed (only present on failure)

Example Request

curl -X POST "https://api.firecrawl.dev/v2/browser/550e8400-e29b-41d4-a716-446655440000/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "await page.goto(\"https://example.com\")\ntitle = await page.title()\nprint(title)",
    "language": "python"
  }'

Example Response (Success)

{
  "success": true,
  "result": "Example Domain"
}

Example Response (Error)

{
  "success": true,
  "error": "TimeoutError: page.goto: Timeout 30000ms exceeded."
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

sessionId
string
required

The browser session ID

Body

application/json
code
string
required

Code to execute in the browser sandbox

Required string length: 1 - 100000
language
enum<string>
default:node

Language of the code to execute. Use node for JavaScript or bash for agent-browser CLI commands.

Available options:
python,
node,
bash
timeout
integer

Execution timeout in seconds

Required range: 1 <= x <= 300

Response

Code executed successfully

success
boolean
stdout
string | null

Standard output from the code execution

result
string | null

Standard output (alias for stdout)

stderr
string | null

Standard error output from the code execution

exitCode
integer | null

Exit code of the executed process

killed
boolean

Whether the process was killed due to timeout

error
string | null

Error message if the code raised an exception