Skip to main content

Execute Code in a Session

Run Playwright or agent-browser code in a standalone Interact session.
1 min read
post/interact/{sessionId}/execute
Request example
Response
post/interact/{sessionId}/execute

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#

Example Response (Success)#

Example Response (Error)#

Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.

Authorization

Authorizationstringheaderrequired#
Bearer authentication header of the form Bearer <token>, where <token> is your API key.

Path parameters

sessionIdstringrequired#
The interact session ID

Body

application/json
codestringrequired#
Code to execute in the browser sandbox

Length: 1–100000

languageenum<string>#
Language of the code to execute. Use node for JavaScript or bash for agent-browser CLI commands.

Default: "node"

Options:pythonnodebash
timeoutinteger#
Execution timeout in seconds

Range: 1–300

Responses

application/json
Code executed successfully
successboolean#
stdoutstring#
Standard output from the code execution
resultstring#
Standard output (alias for stdout)
stderrstring#
Standard error output from the code execution
exitCodeinteger#
Exit code of the executed process
killedboolean#
Whether the process was killed due to timeout
errorstring#
Error message if the code raised an exception