API call description
A department cannot be deleted in the following cases:- The root department (department ID 1) cannot be deleted.
- The department or its sub-departments still contain employees that have not been deleted.
Request
| Basic information | |
|---|---|
| HTTP URL | https://oapi.dingtalk.io/topapi/v2/department/delete |
| HTTP Method | POST |
| Supported app type | appType-Internal app |
| Required permissions | permission-qyapi_manage_addresslist-Contacts data management permission |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | bE74xxxx | The app credential used to call this API. Obtain it through the API for getting the access_token of an internal app. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| dept_id | Number | Yes | 100 | The ID of the department to delete. You can obtain the dept_id value through the Get department list API. |
Request example
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request_id | String | 6iq4zcul5zjp | The request ID. |
Response example
Error codes
If an error is returned when you call this API, look up the solution by the error message in the Global error codes document.| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 43007 | Authorization required | Confirm that the access_token has the required permissions. |
| 60003 | Department not found | Confirm that the dept_id is correct. |
| 400002 | Invalid parameter | Confirm that the parameters are entered as required. |
| -1 | System busy | Try again later. |