Get the user ID list of a department
API call description
- This API is not restricted by the Contacts permission scope.
-
Getting the user IDs of all employees in your organization at once is not supported. To get the user IDs of all employees in your organization, use the following method:
- Call the Get department list API and traverse level by level to get all department IDs within the authorized scope.
- Call the API described in this document to get the user IDs of employees in each department.
Request
| Basic information | |
|---|---|
| HTTP URL | https://oapi.dingtalk.io/topapi/user/listid |
| HTTP Method | POST |
| Supported app types | appType-Internal app, appType-Third-party enterprise app |
| Required permission | permission-qyapi_get_member-Read user information |
Query parameter
| 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 | 100 | The deptId of the department. You can call Get department list to get the deptId. Note For the root department, set this parameter to 1. |
Request example
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| request_id | String | 4f9kasjdhop | The request ID. |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| result | ListUserByDeptResponse | The response result. | |
| userid_list | String[] | [“zxxxx”,“lixxxi”] | The user ID list of the specified department. |
Response example
Error codes
If an error occurs 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 |
|---|---|---|
| 60003 | Department not found | Verify that dept_id is correct. |
| 400002 | Invalid parameter | Verify that the parameters are valid. |
| -1 | System busy | Try again later. |