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

批量删除部门。

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

`departments:write`

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

* 请求方式：`DELETE`
* 请求地址：`{域名}/openapi/v1/departments`

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


* 单次请求最多传入 100 个部门 ID。重复的部门 ID 会自动去重。
* 仅可删除没有子部门且没有直属成员的部门。
* 根部门无法删除。

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

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

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

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

<!-- @cols-width: 183,125,120,459 -->
| **参数**  | **类型**  | **是否必填**  | **描述**  |
| --- | --- | --- | --- |
| `department_ids`  | array  | 是  | 待删除的部门的 ID 列表。范围为 1 至 100 个。 | \
| | | | | \
| | | | 部门 ID 可以通过 “[获取单个父部门的子部门](/enterprise_get-the-subdepartments-for-a-specified-parent-department)” 接口或 ”[按关键词搜索部门](/enterprise_query-department-by-keyword)“ 接口获取。  |

## 响应参数 {#hZNcsfOqD}

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

<!-- @cols-width: 117,100,679 -->
| **参数**  | **类型**  | **描述**  |
| --- | --- | --- |
| `success`  | bool  | 是否删除成功。成功时为 `true`，失败时为 `false`。  |

## 示例 {#示例}

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

```Bash
curl -X DELETE "${HOST}/openapi/v1/departments" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "department_ids": [
      "10001",
      "10002"
    ]
  }'
```

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

```JSON
{
  "code": 0,
  "message": "success",
  "request_id": "req_xxx",
  "data": {
    "success": true
  }
}
```

## 错误码 {#错误码}

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