> ## 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.

获取指定时间范围内，企业在各客户端的活跃成员数。

## 所需权限 {#24460232}

`statistics:read`

## 请求说明 {#bde6271b}

* 请求方式：`GET`
* 请求地址：`{域名}/openapi/v1/statistics/active-users`

## 注意事项 {#hG03XRrke}

时间跨度最长为 180 天。

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

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

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

### 查询参数 {#068dd195}

<!-- @cols-width: 146,100,100,140,411 -->
| **参数**  | **类型**  | **是否必填**  | **默认值**  | **描述**  |
| --- | --- | --- | --- | --- |
| `start_date`  | string  | 是  | \-  | 开始日期。格式：YYYY-MM-DD。  |
| `end_date`  | string  | 是  | \-  | 结束日期。格式：YYYY-MM-DD。  |
| `timezone`  | string  | 否  | `"Asia/Shanghai"`  | 时区。需使用 IANA 时区名称。  |
| `department_id`  | string  | 否  | \-  | 目标部门的 ID。若传入该参数，则仅返回该部门的数据。省略则统计整个企业的数据。 | \
| | | | | | \
| | | | | 部门 ID 可以通过 “[获取单个父部门的子部门](/enterprise_get-the-subdepartments-for-a-specified-parent-department)” 接口或 ”[按关键词搜索部门](/enterprise_query-department-by-keyword)“ 接口获取。  |
| `include_subtree`  | bool  | 否  | `true`  | 是否返回目标部门的所有后代部门的数据： | \
| | | | | | \
| | | | | * `true` 或省略：包含目标部门的所有后代部门的数据 | \
| | | | | * `false`：仅包含目标部门的数据 | \
| | | | | | \
| | | | | 该参数仅在传入 `department_id` 参数时生效。  |

## 响应参数 {#e7f7bf4b}

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

<!-- @cols-width: 308,117,471 -->
| **参数**  | **类型**  | **描述**  |
| --- | --- | --- |
| `total_active_users`  | int64  | 所有客户端去重后的活跃成员总数。如果同一成员在多个客户端上活跃，只会被计算一次。  |
| `ide_active_users`  | int64  | TraeCode 中的活跃成员数。  |
| `plugin_active_users`  | int64  | TraeCode Plugin 中的活跃成员数。  |
| `cli_active_users`  | int64  | TraeCode CLI 中的活跃成员数。  |
| `solo_desktop_code_active_users`  | int64  | TraeWork 桌面版 Code 模式中的活跃成员数。  |
| `solo_desktop_work_active_users`  | int64  | TraeWork 桌面版 Work 模式中的活跃成员数。  |
| `solo_web_code_active_users`  | int64  | TraeWork 网页版 Code 模式中的活跃成员数。  |
| `solo_web_work_active_users`  | int64  | TraeWork 网页版 Work 模式中的活跃成员数。  |

## 示例 {#示例}

### 请求示例 {#423bbfe2}

```Bash
curl -X GET "${HOST}/openapi/v1/statistics/active-users?start_date=2026-08-01&end_date=2026-08-15&department_id=20001&include_subtree=false" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}"
```

### 响应示例 {#47c6b5a3}

```JSON
{
  "code": 0,
  "message": "success",
  "request_id": "req_xxx",
  "data": {
    "total_active_users": 120,
    "ide_active_users": 100,
    "plugin_active_users": 30,
    "cli_active_users": 8,
    "solo_desktop_code_active_users": 5,
    "solo_desktop_work_active_users": 2,
    "solo_web_code_active_users": 3,
    "solo_web_work_active_users": 1
  }
}
```

## 错误码 {#错误码}

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