更新时间:2026-11-04 GMT+08:00
分享

保存浏览器 Profile - SaveBrowserProfile

功能介绍

该 API 用于将当前浏览器 Session 的状态(cookie / localStorage / sessionStorage)

保存到指定的 Profile。通过 CDP 提取浏览器状态后打包上传到 OBS,覆盖之前的 Profile 数据。

Profile 不自动保存,需由 SDK / Agent 在合适时机(如登录成功后)显式调用。

调用方法

请参见如何调用API。

授权信息

当前API调用无需身份策略权限。

URI

PUT https://agentarts.com/v1/browsers/{browser_name}/save-profile

表1 路径参数

参数

是否必选

参数类型

描述

browser_name

是

String

参数解释:

与会话关联的浏览器工具的唯一标识符。

浏览器工具名称获取方式:

1.进入 AgentArts 平台,在左侧导航栏选择"托管与运行 > 浏览器"。

2.在浏览器工具列表中"浏览器工具名称/ID"处获取名称。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

Authorization

是

String

参数解释:

本次智能体工具调用对应的身份认证凭据。需要根据实际的智能体工具的入站身份认证方式获取对应的身份认证凭据。

API Key认证、IAM认证及OAuth 2.0认证具体请参见认证鉴权。

约束限制:

不涉及。

取值范围:

1-4096个字符,由字母、数字及特殊字符组成。

默认取值:

不涉及。

X-Hw-Agentarts-Browser-Session-Id

是

String

参数解释:

要使用的浏览器会话的唯一标识符。

约束限制:

必须是通过 StartBrowserSession 创建的活跃会话。如果会话已过期或已停止,请求将失败。

取值范围:

符合正则:^[a-zA-Z0-9_-]+$。

默认取值:

不涉及。

X-Hw-Agentarts-Browser-Profile-Id

是

String

参数解释:

浏览器 Profile 的唯一标识符。由控制面创建并返回。

约束限制:

长度范围:1到128个字符。

取值范围:

长度1到128个字符。

默认取值:

不涉及。

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

profile_id

String

参数解释:

已保存的 Profile ID。

取值范围:

长度1到128个字符。

saved_at

String

参数解释:

Profile 保存时间(ISO 8601 格式)。

取值范围:

ISO 8601日期时间格式字符串。

size_bytes

Long

参数解释:

Profile 数据包大小(字节)。

取值范围:

0到52428800。

cookie_count

Integer

参数解释:

保存的 cookie 数量。

取值范围:

0到100000。

origin_count

Integer

参数解释:

保存的 origin(localStorage/sessionStorage)数量。

取值范围:

0到100000。

状态码:400

表4 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:401

表5 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:403

表6 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:404

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:413

表8 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:429

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:500

表10 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

请求示例

/v1/browsers/my-browser/save-profile

null

响应示例

状态码:200

{
  "profile_id" : "profile-abc123",
  "saved_at" : "2022-11-09 16:37:24",
  "size_bytes" : 25600,
  "cookie_count" : 42,
  "origin_count" : 5
}

状态码:400

{
  "error_code" : "AgentArts.04020001",
  "error_msg" : "Invalid parameter."
}

状态码:401

{
  "error_code" : "AgentArts.04020002",
  "error_msg" : "Authentication failed: invalid token"
}

状态码:403

{
  "error_code" : "AgentArts.04020003",
  "error_msg" : "Authentication failed: you have no permission."
}

状态码:404

{
  "error_code" : "AgentArts.04020004",
  "error_msg" : "Resource not found: session_id=sess-xxx"
}

状态码:413

{
  "error_code" : "AgentArts.04020009",
  "error_msg" : "Profile data too large: exceeds 50MB limit"
}

状态码:429

{
  "error_code" : "AgentArts.04020006",
  "error_msg" : "Request throttled: too many requests"
}

状态码:500

{
  "error_code" : "AgentArts.04020000",
  "error_msg" : "System error. Please retry."
}

状态码

状态码

描述

200

OK

400

请求参数错误

401

认证失败

403

权限不足

404

资源不存在

413

Profile 数据过大

429

请求频率超限

500

内部系统错误

错误码

请参见错误码。

相关文档