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

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/extcontact/delete
HTTP MethodPOST
Supported app typesappType-Internal app
Required permissionspermission-qyapi_ext_write-Write permission for external contacts of the organization

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
user_idStringYes0125xxxx0251487The userId of the external contact to delete. Call the Get the list of external contacts API to obtain the value of the userid parameter.

Request example

curl -X POST "https://oapi.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
DingTalkClient client = new DefaultDingTalkClient("https://oapi.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
import dingtalk.api

req=dingtalk.api.OapiExtcontactDeleteRequest("https://oapi.dingtalk.io/topapi/extcontact/delete")

req.user_id="0125xxxx0251487"
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 OapiExtcontactDeleteRequest;
$req->setUserId("0125xxxx0251487");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/extcontact/delete");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.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

NameTypeExampleDescription
errcodeNumber0The return code.
request_idString439eqp31da45The request ID.

Response body example

{
  "errcode":0,
  "request_id": "439eqp31da45"
}

Error codes

If an error occurs when calling this API, refer to the Global error codes document to find a solution based on the error message.
Error code (errcode)Error message (errmsg)Solution
33009Invalid tokenGrantTypeCheck whether the access_token is correct.
33012Invalid userIdCheck whether the userId is correct.
43007Operation permission is requiredCheck whether the access_token has the required operation permissions.
400001System errorTry again later.