Skip to main content
Call this API to control whether group members can add each other as contacts and start private chats. It applies to scenarios where an Internal Group needs to restrict communication between members or protect information security.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/chat/member/friendswitch/update
HTTP MethodPOST
Supported app typesappType-Internal app
Required permissionspermission-qyapi_chat_manage-DingTalk group basic information management permission

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYes6d1bxxxxThe App credential for calling this API. Obtain it through the API for getting the access_token of an Internal app.

Request body

NameTypeRequiredExampleDescription
chatidStringYeschatdafe234xxxxThe Chat ID of the organization. Obtain it in one of the following ways: - Call the Server-side API for creating a group to obtain the value of the chatid parameter. - Call the Client-side chooseChat API to obtain the value of the chatId parameter.
is_prohibitBooleanYestrueWhether to turn on the restriction switch. - true: Turn on the restriction switch. - false: Turn off the restriction switch.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=774fdexxxx4bdd68c' \
-d 'chatid=chatdafe234sdf3sdf' \
-d 'is_prohibit=true'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update");
OapiChatMemberFriendswitchUpdateRequest req = new OapiChatMemberFriendswitchUpdateRequest();
req.setChatid("chatdafe234xxxx");
req.setIsProhibit(true);
OapiChatMemberFriendswitchUpdateResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiChatMemberFriendswitchUpdateRequest("https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update")

req.chatid="chatdafe234sdf3sdf"
req.is_prohibit=true
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 OapiChatMemberFriendswitchUpdateRequest;
$req->setChatid("chatdafe234sdf3sdf");
$req->setIsProhibit("true");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/chat/member/friendswitch/update");
OapiChatMemberFriendswitchUpdateRequest req = new OapiChatMemberFriendswitchUpdateRequest();
req.Chatid = "chatdafe234sdf3sdf";
req.IsProhibit = true;
OapiChatMemberFriendswitchUpdateResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
successBooleantrueWhether the configuration is successful. - true: Success. - false: Failed.
errcodeNumber0The return code.
errmsgStringokThe description of the return code.
request_idString10c0wc48i6qzzThe request ID.

Response example

{
  "success":true,
  "errcode":0,
  "errmsg":"ok",
  "request_id":"10c0wc48i6qzz"
}

Error codes

If an error is returned when you call this API, refer to the Global error codes documentation for solutions.
Error code (errorcode)Error message (errmsg)Solution
34001Invalid chatidCheck whether the chatid meets the requirements.
40036Empty parameterConfirm that all required parameters have been provided.
400001system errorTry again later.