Skip to main content
Call this API to get basic information about users in a specified department.

API call description

  • This API only returns the userId and name fields of users. To get detailed user information, see Get the complete information of a department user.
  • This API only returns basic information about users in the current department. Information about users in sub-departments is not returned.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/user/listsimple
HTTP MethodPOST
Supported app typesappType-Internal app appType-Third-party enterprise app
Permissionspermission-qyapi_get_department_member-Read permission for Contacts department users

Query parameter

NameTypeRequiredExampleDescription
access_tokenStringYesbE74xxxxThe app credential used to call this API. - For an internal app, obtain it through the API that gets the access_token of an internal app. - For a third-party enterprise app, obtain it through the API that gets the access_token of a third-party enterprise.

Request body

NameTypeRequiredExampleDescription
dept_idNumberYes10The department ID. For the root department, pass 1. Call Get the department list to get the value of dept_id.
cursorNumberYes0The cursor for pagination. Pass 0 for the first request, and pass the next_cursor value from the response in subsequent requests.
sizeNumberYes10The page size. The maximum value is 100.
order_fieldStringNomodify_descThe sorting rules for department users. The default value is custom. - entry_asc: sort by the time of joining the department in ascending order. - entry_desc: sort by the time of joining the department in descending order. - modify_asc: sort by the modified time of department information in ascending order. - modify_desc: sort by the modified time of department information in descending order. - custom: user-defined sorting (sorted by pinyin when not defined).
contain_access_limitBooleanNofalseWhether to return users with restricted access. - true: Yes - false: No
languageStringNozh_CNThe language of Contacts. - zh_CN: Chinese (default). - en_US: English.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/user/listsimple" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=c1f2d110-4e7c-4536-a340-06652613e0c1' \
-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/user/listsimple");
OapiUserListsimpleRequest req = new OapiUserListsimpleRequest();
req.setDeptId(10L);
req.setCursor(0L);
req.setSize(10L);
req.setOrderField("modify_desc");
req.setContainAccessLimit(false);
req.setLanguage("zh_CN");
OapiUserListsimpleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiUserListsimpleRequest("https://oapi.dingtalk.io/topapi/user/listsimple")

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 OapiUserListsimpleRequest;
$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/user/listsimple");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/user/listsimple");
OapiUserListsimpleRequest req = new OapiUserListsimpleRequest();
req.DeptId = 10L;
req.Cursor = 0L;
req.Size = 10L;
req.OrderField = "modify_desc";
req.Language = "zh_CN";
req.ContainAccessLimit = false;
req.Language = "zh_CN";
OapiUserListsimpleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
request_idString4f9md9obopn2The request ID.
errcodeNumber0The return code. 0 indicates success.
errmsgStringokThe description of the return code.
resultPageResultThe returned result.
has_moreBooleantrueWhether more data is available. - true: Yes - false: No
next_cursorNumber10The cursor for the next page. If has_more is false, no more paginated data is available.
listListUserSimpleResponse[]The user information list.
useridStringzxxxxxThe userid of the user.
nameStringZhang SanThe user name.

Response body example

{
  "errcode": 0,
  "errmsg": "ok",
  "result": {
    "has_more": false,
    "list": [
      {
        "name": "Test User 2",
        "userid": "user100"
      },
      {
        "name": "Li Si",
        "userid": "user1"
      }
    ]
  },
  "request_id": "x4p6arvi0fzj"
}

Error codes

If an error occurs when you call this API, find the solution in the Global error codes document based on the error message.
Error code (errcode)Error message (errmsg)Solution
400002Invalid parameterMake sure the parameters are filled in as required above.
60003The department is not foundMake sure the department ID is correct.
40069Invalid sizeAdjust the page size.
40068Invalid offsetAdjust the offset.
-1System busyTry again later.