Skip to main content
Call this API to get the detailed information of an external contact in your organization.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/extcontact/get
HTTP MethodPOST
Supported app typesappType-Internal app, appType-Third-party enterprise app
Permissionspermission-qyapi_ext_read-Read permission for external contacts

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYesbE74xxxxThe 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
user_idStringYes112500xxxx4889The user ID of the external contact. Call the Get the external contact list API to get the value of the userid parameter.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/extcontact/get" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=53584xxxx2c50b' \
-d 'user_id=112500xxxx4889'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/extcontact/get");
OapiExtcontactGetRequest req = new OapiExtcontactGetRequest();
req.setUserId("112500xxxx4889");
OapiExtcontactGetResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiExtcontactGetRequest("https://oapi.dingtalk.io/topapi/extcontact/get")

req.user_id="112500xxxx4889"
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 OapiExtcontactGetRequest;
$req->setUserId("112500xxxx4889");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/extcontact/get");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/extcontact/get");
OapiExtcontactGetRequest req = new OapiExtcontactGetRequest();
req.UserId = "112500xxxx4889";
OapiExtcontactGetResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

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

Response example

{
  "errcode":0,
  "result":{
    "share_user_ids":[
      "66220007745510"
    ],
    "follower_user_id":"manager4220",
    "address":"Beijing",
    "share_dept_ids":[],
    "label_ids":[
      1561077317
    ],
    "share_dept_ids": [
      42xxxx36
    ],
    "mobile":"136***47616",
    "remark":"Technical Lead",
    "title":"CFO",
    "userid":"011250026469774889",
    "company_name":"DingTalk",
    "name":"Manager Wang",
    "state_code":"86",
    "email":"zhang@example.com"
  },
  "request_id":"xrudojam4g8f"
}

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.
33012Invalid userIdCheck whether the userId is correct.
43007Operation permission requiredCheck whether the access_token has the required operation permissions.
400001System errorTry again later.