# スクレイピングしたページを操作する (/ja/api-reference/endpoint/scrape-execute)

<!-- agent-signals: reading_time_min: 5 · est_tokens: 3379 · updated: 2026-07-30 -->
Related: [検索](/ja/api-reference/endpoint/search.md), [検索フィードバック](/ja/api-reference/endpoint/search-feedback.md), [スクレイプ](/ja/api-reference/endpoint/scrape.md), [バッチスクレープ](/ja/api-reference/endpoint/batch-scrape.md), [バッチスクレイプのステータス取得](/ja/api-reference/endpoint/batch-scrape-get.md), [バッチスクレイプのキャンセル](/ja/api-reference/endpoint/batch-scrape-delete.md)

このエンドポイントを使用すると、以前のスクレイピングから初期化されたのと同じブラウザ状態で、引き続き操作できます。`code` または `prompt` のいずれか一方を指定する必要があります。両方は指定できません。

`POST /v2/scrape/{jobId}/interact` はライフサイクル全体を処理します。

1. このスクレイピングジョブ用のブラウザセッションがまだ存在しない場合、Firecrawl は元のスクレイピングと同じページ状態でブラウザセッションを作成します。
2. `code` が指定されている場合、Firecrawl はそれをブラウザサンドボックスで実行します。`prompt` が指定されている場合は、AI エージェントが自然言語を使ってタスクを自動化します。
3. 同じ `jobId` に対する後続の `POST /interact` 呼び出しでは、同じライブのブラウザ状態が再利用されます。

完了したら、`DELETE /v2/scrape/{jobId}/interact` を呼び出してセッションを停止します。

<div id="path-parameters">
  ## パスパラメータ [#パスパラメータ]
</div>

| パラメータ   | 型             | 必須 | 説明                                                          |
| ------- | ------------- | -- | ----------------------------------------------------------- |
| `jobId` | string (UUID) | はい | スクレイピングのレスポンス内の `data.metadata.scrapeId` に含まれるスクレイピングジョブ ID |

<div id="request-body">
  ## リクエストボディ [#リクエストボディ]
</div>

| パラメータ      | 型      | 必須  | デフォルト    | 説明                                                           |
| ---------- | ------ | --- | -------- | ------------------------------------------------------------ |
| `code`     | string | いいえ | —        | ブラウザサンドボックスで実行するコード (1～100,000文字) 。`prompt`が設定されていない場合は必須です。 |
| `prompt`   | string | いいえ | —        | AIエージェント向けの自然言語タスク (1～10,000文字) 。`code`が設定されていない場合は必須です。     |
| `language` | string | いいえ | `"node"` | `"python"`、`"node"`、`"bash"` のいずれか。`code`を使用する場合にのみ使われます。    |
| `timeout`  | number | いいえ | `30`     | 実行タイムアウト (秒)  (1～300) 。                                      |
| `origin`   | string | いいえ | —        | テレメトリに使用される任意のオリジンラベル。                                       |

<div id="response">
  ## レスポンス [#レスポンス]
</div>

| フィールド                    | 型       | 説明                                                                                                           |
| ------------------------ | ------- | ------------------------------------------------------------------------------------------------------------ |
| `success`                | boolean | 実行がエラーなく完了したかどうか                                                                                             |
| `cdpUrl`                 | string  | ブラウザセッション用の Chrome DevTools Protocol (CDP) の生の WebSocket URL。Playwright、Puppeteer、または任意の CDP クライアントで直接接続できます |
| `liveViewUrl`            | string  | ブラウザセッション用の読み取り専用ライブビューURL                                                                                   |
| `interactiveLiveViewUrl` | string  | インタラクティブ ライブビューURL (閲覧者がブラウザを操作可能)                                                                           |
| `output`                 | string  | AIエージェントの最終レスポンス (`prompt` を使用した場合のみ存在)                                                                      |
| `stdout`                 | string  | コード実行の標準出力                                                                                                   |
| `result`                 | string  | 戻り値 — Node.js では最後の式の値、`prompt` では最終ページのスナップショット                                                             |
| `stderr`                 | string  | 標準エラー出力                                                                                                      |
| `exitCode`               | number  | 実行の終了コード (`0` = 成功)                                                                                          |
| `killed`                 | boolean | タイムアウトにより実行が終了したかどうか                                                                                         |
| `error`                  | string  | エラーメッセージ (失敗時のみ存在)                                                                                           |

<div id="example-request-code">
  ### リクエスト例 (コード) [#リクエスト例-コード]
</div>

```bash
curl -X POST "https://api.firecrawl.dev/v2/scrape/550e8400-e29b-41d4-a716-446655440000/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "const title = await page.title(); JSON.stringify({ title });",
    "language": "node",
    "timeout": 30
  }'
```

<div id="example-response-code">
  ### レスポンス例 (コード) [#レスポンス例-コード]
</div>

```json
{
  "success": true,
  "cdpUrl": "wss://browser.firecrawl.dev/...",
  "liveViewUrl": "https://liveview.firecrawl.dev/...",
  "interactiveLiveViewUrl": "https://liveview.firecrawl.dev/...",
  "stdout": "",
  "result": "{\"title\":\"Example Domain\"}",
  "stderr": "",
  "exitCode": 0,
  "killed": false
}
```

