# 批量设置浏览器代理

为多个浏览器绑定代理。
- **前置条件**
：
`envIds`
 与
`uniqueIds`
 至少提供一个。传入的
`proxyId`
 必须已存在于团队中，否则调用被拒绝而不是自动创建。
- **副作用**
：在每个浏览器上写入
`proxyId`
。默认情况下，当
`proxyId`
 省略或为
`0`
 时，会复用连接信息完全相同的已有代理；
**若没有匹配项，则在调用方团队中新建一条代理记录**
。
- **完成信号**
：同步。运行中的浏览器仍使用启动时的代理。
- **重试**
：重新绑定同一个
`proxyId`
 是幂等的；但如果请求里带的是原始连接信息，每次去重未命中都可能再新建一条代理记录。

已记录的业务错误码：`19106`, `19193`, `14023`。 各错误码的含义见 [Error Codes](/zh/api-reference/getting-started/error-codes)。任何接口还可能返回通用错误码。

Endpoint: POST /env/setProxy/batch
Version: 2026-09-05
Security: OpenApiBearer

## Security:

  - `OpenApiBearer` (unknown)
    http bearer JWT

## Request fields (application/json):

  - `envIds` (array)
    浏览器 ID 列表。

  - `uniqueIds` (array)
    浏览器序号列表。
    Example: [1001]

  - `proxy` (object)
    代理连接信息。当 `proxyId` 指向已有代理时复用该代理；否则用这些字段新建代理。

  - `proxy.skipDuplicateProxy` (boolean)
    通过连接信息配置代理且未指定已有 `proxyId` 时生效。 设为 `true` 时复用匹配的代理，找不到匹配项时新建。设为 `false` 时即使已有匹配的代理也会新建。

  - `proxy.proxyId` (string)
    已有代理 ID。
    Example: 1800000000000101

  - `proxy.proxyIp` (string)
    代理主机或 IP 地址。
    Example: 127.0.0.1

  - `proxy.proxyPort` (integer)
    代理端口。
    Example: 1080

  - `proxy.proxyName` (string)
    代理名称。
    Example: proxy-a

  - `proxy.proxyType` (integer)
    代理协议：
- `0`
 — HTTP
- `1`
 — HTTPS
- `2`
 — SOCKS5
- `3`
 — SSH
    Enum: "0", "1", "2", "3"

  - `proxy.proxyProvider` (integer)
    代理类型。`0` 到 `3` 表示对应协议的普通代理；`4` 及以上标识商业代理类型：
- `0`
 — HTTP
- `1`
 — HTTPS
- `2`
 — SOCKS5
- `3`
 — SSH
- `4`
 — Oxylabs
- `5`
 — Proxys.io
- `6`
 — GeoSurf
- `7`
 — Luminati
- `8`
 — Lumauto
- `9`
 — Oxylabsauto
- `10`
 — Trojan
- `11`
 — Shadowsocks
- `12`
 — vmess
- `13`
 — ABCProxy
- `14`
 — LunaProxy
- `15`
 — IPHTML
- `16`
 — PiaProxy
- `17`
 — 922S5
- `18`
 — 360Proxy

未知的新增取值请按通用商业代理类型处理。
    Example: 0

  - `proxy.ipMonitor` (boolean)
    是否监控出口 IP 变化。
    Example: true

  - `proxy.ipChangeAction` (integer)
    出口 IP 变化后采取的动作。
    Example: 0

  - `proxy.username` (string)
    代理用户名。
    Example: user

  - `proxy.password` (string)
    代理密码。
    Example: pass

  - `proxy.refreshUrl` (string)
    代理刷新 URL。
    Example: https://example.com/refresh

  - `proxy.encryptionType` (integer)
    代理加密方式。
    Example: 0

  - `proxy.country` (string)
    国家或地区。
    Example: US

  - `proxy.state` (string)
    州或省。
    Example: CA

  - `proxy.city` (string)
    城市。
    Example: Los Angeles

## Response 200:

  - `200` (unknown)
    Success

## Response 200 fields (application/json):

  - `code` (integer, required)
    Return result code. `0` means success; other codes indicate exceptions.
    Example: 0

  - `msg` (string | null, required)
    Error message. Usually `null` on success.
    Example: null

  - `requestId` (string)
    Operation request ID. This field may be present when the request passes through the API gateway.
    Example: 1d4f3ea968664593860b94b35d4ebf5e

  - `data` (boolean, required)
    Whether the batch operation succeeded.
    Example: true

