Skip to main content

Interact with a Scraped Page

Execute code or an AI prompt in the browser session bound to a scrape job.
3 min read
post/scrape/{jobId}/interact
Request example
Response
post/scrape/{jobId}/interact

Use this endpoint to continue interacting with the same browser state initialized from a previous scrape. Either code or prompt must be provided — not both.

POST /v2/scrape/{jobId}/interact handles the full lifecycle:

  1. If no browser session exists for this scrape job yet, Firecrawl creates one at the same page state as the original scrape.
  2. When code is provided, Firecrawl runs it in the browser sandbox. When prompt is provided, an AI agent automates the task using natural language.
  3. Later POST /interact calls on the same jobId reuse the same live browser state.

When you are done, call DELETE /v2/scrape/{jobId}/interact to stop the session.

Path Parameters#

ParameterTypeRequiredDescription
jobIdstring (UUID)YesThe scrape job ID from data.metadata.scrapeId in the scrape response

Request Body#

ParameterTypeRequiredDefaultDescription
codestringNoCode to execute in the browser sandbox (1–100,000 chars). Required if prompt is not set.
promptstringNoNatural language task for the AI agent (1–10,000 chars). Required if code is not set.
languagestringNo"node"One of "python", "node", or "bash". Only used with code.
timeoutnumberNo30Execution timeout in seconds (1–300).
originstringNoOptional origin label used for telemetry.

Response#

FieldTypeDescription
successbooleanWhether the execution completed without errors
cdpUrlstringRaw Chrome DevTools Protocol (CDP) WebSocket URL for the browser session. Connect directly with Playwright, Puppeteer, or any CDP client
liveViewUrlstringRead-only live view URL for the browser session
interactiveLiveViewUrlstringInteractive live view URL (viewers can control the browser)
outputstringAI agent's final response (only present when using prompt)
stdoutstringStandard output from the code execution
resultstringReturn value — last expression value for Node.js, final page snapshot for prompt
stderrstringStandard error output
exitCodenumberExit code of the execution (0 = success)
killedbooleanWhether the execution was terminated due to timeout
errorstringError message (only present on failure)

Example Request (Code)#

Example Response (Code)#

Example Request (Prompt)#

Example Response (Prompt)#

Error Codes#

StatusDescription
402Insufficient credits for a browser session
403Scrape job belongs to a different team
404Scrape job not found
409Replay context unavailable — rerun the scrape and try again
410Browser session has already been destroyed
429Maximum concurrent browser sessions reached
502Browser service or AI agent execution failed
503Browser feature not configured (self-hosted only)

For detailed usage with examples, see the Interact feature guide.

Authorization

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

Path parameters

jobIdstringrequired#
The scrape job ID

Body

application/json
codestringrequired#
Code to execute in the scrape-bound 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

Default: 30

Range: 1–300

originstring#
Optional origin label used for execution telemetry

Responses

application/json
Code executed successfully
successboolean#
cdpUrlstring#
Raw Chrome DevTools Protocol (CDP) WebSocket URL for the browser session. Use it to connect directly with Playwright, Puppeteer, or any CDP client.
liveViewUrlstring#
Read-only live view URL for the browser session
interactiveLiveViewUrlstring#
Interactive live view URL (viewers can control the browser)
outputstring#
AI agent's final response (only present when using prompt)
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