<div id="example-request-prompt">
  ### リクエスト例 (Prompt) [#リクエスト例-prompt]
</div>

```bash
curl -X POST "https://api.firecrawl.dev/v2/scrape/550e8400-e29b-41d4-a716-446655440000/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Find the pricing section and tell me the price of the Pro plan",
    "timeout": 60
  }'
```

<div id="example-response-prompt">
  ### レスポンス例 (Prompt) [#レスポンス例-prompt]
</div>

```json
{
  "success": true,
  "cdpUrl": "wss://browser.firecrawl.dev/...",
  "liveViewUrl": "https://liveview.firecrawl.dev/...",
  "interactiveLiveViewUrl": "https://liveview.firecrawl.dev/...",
  "output": "The Pro plan costs $49/month and includes unlimited scrapes, priority support, and custom integrations.",
  "stdout": "...",
  "result": "...",
  "stderr": "",
  "exitCode": 0,
  "killed": false
}
```

<div id="error-codes">
  ### エラーコード [#エラーコード]
</div>

| ステータス | 説明                                            |
| ----- | --------------------------------------------- |
| `402` | ブラウザセッションのクレジットが不足しています                       |
| `403` | スクレイピングジョブは別のチームに属しています                       |
| `404` | スクレイピングジョブが見つかりません                            |
| `409` | リプレイコンテキストを利用できません — スクレイピングを再実行してもう一度お試しください |
| `410` | ブラウザセッションはすでに破棄されています                         |
| `429` | 同時ブラウザセッション数の上限に達しました                         |
| `502` | ブラウザサービスまたはAIエージェントの実行に失敗しました                 |
| `503` | ブラウザ機能が設定されていません (セルフホスト環境のみ)                 |

詳細な使用方法と例については、[Interact機能ガイド](/ja/features/interact)を参照してください。

`POST /scrape/{jobId}/interact`

スクレイピングジョブに関連付けられたブラウザセッションを操作します

## OpenAPI

```json
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "description": "スクレイピングジョブの job ID",
      "in": "path",
      "name": "jobId",
      "required": true,
      "schema": {
        "format": "uuid",
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "code": {
              "description": "スクレイピングに紐付けられたブラウザサンドボックスで実行するコード",
              "maxLength": 100000,
              "minLength": 1,
              "type": "string"
            },
            "language": {
              "default": "node",
              "description": "実行するコードの言語。JavaScript には `node`、agent-browser の CLI コマンドには `bash` を使用します。",
              "enum": [
                "python",
                "node",
                "bash"
              ],
              "type": "string"
            },
            "origin": {
              "description": "実行テレメトリーで使用する任意のオリジンラベル",
              "type": "string"
            },
            "timeout": {
              "default": 30,
              "description": "実行タイムアウト（秒）",
              "maximum": 300,
              "minimum": 1,
              "type": "integer"
            }
          },
          "required": [
            "code"
          ],
          "type": "object"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "cdpUrl": {
                "description": "ブラウザセッション用の生の Chrome DevTools Protocol（CDP）WebSocket URL。これを使用して、Playwright、Puppeteer、または任意の CDP クライアントから直接接続できます。",
                "nullable": true,
                "type": "string"
              },
              "error": {
                "description": "コードで例外が発生した場合のエラーメッセージ",
                "nullable": true,
                "type": "string"
              },
              "exitCode": {
                "description": "実行されたプロセスの終了コード",
                "nullable": true,
                "type": "integer"
              },
              "interactiveLiveViewUrl": {
                "description": "インタラクティブ ライブビュー URL（閲覧者がブラウザを操作できます）",
                "nullable": true,
                "type": "string"
              },
              "killed": {
                "description": "タイムアウトによりプロセスが強制終了されたかどうか",
                "type": "boolean"
              },
              "liveViewUrl": {
                "description": "ブラウザセッション用の読み取り専用ライブビュー URL",
                "nullable": true,
                "type": "string"
              },
              "output": {
                "description": "AI agent の最終レスポンス（prompt を使用した場合にのみ含まれます）",
                "nullable": true,
                "type": "string"
              },
              "result": {
                "description": "標準出力（stdout の別名）",
                "nullable": true,
                "type": "string"
              },
              "stderr": {
                "description": "コード実行時の標準エラー出力",
                "nullable": true,
                "type": "string"
              },
              "stdout": {
                "description": "コード実行時の標準出力",
                "nullable": true,
                "type": "string"
              },
              "success": {
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "コードは正常に実行されました"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Invalid job ID format.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "無効な job ID"
    },
    "402": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Payment required to access this resource.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "支払いが必要です"
    },
    "403": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Forbidden.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "アクセスが拒否されました"
    },
    "404": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Job not found.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "スクレイピングジョブが見つかりません"
    },
    "409": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Replay context is unavailable for this scrape job. Please rerun the scrape.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "スクレイピングのリプレイコンテキストを利用できないか、セッションを初期化できませんでした"
    },
    "410": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Browser session has been destroyed.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "スクレイピングのブラウザセッションはすでに破棄されています"
    },
    "429": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "You have reached the maximum number of active browser sessions.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "アクティブなブラウザセッションが多すぎます"
    },
    "502": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Failed to execute code in browser session.",
                "type": "string"
              },
              "success": {
                "example": false,
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "ブラウザサービスとの通信に失敗しました"
    }
  }
}
```
