Request
| Basic information | |
|---|---|
| HTTP URL | https://oapi.dingtalk.io/topapi/v2/department/listparentbydept |
| HTTP Method | POST |
| Supported app types | appType-Internal app, appType-Third-party enterprise app |
| Permissions required | permission-qyapi_get_department_list-Read permission for Contacts department information |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | bE74xxxx | The app credential used to call this API. - For an internal app, obtain it through the API for getting the access_token of an internal app. - For a third-party enterprise app, obtain it through the API for getting the access_token of a third-party enterprise. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| dept_id | Number | Yes | 42xxxx36 | The ID of the department to query. Call the Get department list API to obtain the value of dept_id. |
Request example
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| request_id | String | 10u9dj0853fwe | The request ID. |
| errcode | Number | 0 | The return code. |
| errmsg | String | Invalid department ID | The error message returned when the call failed. |
| result | DeptListParentByDeptIdResponse | The list of parent department IDs. | |
| parent_id_list | Number[] | [789, 456, 123, 1] | The list of IDs of all parent departments of the department. Note In the returned list, the first element is the ID of the current department, and the last element is the ID of the top-level parent department. The department tier increases from left to right. |
Response body example
Error codes
If an error is returned when you call this API, refer to the Global error codes document to find a solution based on the error message.| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 43007 | Authorization required | Make sure the access_token has the required permissions. |
| 60003 | Department not found | Make sure dept_id is correct. |
| 400002 | Invalid parameter | Make sure the parameters are entered as required. |
| -1 | System busy | Try again later. |