> ## 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.

# Update an external contact

> Call this API to update an external contact of an organization. Documents the request parameters and response structure.

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

## Request

| **Basic information** |                                                                                                      |
| --------------------- | ---------------------------------------------------------------------------------------------------- |
| HTTP URL              | [https://api.dingtalk.io/topapi/extcontact/update](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](/open/development/obtain-orgapp-token). |

### 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](/open/development/obtain-the-external-contact-list) API to query tag information.  Refer to [How to customize tag groups for an organization](https://tms.dingtalk.io/markets/dingtalk/biaoqianzu) 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](/open/development/obtain-the-list-of-sub-department-ids) 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](/open/development/obtain-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 theme={"theme":{"light":"github-light","dark":"github-dark"}}
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'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
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());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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)
```

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 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");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
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

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "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](/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.                                   |
| 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.                                                              |
