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

# Get the user ID list of a department

> Call this API to get the userId list of users in a specified department. This API is not restricted by the Contacts permission scope.

# 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](/open/development/user-management-acquires-the-list-departments) 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://api.dingtalk.io/topapi/user/listid](https://api.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](/open/development/obtain-orgapp-token). - 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](/open/development/user-management-acquires-the-list-departments) to get the deptId.  **Note**  For the root department, set this parameter to 1. |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/user/listid" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=03987655-598f-4f7a-8fc3-aaf257c47c27' \
-d 'dept_id=100'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/user/listid");
OapiUserListidRequest req = new OapiUserListidRequest();
req.setDeptId(100L);
OapiUserListidResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiUserListidRequest("https://api.dingtalk.io/topapi/user/listid")

req.dept_id=100
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiUserListidRequest;
$req->setDeptId("100");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/user/listid");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/user/listid");
OapiUserListidRequest req = new OapiUserListidRequest();
req.DeptId = 100L;
OapiUserListidResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

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

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "errmsg":"ok",
  "result": {
    "userid_list": [
      "usxxx",
      "manager4xxx",
      "10203029011xxxx",
      "usexxx"
    ]
  },
  "request_id": "3naksldjh0dk"
}
```

### Error codes

If an error occurs when you call this API, refer to the [Global error codes](/open/development/server-api-error-codes-1) 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.                      |
