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

按部门 ID 批量获取多个部门的信息。

## 所需权限 {#所需权限}

`departments:read`

## 请求说明 {#请求说明}

* 请求方式：`POST`
* 请求地址：`{域名}/openapi/v1/departments/batch-get`

## 注意事项 {#注意事项}

若在请求中传入重复的部门 ID，系统会自动去重，并仅在 `items` 中返回一次该部门的信息。

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

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

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

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

<!-- @cols-width: 143,112,100,100,434 -->
| **参数**  | **类型**  | **是否必填**  | **默认值**  | **描述**  |
| --- | --- | --- | --- | --- |
| `department_ids`  | string[]  | 是  | \-  | 部门 ID 列表。范围为 1 至 100 个。`"0"` 表示当前企业的根部门。 | \
| | | | | | \
| | | | | 部门 ID 可以通过 “[获取单个父部门的子部门](/enterprise_get-the-subdepartments-for-a-specified-parent-department)” 接口或 ”[按关键词搜索部门](/enterprise_query-department-by-keyword)“ 接口获取。  |

## 响应参数 {#响应参数}

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

<!-- @cols-width: 239,112,539 -->
| **参数**  | **类型**  | **描述**  |
| --- | --- | --- |
| `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。返回请求中传入的原始值。  |

## 示例 {#hwZOjtMND}

### 请求示例 {#请求示例}

```bash
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"
    ]
  }'
```

### 响应示例 {#响应示例}

```json
{
  "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"]
  }
}
```

## 错误码 {#错误与边界行为}

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