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

# Delete an external contact

> Call this API to delete an external contact of the enterprise, with request parameters and response fields.

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

## Request

| **Basic information** |                                                                                                      |
| --------------------- | ---------------------------------------------------------------------------------------------------- |
| HTTP URL              | [https://api.dingtalk.io/topapi/extcontact/delete](https://api.dingtalk.io/topapi/extcontact/delete) |
| HTTP Method           | POST                                                                                                 |
| Supported app types   | appType-Internal app                                                                                 |
| Required permissions  | permission-qyapi\_ext\_write-Write permission for external contacts of the organization              |

### 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                                                                                                                                                                                     |
| -------- | ------ | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user\_id | String | Yes      | 0125xxxx0251487 | The userId of the external contact to delete. Call the [Get the list of external contacts](/open/development/obtain-the-external-contact-list) API to obtain the value of the userid parameter. |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/extcontact/delete" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=22c945xxxx509f1' \
-d 'user_id=0125xxxx0251487'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/extcontact/delete");
OapiExtcontactDeleteRequest req = new OapiExtcontactDeleteRequest();
req.setUserId("0125xxxx0251487");
OapiExtcontactDeleteResponse 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.OapiExtcontactDeleteRequest("https://api.dingtalk.io/topapi/extcontact/delete")

req.user_id="0125xxxx0251487"
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 OapiExtcontactDeleteRequest;
$req->setUserId("0125xxxx0251487");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/extcontact/delete");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/extcontact/delete");
OapiExtcontactDeleteRequest req = new OapiExtcontactDeleteRequest();
req.UserId = "0125xxxx0251487";
OapiExtcontactDeleteResponse 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 | 439eqp31da45 | The request ID.  |

### Response body example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "request_id": "439eqp31da45"
}
```

### Error codes

If an error occurs when calling this API, refer to the [Global error codes](/open/development/server-api-error-codes-1) document to find a solution based on the error message.

| Error code (errcode) | Error message (errmsg)           | Solution                                                                |
| -------------------- | -------------------------------- | ----------------------------------------------------------------------- |
| 33009                | Invalid tokenGrantType           | Check whether the access\_token is correct.                             |
| 33012                | Invalid userId                   | Check whether the userId is correct.                                    |
| 43007                | Operation permission is required | Check whether the access\_token has the required operation permissions. |
| 400001               | System error                     | Try again later.                                                        |
