> ## 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 external contact list

> Call this API to get the external contact list of an organization for reviewing externally maintained contacts.

Call this API to get the external contact list of an organization.

## Request

| **Basic information** |                                                                                                  |
| --------------------- | ------------------------------------------------------------------------------------------------ |
| HTTP URL              | [https://api.dingtalk.io/topapi/extcontact/list](https://api.dingtalk.io/topapi/extcontact/list) |
| HTTP Method           | POST                                                                                             |
| Supported app types   | appType-Internal appappType-Third-party enterprise app                                           |
| Required permissions  | permission-qyapi\_ext\_read-Read permission for external contacts                                |

### Query parameter

| Name          | Type   | Required | Example  | Description                                                                                                                                                                                                                                                                                                            |
| ------------- | ------ | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | 6d1bxxxx | The app credential used to call this API.   - For an internal app, obtain it by calling the API for getting the [access\_token of an internal app](/open/development/obtain-orgapp-token). - For a third-party enterprise app, obtain it by calling the API for getting the access\_token of a third-party enterprise. |

### Request body

| Name   | Type   | Required | Example | Description                                                                                                                                                  |
| ------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| size   | Number | No       | 20      | Supports paginated queries. This parameter takes effect only when set together with the offset parameter. It indicates the page size, with a maximum of 100. |
| offset | Number | No       | 0       | Supports paginated queries. This parameter takes effect only when set together with the size parameter. It indicates the offset, starting from 0.            |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/extcontact/list" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=b5039xxxx8bcc' \
-d 'offset=0' \
-d 'size=20'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/extcontact/list");
OapiExtcontactListRequest req = new OapiExtcontactListRequest();
req.setSize(20L);
req.setOffset(0L);
OapiExtcontactListResponse 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.OapiExtcontactListRequest("https://api.dingtalk.io/topapi/extcontact/list")

req.offset=0
req.size=20
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 OapiExtcontactListRequest;
$req->setOffset("0");
$req->setSize("20");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/extcontact/list");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/extcontact/list");
OapiExtcontactListRequest req = new OapiExtcontactListRequest();
req.Offset = 0L;
req.Size = 20L;
OapiExtcontactListResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response body

| Name               | Type              | Example                   | Description                                                                                         |
| ------------------ | ----------------- | ------------------------- | --------------------------------------------------------------------------------------------------- |
| results            | OpenExtContact\[] |                           | The query result.                                                                                   |
| title              | String            | Development Engineer      | The job title.                                                                                      |
| share\_dept\_ids   | Number\[]         | 1,2,3                     | The list of shared department IDs.                                                                  |
| label\_ids         | Number\[]         | 1,2,3                     | The list of external contact tags.                                                                  |
| remark             | String            | Alias content             | The alias.                                                                                          |
| address            | String            | Address content           | The address.                                                                                        |
| name               | String            | Zhang San                 | The name.                                                                                           |
| follower\_user\_id | String            | 6767531692                | The userid of the owner.                                                                            |
| state\_code        | String            | 86                        | The country code.                                                                                   |
| company\_name      | String            | DingTalk                  | The company name.                                                                                   |
| share\_user\_ids   | String\[]         | 042059613752              | The list of userids of employees with whom the contact is shared.                                   |
| mobile             | String            | 13088888888               | The mobile phone number.  **Note**  This parameter is not returned for third-party enterprise apps. |
| userid             | String            | 0123456789                | The userid of the external contact.                                                                 |
| email              | String            | [1@1.com](mailto:1@1.com) | The mail address.                                                                                   |
| errcode            | Number            | 0                         | The return code.                                                                                    |
| errmsg             | String            | ok                        | The description of the return code.                                                                 |
| request\_id        | String            | 439eqp31da45              | The request ID.                                                                                     |

### Response body example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "results": [
    {
      "address": "Beijing",
      "company_name": "DingTalk",
      "email": "zhang@example.com",
      "follower_user_id": "manager4220",
      "label_ids": [
        1517
      ],
      "mobile": "1360054xxxx",
      "name": "Manager Wang",
      "remark": "Technical Lead",
      "share_dept_ids": [
        42536
      ],
      "share_user_ids": [
        "0423752"
      ],
      "state_code": "86",
      "title": "CFO",
      "userid": "01129774889"
    }
  ],
  "request_id": "439eqp31da45"
}
```

### Error codes

If an error is returned when you call this API, find the solution in the [Global error codes](/open/development/server-api-error-codes-1) document based on the error message.

| Error code (errcode) | Error message (errmsg) | Solution                                    |
| -------------------- | ---------------------- | ------------------------------------------- |
| 33009                | Invalid tokenGrantType | Check whether the access\_token is correct. |
| 40069                | Invalid size           | Adjust the page size.                       |
| 40068                | Invalid offset         | Adjust the offset.                          |
| 400001               | System error           | Try again later.                            |
