# 创建交互会话 (/zh/api-reference/endpoint/browser-create)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 1379 · updated: 2026-07-30 -->
Related: [Search（搜索）](/zh/api-reference/endpoint/search.md), [搜索反馈](/zh/api-reference/endpoint/search-feedback.md), [Scrape](/zh/api-reference/endpoint/scrape.md), [批量抓取](/zh/api-reference/endpoint/batch-scrape.md), [获取批量抓取状态](/zh/api-reference/endpoint/batch-scrape-get.md), [取消批量抓取](/zh/api-reference/endpoint/batch-scrape-delete.md)

<div id="headers">
  ## 请求头 [#请求头]
</div>

| Header          | 值                  |
| --------------- | ------------------ |
| `Authorization` | `Bearer <API_KEY>` |
| `Content-Type`  | `application/json` |

<div id="request-body">
  ## 请求体 [#请求体]
</div>

| 参数                    | 类型      | 必填  | 默认值    | 描述                                                                       |
| --------------------- | ------- | --- | ------ | ------------------------------------------------------------------------ |
| `ttl`                 | number  | 否   | 600    | 会话总有效期（秒）（30-3600）                                                       |
| `activityTtl`         | number  | 否   | 300    | 会话在销毁前允许的不活动时长（秒）（10-3600）                                               |
| `profile`             | object  | 否   | —      | 启用跨会话的持久化存储。参见下文。                                                        |
| `profile.name`        | string  | 是\* | —      | 配置文件名称（1-128 字符）。具有相同名称的会话共享存储。                                          |
| `profile.saveChanges` | boolean | 否   | `true` | 当为 `true` 时，在关闭时会将浏览器状态保存回该配置文件。设为 `false` 可在不写入的情况下加载已有数据。同一时间只允许一个保存方。 |

<div id="response">
  ## 响应 [#响应]
</div>

| 字段                       | 类型      | 描述                         |
| ------------------------ | ------- | -------------------------- |
| `success`                | boolean | 会话是否创建成功                   |
| `id`                     | string  | 唯一的会话标识符                   |
| `cdpUrl`                 | string  | 用于 CDP 连接的 WebSocket 地址    |
| `liveViewUrl`            | string  | 用于实时查看会话的 URL              |
| `interactiveLiveViewUrl` | string  | 用于与会话进行实时交互（点击、输入、滚动）的 URL |
| `expiresAt`              | string  | 会话基于 TTL 的过期时间             |

<div id="example-request">
  ### 请求示例 [#请求示例]
</div>

```bash
curl -X POST "https://api.firecrawl.dev/v2/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ttl": 120
  }'
```

<div id="example-response">
  ### 响应示例 [#响应示例]
</div>

```json
{
  "success": true,
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "cdpUrl": "wss://cdp-proxy.firecrawl.dev/cdp/550e8400-e29b-41d4-a716-446655440000",
  "liveViewUrl": "https://liveview.firecrawl.dev/550e8400-e29b-41d4-a716-446655440000",
  "interactiveLiveViewUrl": "https://liveview.firecrawl.dev/550e8400-e29b-41d4-a716-446655440000?interactive=true"
}
```

> 如果你是需要 Firecrawl API 密钥的 AI 代理，请参阅 [firecrawl.dev/agent-onboarding/SKILL.md](https://www.firecrawl.dev/agent-onboarding/SKILL.md) 获取自动化接入说明。

`POST /interact`

创建交互会话

## OpenAPI

```json
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "activityTtl": {
              "description": "会话因无活动而被销毁前的时间（秒）",
              "maximum": 3600,
              "minimum": 10,
              "type": "integer"
            },
            "profile": {
              "description": "在多个交互会话之间启用持久化存储。在一个会话中保存的数据，可在后续使用相同名称的会话中加载。",
              "properties": {
                "name": {
                  "description": "配置文件名称。名称相同的会话共享存储。",
                  "maxLength": 128,
                  "minLength": 1,
                  "type": "string"
                },
                "saveChanges": {
                  "default": true,
                  "description": "为 true 时，关闭时会将浏览器状态保存回配置文件。设为 false 可加载现有数据而不写入。允许同时存在多个不保存的会话，但同一时间只允许一个保存会话。",
                  "type": "boolean"
                }
              },
              "required": [
                "name"
              ],
              "type": "object"
            },
            "streamWebView": {
              "default": true,
              "description": "是否流式传输浏览器的实时画面",
              "type": "boolean"
            },
            "ttl": {
              "default": 300,
              "description": "交互会话的总存活时间（秒）",
              "maximum": 3600,
              "minimum": 30,
              "type": "integer"
            }
          },
          "type": "object"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "cdpUrl": {
                "description": "用于访问 Chrome DevTools Protocol 的 WebSocket URL",
                "type": "string"
              },
              "expiresAt": {
                "description": "会话基于 TTL 的过期时间",
                "format": "date-time",
                "type": "string"
              },
              "id": {
                "description": "唯一会话标识符",
                "type": "string"
              },
              "interactiveLiveViewUrl": {
                "description": "用于实时与交互会话交互的 URL（点击、输入、滚动）",
                "type": "string"
              },
              "liveViewUrl": {
                "description": "用于实时查看交互会话的 URL",
                "type": "string"
              },
              "success": {
                "type": "boolean"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "交互会话创建成功"
    },
    "402": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "error": {
                "example": "Payment required to access this resource.",
                "type": "string"
              }
            },
            "type": "object"
          }
        }
      },
      "description": "需要付费"
    }
  }
}
```
