Skip to main content
Call this API to update an external contact of your organization.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/extcontact/update
HTTP MethodPOST
Supported app typesappType-Internal app
Permissions requiredpermission-qyapi_ext_write-Write permission for external contacts

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYes6d1bxxxxThe app credential used to call this API. Obtain it through the API for getting the access_token of an internal app.

Request body

NameTypeRequiredExampleDescription
contactOpenExtContactYesThe external contact information.
titleStringNoDevelopment EngineerThe job title.
label_idsNumber[]Yes[1,2,3]The tag list. Call the Get the external contact list API to query tag information. Refer to How to customize tag groups for an organization to add custom tags. A maximum of 20 labelIds can be passed per call.
share_dept_idsNumber[]No[420606536]The IDs of departments to share with. Call the Get the sub-department ID list API to obtain them. A maximum of 20 department IDs can be passed per call.
addressStringNoBeijingThe address.
remarkStringNoTechnical LeadThe alias.
follower_user_idStringYes023420013645The userId of the owner.
nameStringYesZhang xxThe name of the external contact.
user_idStringYes123420013632The userId of the external contact. Call the Get the external contact list API to obtain it.
company_nameStringNoDingTalkThe organization name of the external contact.
share_user_idsString[]No[“023420013644”]The list of userids of employees to share with. A maximum of 20 labelIds can be passed per call.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/extcontact/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=34ddexxxx6c95' \
-d 'contact=null'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/extcontact/update");
OapiExtcontactUpdateRequest req = new OapiExtcontactUpdateRequest();
OapiExtcontactUpdateRequest.OpenExtContact contact = new OapiExtcontactUpdateRequest.OpenExtContact();
contact.setTitle("Development Engineer");
contact.setLabelIds(Arrays.asList(1L,2L,3L));
contact.setShareDeptIds(Arrays.asList(420606536
L));
contact.setAddress("Beijing");
contact.setRemark("Technical Lead");
contact.setFollowerUserId("023420013645");
contact.setName("Zhang xx");
contact.setUserId("123420013632");
contact.setCompanyName("DingTalk");
contact.setShareUserIds(Arrays.asList("user123"));
req.setContact(contact);
OapiExtcontactUpdateResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiExtcontactUpdateRequest("https://oapi.dingtalk.io/topapi/extcontact/update")

req.contact=""
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 OapiExtcontactUpdateRequest;
$contact = new OpenExtContact;
$contact->title="Development Engineer";
$contact->label_ids="[1,2,3]";
$contact->share_dept_ids="[1,2,3]";
$contact->address="Address details";
$contact->remark="Remark details";
$contact->follower_user_id="023420013645";
$contact->name="John";
$contact->user_id="123420013632";
$contact->company_name="DingTalk";
$contact->share_user_ids="[\"023420013644\"]";
$req->setContact($contact);
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/extcontact/update");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/extcontact/update");
OapiExtcontactUpdateRequest req = new OapiExtcontactUpdateRequest();
OapiExtcontactUpdateRequest.OpenExtContactDomain obj1 = new OapiExtcontactUpdateRequest.OpenExtContactDomain();
obj1.Title = "Development Engineer";
obj1.LabelIds = new long[] { 1,2,3 };
obj1.ShareDeptIds = new long[] { 1,2,3 };
obj1.Address = "Address details";
obj1.Remark = "Remark details";
obj1.FollowerUserId = "023420013645";
obj1.Name = "John";
obj1.UserId = "123420013632";
obj1.CompanyName = "DingTalk";
obj1.ShareUserIds = ""023420013644"";
req.Contact_ = obj1;
OapiExtcontactUpdateResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
errcodeNumber0The return code.
request_idString8n3mksu5hqzyThe request ID.

Response body example

{
  "errcode":0,
  "request_id": "8n3mksu5hqzy""
}

Error codes

If an error occurs when you call this API, look up a 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.
40036Empty parameterCheck whether all required parameters are filled in.
40003Invalid userIdCheck whether the userId is correct.
60112Invalid user nameCheck whether the user name is correct.
60121The corresponding user is not foundCheck whether the user information is correct.
60204A label is required for the external contactFill in the label_ids for the external contact.
43007Permission requiredCheck whether the access_token has the permission to perform this operation.
60103Invalid mobile numberCheck whether the mobile number is correct.
60200The external contact already existsCheck whether the external contact information is correct.
60203The number of external contacts exceeds the limitRemove some external contacts.
-1System busyTry again later.