API call description
This API is not restricted by the Contacts permission scope.Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/user/count |
| HTTP Method | POST |
| Supported app types | appType-Internal app, appType-Third-party enterprise app |
| Required permissions | permission-qyapi_get_member-Read permission for 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 |
|---|---|---|---|---|
| only_active | Boolean | Yes | false | Whether to include the number of employees who have not activated DingTalk: - false: Include employees who have not activated DingTalk. - true: Only include employees who have activated DingTalk. |
Request example
curl -X POST "https://api.dingtalk.io/topapi/user/count" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=7a1bee78-57cb-4a05-9316-0341b1ca303f' \
-d 'only_active=false'
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/user/count");
OapiUserCountRequest req = new OapiUserCountRequest();
req.setOnlyActive(false);
OapiUserCountResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
import dingtalk.api
req=dingtalk.api.OapiUserCountRequest("https://api.dingtalk.io/topapi/user/count")
req.only_active=false
try:
resp= req.getResponse(access_token)
print(resp)
except Exception,e:
print(e)
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiUserCountRequest;
$req->setOnlyActive("false");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/user/count");
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/user/count");
OapiUserCountRequest req = new OapiUserCountRequest();
req.OnlyActive = false;
OapiUserCountResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| request_id | String | o38h5bztjouc | The request ID. |
| errcode | Number | 0 | The status code. 0 indicates that the call succeeded. |
| errmsg | String | Invalid access_token | The error message returned when the call failed. |
| result | CountUserResponse | The returned result. | |
| count | Number | 4 | The number of employees. |
Response body example
{
"errcode": 0,
"errmsg":"ok",
"result": {
"count": 4
},
"request_id": "40k5v0mgbzyh"
}
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 |
|---|---|---|
| 400002 | Parameter is empty | Make sure all required parameters are provided. |
| 40035 | Invalid parameter | Make sure the parameters meet the requirements in the documentation above. |
| -1 | System busy | Try again later. |