Skip to content
Firecrawl Docsv2
Firecrawl Docs
Interact Endpoints

Execute Code in a Session

POST/interact/{sessionId}/execute

Run Playwright or agent-browser code in a standalone Interact session.

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/interact/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."
}

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

Was this page helpful?Suggest editsRaise issue