Skip to content
中文

Update a context

PUT/browser/v1/contexts/{contextId}● Supported

Request parameters

  • contextIdstringrequired

    登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。

  • namestringoptional

    登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。

  • labelsobjectoptional

    自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。 更新时整体替换;空对象清除标签,省略则保留。

  • proxyunionoptional

    给登录态绑定一个固定的外部代理(如住宅 IP),使用这个登录态的会话没有写 proxies 时都经它出网,让同一账号始终从同一个出口地址出去。只存保管库引用(password_secret),不存密码;会话自己写了 proxies 时以会话的为准。需要组织已开通容器后端,否则返回 501 PROVIDER_UNSUPPORTED。 更新时传 null 解除绑定,省略则保留原绑定。

Returns

200

Errors contain statusCode, error and message; the native API adds code. The request ID is in X-Request-Id. Errors

Request example

curl
curl -X PUT "https://api.deepraxis.com/browser/v1/contexts/${CONTEXT_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"work-login"}'
Python
import os, requests

response = requests.request("PUT", f"https://api.deepraxis.com/browser/v1/contexts/{os.environ['CONTEXT_ID']}",
    headers={"Authorization": "Bearer " + os.environ["PRAXIS_API_KEY"]},
    json={"name":"work-login"}
)
print(response.status_code, response.text)
TypeScript
const CONTEXT_ID = process.env.CONTEXT_ID;
if (!CONTEXT_ID) throw new Error("Set CONTEXT_ID");
const response = await fetch(`https://api.deepraxis.com/browser/v1/contexts/${CONTEXT_ID}`, {
  method: "PUT",
  headers: { "Authorization": `Bearer ${process.env.PRAXIS_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({"name":"work-login"}),
});
console.log(response.status, await response.text());

Connection guide

Response

HTTP 200

请求成功。

application/json

Name Type Description
id string 登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
projectId string 兼容项目标识,当前账户的登录态固定返回 default。
createdAt string 登录态创建时刻,UTC ISO 8601 时间。
updatedAt string 登录态名称、标签或保存内容最近一次更新的时刻,UTC ISO 8601 时间。
name string 登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。
labels object 自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
sites array<string> 已保存的 localStorage 主机名和 cookie 域名,去掉 cookie 域名前导点后去重排序。
cookieCount integer 登录态中已保存的 cookie 条目数量;新登录态为 0。
bytes integer 登录态加密后保存内容的大小,单位为 UTF-8 字节。
lockedBy string 当前登录态写入租约的持有者标识;无有效租约时省略。
lastUsedAt string UTC timestamp when a session last started with this context; absent if it has never been used.
proxy object 登录态绑定的固定外部代理(只含保管库引用,不含密码);没有绑定时省略。
proxy.type string 固定为 external:经一个你自己的外部 HTTP 代理出网。
proxy.server string 代理地址,host:port 或 http://host:port;只支持 HTTP 代理,不接受 socks5:// 等协议,也不接受 localhost 和内网、链路本地地址。
proxy.username string 代理用户名;有密码时才能填,填了就必须同时给出密码。
proxy.password_secret object 必须用这种形式:引用保管库里的代理密码,只在连接这个代理的主机时兑换,不会交给网页。登录态里只存引用,传明文 password 返回 400 INVALID_PARAMS。