TRAE 企业版批量获取多个部门的信息
2026-12-02 18:36 更新
按部门 ID 批量获取多个部门的信息。
所需权限
departments:read
请求说明
- 请求方式:
POST - 请求地址:
{域名}/openapi/v1/departments/batch-get
注意事项
若在请求中传入重复的部门 ID,系统会自动去重,并仅在 items 中返回一次该部门的信息。
请求参数
请求头参数
| Header 参数 | 是否必填 | 描述 |
|---|---|---|
Authorization |
是 | 固定取值为 Bearer {access_token}。关于如何获取访问令牌,参考鉴权。 |
Content-Type |
是 | 固定取值为 application/json。 |
请求体参数
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
department_ids |
string[] | 是 | - | 部门 ID 列表。范围为 1 至 100 个。"0" 表示当前企业的根部门。部门 ID 可以通过 “获取单个父部门的子部门” 接口或 ”按关键词搜索部门“ 接口获取。 |
响应参数
该接口独有的响应参数如下,参数位于 data 中。通用响应参数参考此文档。
| 参数 | 类型 | 描述 |
|---|---|---|
items |
array | 查询到的部门列表。按请求中的部门 ID 顺序返回。 |
items[].department_id |
string | 部门 ID。 |
items[].parent_department_id |
string | 直属父部门的 ID。根部门为 "0"。 |
items[].name |
string | 部门名称。 |
items[].full_path |
string | 部门的完整归属路径。各级部门名称以 / 分隔。 |
items[].depth |
int | 部门的层级深度。根部门为 0。 |
not_found_department_ids |
string[] | 未找到或不属于当前企业的部门的 ID。返回请求中传入的原始值。 |
示例
请求示例
curl -X POST "${HOST}/openapi/v1/departments/batch-get"
-H "Authorization: Bearer ${ACCESS_TOKEN}"
-H "Content-Type: application/json"
-d '{
"department_ids": [
"0",
"20001",
"99999"
]
}'
响应示例
{
"code": 0,
"message": "success",
"request_id": "req_xxx",
"data": {
"items": [
{
"department_id": "90001",
"parent_department_id": "0",
"name": "示例企业",
"full_path": "示例企业",
"depth": 0
},
{
"department_id": "20001",
"parent_department_id": "90001",
"name": "研发一部",
"full_path": "示例企业/研发一部",
"depth": 1
}
],
"not_found_department_ids": ["99999"]
}
}
错误码
若该接口的请求返回错误码,参考错误码文档进行排查。
编程狮笔记
按部门 ID 批量获取多个部门的信息。
- 请求地址:{域名}/openapi/v1/departments/batch-get…
- 若在请求中传入重复的部门 ID,系统会自动去重,并仅在 items 中返回一次该部门的信息。
- 该接口独有的响应参数如下,参数位于 data 中。通用响应参数参考此文档。
想直接上手体验 TRAE:TRAE 官网
以上内容是否对您有帮助:



更多建议: