> ## 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 total number of employees

> Call this API to get the total number of employees in an organization, covering request parameters and the response structure.

Call this API to get the total number of employees.

## 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](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](/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                                                                                                                                                                                                   |
| ------------ | ------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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 theme={"theme":{"light":"github-light","dark":"github-dark"}}
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'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
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());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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)
```

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 OapiUserCountRequest;
$req->setOnlyActive("false");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/user/count");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
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

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
    "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](/open/development/server-api-error-codes-1) 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.                                                           |
