> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trae.cn/llms.txt?lang=zh
> Use this file to discover all available pages before exploring further.

重置企业成员的账号密码。

## 所需权限 {#hGsRFzLmA}

`users:write`

## 请求说明 {#hMMmAM1uG}

* 请求方式：`POST`
* 请求地址：`{域名}/openapi/v1/users/reset_password`

## 注意事项 {#hnlhK1mwl}


* 单次请求最多重置 100 个成员的账号密码。
* 本接口支持批量部分成功。顶层 `code=0` 仅表示请求处理完成，不代表每个成员的账号密码均重置成功，需根据 `failed_items` 判断逐项结果。
* 仅支持重置由 TRAE 企业账号体系管理的成员密码。以下成员的账号密码不会被重置：超级管理员、非当前企业的成员、已注销成员、外部身份源（包括火山引擎云身份中心）托管的成员不会被修改。
* 同一成员在同一个请求中被重复传入时，第一项会被处理，后续项会失败。
* 密码重置成功后，相关成员已有的登录 Session 和 Refresh Token 将被清理。成员需要使用新密码重新登录。

## 请求参数 {#请求参数}

### 请求头参数 {#请求头参数}

<!-- @cols-width: 172,122,614 -->
| **Header 参数**  | **是否必填**  | **描述**  |
| --- | --- | --- |
| `Authorization`  | 是  | 固定取值为 `Bearer {access_token}`。关于如何获取访问令牌，参考[鉴权](enterprise_authentication)。  |
| `Content-Type`  | 是  | 固定取值为 `application/json`。  |

### 请求体参数 {#hjt8Dj4zM}

<!-- @cols-width: 190,100,145,477 -->
| **参数**  | **类型**  | **是否必填**  | **描述**  |
| --- | --- | --- | --- |
| `users`  | array  | 是  | 待重置账号密码的成员列表。范围为 1 至 100 个。  |
| `users[].email`  | string  | 条件必填  | 成员的邮箱地址，不区分大小写。 | \
| | | | | \
| | | | 与 `user_id` 至少传入一个；若与 `user_id` 同时传入，两者必须指向同一成员。 | \
| | | | | \
| | | | 你可以调用 “[获取成员列表](/enterprise_get-user-list)” 接口来获取成员的邮箱。  |
| `users[].user_id`  | string  | 条件必填  | 成员的用户 ID。 | \
| | | | | \
| | | | 与 `email` 至少传入一个；若与 `email` 同时传入，两者必须指向同一成员。 | \
| | | | | \
| | | | 你可以调用 “[获取成员列表](/enterprise_get-user-list)” 接口来获取成员的 ID。  |
| `users[].password`  | string  | 是  | 新的密码。 | \
| | | | | \
| | | | 长度至少 8 位；不能包含空白字符；大写字母、小写字母、数字、特殊字符四类中至少包含三类。  |

## 响应参数 {#hkOy4UvjI}

该接口独有的响应参数如下，参数位于 `data` 中。通用响应参数参考[此文档](/enterprise_general-response-schema)。

<!-- @cols-width: 281,127,502 -->
| **参数**  | **类型**  | **描述**  |
| --- | --- | --- |
| `success_count`  | int  | 成功重置密码的成员数量。  |
| `failed_items`  | array  | 重置密码失败的成员列表。全部成功时返回 `[]`。  |
| `failed_items[].index`  | int  | 重置密码失败的成员在请求中传入的 `users` 数组中的下标，从 `0` 开始。  |
| `failed_items[].email`  | string  | 若在请求中传入了成员的邮箱，则返回该邮箱，否则省略。  |
| `failed_items[].user_id`  | string  | 若在请求中传入了成员的用户 ID，则返回该用户 ID，否则省略。  |
| `failed_items[].code`  | int  | 错误码。  |
| `failed_items[].message`  | string  | 失败原因。  |

## 示例 {#示例}

### 请求示例 {#hwNw3peHA}

```Bash
curl -X POST "${HOST}/openapi/v1/users/reset_password" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "users": [
      {
        "email": "john@example.com",
        "password": "NewAa123!"
      },
      {
        "user_id": "123456789012345678",
        "password": "NewBb123!"
      }
    ]
  }'
```

### 响应示例 {#hNjKloFqH}

```JSON
{
  "code": 0,
  "message": "success",
  "request_id": "021xxxxxxxxx",
  "data": {
    "success_count": 1,
    "failed_items": [
      {
        "index": 1,
        "email": "bob@example.com",
        "user_id": "123456",
        "code": 30019,
        "message": "password invalid"
      }
    ]
  }
}
```

## 错误码 {#错误码}

若该接口的请求返回错误码，参考[错误码](/enterprise_error-codes)文档进行排查。
