Skip to main content
Call this API to get the details of employees in a specified department. Employees in sub-departments cannot be retrieved. This API is currently only available to organizations that have purchased and enabled Enterprise Account.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/v2/user/list
HTTP MethodPOST
Supported app typesappType-Internal app, appType-Third-party enterprise app
Permissions requiredpermission-qyapi_get_department_member-Contacts department member read permission

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYesbe3FxxxxThe 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

NameTypeRequiredExampleDescription
dept_idNumberYes10The department ID. Call the Get the department list API to obtain the value of dept_id. Note - Only employees in the current department are returned. Employees in sub-departments are not included. - For the root department, pass 1.
cursorNumberYes0The cursor for pagination. Pass 0 for the first call, then pass the value of next_cursor returned in subsequent calls.
sizeNumberYes10The page size.
order_fieldStringNomodify_descThe sorting rules for department members. If this parameter is not passed, results are sorted by custom order (custom) by default. - entry_asc: Sort by ascending order of the time joining the department. - entry_desc: Sort by descending order of the time joining the department. - modify_asc: Sort by ascending order of department information modification time. - modify_desc: Sort by descending order of department information modification time. - custom: Sort by user-defined order (by pinyin when undefined).
contain_access_limitBooleanNofalseWhether to return employees with access restrictions: - true: Return them. - false: Do not return them.
languageStringNozh_CNThe language for Contacts. - zh_CN: Chinese (default). - en_US: English.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/v2/user/list" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=8d4de2xxxx49c' \
-d 'contain_access_limit=false' \
-d 'cursor=0' \
-d 'dept_id=10' \
-d 'language=zh_CN' \
-d 'order_field=modify_desc' \
-d 'size=10'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/v2/user/list");
OapiV2UserListRequest req = new OapiV2UserListRequest();
req.setDeptId(10L);
req.setCursor(0L);
req.setSize(10L);
req.setOrderField("modify_desc");
req.setContainAccessLimit(false);
req.setLanguage("zh_CN");
OapiV2UserListResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiV2UserListRequest("https://oapi.dingtalk.io/topapi/v2/user/list")

