# 更新可搜可见规则

管理员视角更新可搜可见规则。用户需具备关联组织管理员权限。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/directory/v1/collaboration_rules/:collaboration_rule_id
HTTP Method | PUT
接口频率限制 | [100 次/分钟](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 变更关联组织协作规则(trust_party:collaboration_rule:write)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>或<br>`user_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

### 路径参数

名称 | 类型 | 描述
---|---|---
collaboration_rule_id | string | 规则ID，可通过[查询可搜可见规则](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collaboration_rule/list)获得<br>**示例值**："12121"

### 查询参数

名称 | 类型 | 必填 | 描述
---|---|---|---
target_tenant_key | string | 是 | 对方组织的tenant key，可通过[管理员获取所有关联组织列表](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collaboration_tenant/list)获取<br>**示例值**：test_key

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
subjects | collaboration_rule_entities | 是 | 实体数量之和需要小于100
open_user_ids | string\[\] | 否 | 用户 open id，可以使用通讯录/组织架构接口获取我方ID<br>**示例值**：["od-112121"]<br>**数据校验规则**：<br>- 长度范围：`0` ～ `100`
open_department_ids | string\[\] | 否 | 部门 open id，0代表全部成员。可以使用通讯录/组织架构接口获取我方ID<br>**示例值**：["od-12121212"]<br>**数据校验规则**：<br>- 长度范围：`0` ～ `100`
open_group_ids | string\[\] | 否 | 用户组 open id，可以使用通讯录/组织架构接口获取我方ID<br>**示例值**：["od-12121"]<br>**数据校验规则**：<br>- 长度范围：`0` ～ `100`
objects | collaboration_rule_entities | 是 | 实体数量之和需要小于100
open_user_ids | string\[\] | 否 | 用户 open id，可以使用[获取关联组织双方共享成员范围](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)和[获取关联组织的部门和成员信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/collaboration_tenant/visible_organization)来组合获取我方想要设置的关联组织部门/用户组和人员<br>**示例值**：["od-112121"]<br>**数据校验规则**：<br>- 长度范围：`0` ～ `100`
open_department_ids | string\[\] | 否 | 部门 open id，0代表全部成员；可以使用[获取关联组织双方共享成员范围](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)和[获取关联组织的部门和成员信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/collaboration_tenant/visible_organization)来组合获取我方想要设置的关联组织部门/用户组和人员<br>**示例值**：["od-12121212"]<br>**数据校验规则**：<br>- 长度范围：`0` ～ `100`
open_group_ids | string\[\] | 否 | 用户组 open id，可以使用[获取关联组织双方共享成员范围](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)和[获取关联组织的部门和成员信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/collaboration_tenant/visible_organization)来组合获取我方想要设置的关联组织部门/用户组和人员<br>**示例值**：["od-12121"]<br>**数据校验规则**：<br>- 长度范围：`0` ～ `100`

### 请求体示例
```json
{
    "subjects": {
        "open_user_ids": [
            "od-112121"
        ],
        "open_department_ids": [
            "od-12121212"
        ],
        "open_group_ids": [
            "od-12121"
        ]
    },
    "objects": {
        "open_user_ids": [
            "od-112121"
        ],
        "open_department_ids": [
            "od-12121212"
        ],
        "open_group_ids": [
            "od-12121"
        ]
    }
}
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 2223101 | This tenant has no  relationship with the other tenant | 请选择正确的关联组织
400 | 2223103 | The rule subject is not within the sharing scope | 请按照[获取关联组织双方共享成员范围](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)设置关联组织规则主体
400 | 2223104 | The rule object is not within the sharing scope | 请按照[获取关联组织双方共享成员范围](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)设置关联组织规则客体
400 | 2223106 | can't set empty entity in subject or object | 请给主客体设置有效的实体
400 | 2223108 | The update is too frequent. Please try again later | 操作过于频繁，请稍后再试
400 | 2223107 | The rule id is not exist | 请选择有效的rule id
400 | 2223110 | can't set other entity when department is 0 | 在部门设置为0的时候，勿设置其他实体
400 | 2224001 | No permission to operate | 无操作权限，请联系超管配置你为关联组织管理员

