Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/extcontact/update |
| HTTP Method | POST |
| Supported app types | appType-Internal app |
| Permissions required | permission-qyapi_ext_write-Write permission for external contacts |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | 6d1bxxxx | The app credential used to call this API. Obtain it through the API for getting the access_token of an internal app. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| contact | OpenExtContact | Yes | The external contact information. | |
| title | String | No | Development Engineer | The job title. |
| label_ids | Number[] | 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_ids | Number[] | 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. |
| address | String | No | Beijing | The address. |
| remark | String | No | Technical Lead | The alias. |
| follower_user_id | String | Yes | 023420013645 | The userId of the owner. |
| name | String | Yes | Zhang xx | The name of the external contact. |
| user_id | String | Yes | 123420013632 | The userId of the external contact. Call the Get the external contact list API to obtain it. |
| company_name | String | No | DingTalk | The organization name of the external contact. |
| share_user_ids | String[] | 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://api.dingtalk.io/topapi/extcontact/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=34ddexxxx6c95' \
-d 'contact=null'
DingTalkClient client = new DefaultDingTalkClient("https://api.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());
import dingtalk.api
req=dingtalk.api.OapiExtcontactUpdateRequest("https://api.dingtalk.io/topapi/extcontact/update")
req.contact=""
try:
resp= req.getResponse(access_token)
print(resp)
except Exception,e:
print(e)
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://api.dingtalk.io/topapi/extcontact/update");
IDingTalkClient client = new DefaultDingTalkClient("https://api.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
| Name | Type | Example | Description |
|---|---|---|---|
| errcode | Number | 0 | The return code. |
| request_id | String | 8n3mksu5hqzy | The 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 |
|---|---|---|
| 33009 | Invalid tokenGrantType | Check whether the access_token is correct. |
| 40036 | Empty parameter | Check whether all required parameters are filled in. |
| 40003 | Invalid userId | Check whether the userId is correct. |
| 60112 | Invalid user name | Check whether the user name is correct. |
| 60121 | The corresponding user is not found | Check whether the user information is correct. |
| 60204 | A label is required for the external contact | Fill in the label_ids for the external contact. |
| 43007 | Permission required | Check whether the access_token has the permission to perform this operation. |
| 60103 | Invalid mobile number | Check whether the mobile number is correct. |
| 60200 | The external contact already exists | Check whether the external contact information is correct. |
| 60203 | The number of external contacts exceeds the limit | Remove some external contacts. |
| -1 | System busy | Try again later. |