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

# Turn off Private Chat for group members

> Call this API to control whether group members can add each other as friends and chat privately, useful for internal groups that need to limit communication and protect information.

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 URL              | [https://api.dingtalk.io/topapi/chat/member/friendswitch/update](https://api.dingtalk.io/topapi/chat/member/friendswitch/update) |
| HTTP Method           | POST                                                                                                                             |
| Supported app types   | appType-Internal app                                                                                                             |
| Required permissions  | permission-qyapi\_chat\_manage-DingTalk group basic information management permission                                            |

### Query parameters

| Name          | Type   | Required | Example  | Description                                                                                                          |
| ------------- | ------ | -------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | 6d1bxxxx | The App credential for calling this API. Obtain it through the API for getting the access\_token of an Internal app. |

### Request body

| Name         | Type    | Required | Example         | Description                                                                                                                                                                                                                                                |
| ------------ | ------- | -------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chatid       | String  | Yes      | chatdafe234xxxx | The 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\_prohibit | Boolean | Yes      | true            | Whether to turn on the restriction switch.   - **true**: Turn on the restriction switch. - **false**: Turn off the restriction switch.                                                                                                                     |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.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

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.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

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiChatMemberFriendswitchUpdateRequest("https://api.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

```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 OapiChatMemberFriendswitchUpdateRequest;
$req->setChatid("chatdafe234sdf3sdf");
$req->setIsProhibit("true");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/chat/member/friendswitch/update");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.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

| Name        | Type    | Example       | Description                                                                          |
| ----------- | ------- | ------------- | ------------------------------------------------------------------------------------ |
| success     | Boolean | true          | Whether the configuration is successful.   - **true**: Success. - **false**: Failed. |
| errcode     | Number  | 0             | The return code.                                                                     |
| errmsg      | String  | ok            | The description of the return code.                                                  |
| request\_id | String  | 10c0wc48i6qzz | The request ID.                                                                      |

### Response example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "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](/open/development/server-api-error-codes-1) documentation for solutions.

| Error code (errorcode) | Error message (errmsg) | Solution                                                 |
| ---------------------- | ---------------------- | -------------------------------------------------------- |
| 34001                  | Invalid chatid         | Check whether the chatid meets the requirements.         |
| 40036                  | Empty parameter        | Confirm that all required parameters have been provided. |
| 400001                 | system error           | Try again later.                                         |
