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

# Menghapus kontak eksternal

> Panggil API ini untuk menghapus kontak eksternal organisasi di DingTalk — lengkap dengan parameter permintaan dan bidang respons untuk integrasi Server API.

Panggil API ini untuk menghapus kontak eksternal organisasi Anda.

## Permintaan

| **Informasi dasar**         |                                                                                                      |
| --------------------------- | ---------------------------------------------------------------------------------------------------- |
| URL HTTP                    | [https://api.dingtalk.io/topapi/extcontact/delete](https://api.dingtalk.io/topapi/extcontact/delete) |
| Metode HTTP                 | POST                                                                                                 |
| Tipe aplikasi yang didukung | appType-Aplikasi internal                                                                            |
| Izin yang diperlukan        | permission-qyapi\_ext\_write-Izin tulis untuk kontak eksternal organisasi                            |

### Parameter query

| Nama          | Tipe   | Wajib | Contoh   | Deskripsi                                                                                                                                                                           |
| ------------- | ------ | ----- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Ya    | 6d1bxxxx | Kredensial aplikasi yang digunakan untuk memanggil API ini. Dapatkan melalui API untuk memperoleh [access\_token dari aplikasi internal](/id/open/development/obtain-orgapp-token). |

### Isi permintaan

| Nama     | Tipe   | Wajib | Contoh          | Deskripsi                                                                                                                                                                                        |
| -------- | ------ | ----- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| user\_id | String | Ya    | 0125xxxx0251487 | userId dari kontak eksternal yang akan dihapus. Panggil API [Memperoleh daftar kontak eksternal](/id/open/development/obtain-the-external-contact-list) untuk memperoleh nilai parameter userid. |

### Contoh permintaan

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

## Respons

### Isi respons

| Nama        | Tipe   | Contoh       | Deskripsi          |
| ----------- | ------ | ------------ | ------------------ |
| errcode     | Number | 0            | Kode pengembalian. |
| request\_id | String | 439eqp31da45 | ID permintaan.     |

### Contoh isi respons

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

### Kode error

Jika terjadi error saat memanggil API ini, lihat dokumen [Kode error global](/id/open/development/server-api-error-codes-1) untuk menemukan solusi berdasarkan pesan error.

| Kode error (errcode) | Pesan error (errmsg)             | Solusi                                                              |
| -------------------- | -------------------------------- | ------------------------------------------------------------------- |
| 33009                | Invalid tokenGrantType           | Periksa apakah access\_token sudah benar.                           |
| 33012                | Invalid userId                   | Periksa apakah userId sudah benar.                                  |
| 43007                | Operation permission is required | Periksa apakah access\_token memiliki izin operasi yang diperlukan. |
| 400001               | System error                     | Coba lagi nanti.                                                    |
