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

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/extcontact/list
HTTP MethodPOST
Supported app typesappType-Internal appappType-Third-party enterprise app
Required permissionspermission-qyapi_ext_read-Read permission for external contacts

Query parameter

NameTypeRequiredExampleDescription
access_tokenStringYes6d1bxxxxThe 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. - For a third-party enterprise app, obtain it by calling the API for getting the access_token of a third-party enterprise.

Request body

NameTypeRequiredExampleDescription
sizeNumberNo20Supports paginated queries. This parameter takes effect only when set together with the offset parameter. It indicates the page size, with a maximum of 100.
offsetNumberNo0Supports paginated queries. This parameter takes effect only when set together with the size parameter. It indicates the offset, starting from 0.

Request example

curl -X POST "https://oapi.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
DingTalkClient client = new DefaultDingTalkClient("https://oapi.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
import dingtalk.api

req=dingtalk.api.OapiExtcontactListRequest("https://oapi.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
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://oapi.dingtalk.io/topapi/extcontact/list");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.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

NameTypeExampleDescription
resultsOpenExtContact[]The query result.
titleStringDevelopment EngineerThe job title.
share_dept_idsNumber[]1,2,3The list of shared department IDs.
label_idsNumber[]1,2,3The list of external contact tags.
remarkStringAlias contentThe alias.
addressStringAddress contentThe address.
nameStringZhang SanThe name.
follower_user_idString6767531692The userid of the owner.
state_codeString86The country code.
company_nameStringDingTalkThe company name.
share_user_idsString[]042059613752The list of userids of employees with whom the contact is shared.
mobileString13088888888The mobile phone number. Note This parameter is not returned for third-party enterprise apps.
useridString0123456789The userid of the external contact.
emailString1@1.comThe mail address.
errcodeNumber0The return code.
errmsgStringokThe description of the return code.
request_idString439eqp31da45The request ID.

Response body example

{
  "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 document based on the error message.
Error code (errcode)Error message (errmsg)Solution
33009Invalid tokenGrantTypeCheck whether the access_token is correct.
40069Invalid sizeAdjust the page size.
40068Invalid offsetAdjust the offset.
400001System errorTry again later.