req.dept_id=10
req.cursor=0
req.size=10
req.order_field="modify_desc"
req.contain_access_limit=false
req.language="zh_CN"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
PHP
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiV2UserListRequest;
$req->setDeptId("10");
$req->setCursor("0");
$req->setSize("10");
$req->setOrderField("modify_desc");
$req->setContainAccessLimit("false");
$req->setLanguage("zh_CN");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/v2/user/list");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/v2/user/list");
OapiV2UserListRequest req = new OapiV2UserListRequest();
req.DeptId = 10L;
req.Cursor = 0L;
req.Size = 10L;
req.OrderField = "modify_desc";
req.ContainAccessLimit = false;
req.Language = "zh_CN";
OapiV2UserListResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
errcodeNumber0The return code.
errmsgStringokThe description of the return code.
resultObjectThe returned result.
has_moreBooleantrueWhether more data is available: - true: Yes. - false: No.
next_cursorNumber10The cursor for the next pagination. Note If has_more is false, there is no more paginated data.
listObject[]The user information list.
useridStringzhangsanThe userId of the user.
unionidStringz21HjQliSzpw0YWCNxmii6u2Os62cZ62iSZThe unique identifier of the user within the current developer’s enterprise account scope.
nameStringJohnThe user name.
avatarStringxxxThe profile photo URL.
state_codeString86The international dialing code. Note - For an internal app, if this field is not returned, check whether the Permission to access employee mobile numbers is enabled in the current app’s Contacts permissions. - This parameter is not returned for third-party enterprise apps. To obtain state_code, use the DingTalk unified authorization suite.
mobileString13800138000The mobile number. Note - For an internal app, if this field is not returned, check whether the Permission to access employee mobile numbers is enabled in the current app’s Contacts permissions. - This parameter is not returned for third-party enterprise apps. To obtain mobile, use the DingTalk unified authorization suite.
hide_mobileBooleanfalseWhether the mobile number is hidden: - true: Hidden. After the mobile number is hidden, it is hidden on the Profile page, but DING messages and DingTalk business calls can still be sent to the number. - false: Not hidden.
telephoneString010-86123456-2345The extension number. Note This parameter is not returned for third-party enterprise apps.
job_numberString4The employee ID.
titleStringTechnical DirectorThe job title.
emailStringtest@xxx.comThe employee mail. Note - For an internal app, if this field is not returned, check whether the Mail and other profile permission is enabled in the current app’s Contacts permissions. - This field is returned only when the mail field has a value in the employee information panel. - This parameter is not returned for third-party enterprise apps.
org_emailStringtest@xxx.comThe Enterprise Mail of the employee. Note - For an internal app, if this field is not returned, check whether the Mail and other profile permission is enabled in the current app’s Contacts permissions. - This field is returned only when it has a value in the employee information panel. - This parameter is not returned for third-party enterprise apps.
work_placeStringFuture ParkThe Work Location. Note - For an internal app, if this field is not returned, check whether the Mail and other profile permission is enabled in the current app’s Contacts permissions. - This field is returned only when it has a value in the employee information panel. - This parameter is not returned for third-party enterprise apps.
remarkStringRemarksThe alias. Note - For an internal app, if this field is not returned, check whether the Mail and other profile permission is enabled in the current app’s Contacts permissions. - This field is returned only when it has a value in the employee information panel. - This parameter is not returned for third-party enterprise apps.
dept_id_listNumber[][2,3,4]The list of department IDs to which the employee belongs.
dept_orderNumber1The sort order of the employee within the department.
extensionString{"Hobby":"Travel","Age":"24"}The extended attributes. Note - For an internal app, if this field is not returned, check whether the Mail and other profile permission is enabled in the current app’s Contacts permissions. - This field is returned only when it has a value in the employee information panel. - This parameter is not returned for third-party enterprise apps.
hired_dateNumber1597573616828The hire date, as a Unix timestamp in milliseconds. Note This parameter is not returned for third-party enterprise apps.
activeBooleantrueWhether DingTalk has been activated: - true: Activated. - false: Not activated.
adminBooleantrueWhether the user is an admin of the organization: - true: Yes. - false: No.
bossBooleantrueWhether the user is the boss of the organization: - true: Yes. - false: No.
leaderBooleantrueWhether the user is the leader of the department: - true: Yes. - false: No.
exclusive_accountBooleantrueWhether the user is an Enterprise Account: - true: Yes. - false: No. Note This parameter is not returned for third-party enterprise apps.
login_idStringlogin_id3The sign-in name of the Enterprise Account in your organization. Note This field is returned only for DingTalk Enterprise Accounts that belong to your organization.
exclusive_account_typeStringdingtalkssoThe Enterprise Account type. - sso: Enterprise Account created by the organization. - dingtalk: Enterprise Account created by DingTalk. Note This field is returned only for Enterprise Accounts.
nicknameStringNameThe name of the Enterprise Account. Note This field is returned only for Enterprise Accounts created by your organization.
exclusive_account_corp_nameStringOrganization NameThe name of the organization to which the Enterprise Account belongs. Note Only applicable to Enterprise Accounts. Returns the name of the organization that created the Enterprise Account.
exclusive_account_corp_idStringcorpxxxThe organization ID of the organization to which the Enterprise Account belongs. Note Only applicable to Enterprise Accounts. Returns the organization ID of the organization that created the Enterprise Account.
disable_statusBooleantrueThe disabled status of the Enterprise Account in your organization: - true: Disabled. - false: Enabled. Note This field is returned only for DingTalk Enterprise Accounts that belong to your organization.

Response example

{
  "errcode":"0",
  "result":{
    "next_cursor":"10",
    "has_more":"true",
    "list":{
      "leader":"true",
      "exclusive_account_type":"dingtalk|sso",
      "extension":"{\"Hobby\":\"Travel\",\"Age\":\"24\"}",
      "unionid":"z21HjQliSzpw0YWCNxmii6u2Os62cZ62iSZ",
      "boss":"true",
      "exclusive_account":"true",
      "admin":"true",
      "remark":"Remarks",
      "title":"Technical Director",
      "hired_date":"1597573616828",
      "userid":"zhangsan",
      "work_place":"Future Park",
      "nickname":"Name",
      "dept_id_list":"[2,3,4]",
      "job_number":"4",
      "email":"test@xxx.com",
      "dept_order":"1",
      "login_id":"login_id3",
      "exclusive_account_corp_name":"Organization Name",
      "mobile":"13800138000",
      "active":"true",
      "telephone":"010-86123456-2345",
      "avatar":"xxx",
      "hide_mobile":"false",
      "exclusive_account_corp_id":"corpxxx",
      "org_email":"test@xxx.com",
      "name":"John",
      "state_code":"86"
    }
  },
  "errmsg":"ok"
}

Error codes

If an error is returned when calling this API, find a solution in the Global error codes document based on the error message.
Error code (errcode)Error message (errmsg)Solution
400002Invalid parameterCheck whether the parameter is filled in as required.
50004The department is not within the permission scopeMake sure the access_token has operation permissions.
40035Invalid parameterdept_id, cursor, size, or order_field is filled in incorrectly.
60019Failed to get users from the departmentMake sure the relevant parameters are filled in correctly.
-1System busyTry again later.