# Modify the collaboration rules

Administrator updates the collaboration rules. Users need to have trusted party administrator role.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/directory/v1/collaboration_rules/:collaboration_rule_id
HTTP Method | PUT
Rate Limit | [100 per minute](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.** | Update collaboration rules for trusted party(trust_party:collaboration_rule:write)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>or<br>`user_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

### Path parameters

Parameter | Type | Description
---|---|---
collaboration_rule_id | string | rule ID<br>**Example value**: "12121"

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
target_tenant_key | string | Yes | The other tenant's tenant key<br>**Example value**: test_key

### Request body

Parameter | Type | Required | Description
---|---|---|---
subjects | collaboration_rule_entities | Yes | The sum of the number of entities needs to be less than 100.
open_user_ids | string\[\] | No | User open id<br>**Example value**: ["od-112121"]<br>**Data validation rules**:<br>- Length range: `0` ～ `100`
open_department_ids | string\[\] | No | Department open id, 0 represents all members<br>**Example value**: ["od-12121212"]<br>**Data validation rules**:<br>- Length range: `0` ～ `100`
open_group_ids | string\[\] | No | Group open id<br>**Example value**: ["od-12121"]<br>**Data validation rules**:<br>- Length range: `0` ～ `100`
objects | collaboration_rule_entities | Yes | The sum of the number of entities needs to be less than 100.
open_user_ids | string\[\] | No | User open id<br>**Example value**: ["od-112121"]<br>**Data validation rules**:<br>- Length range: `0` ～ `100`
open_department_ids | string\[\] | No | Department open id, 0 represents all members<br>**Example value**: ["od-12121212"]<br>**Data validation rules**:<br>- Length range: `0` ～ `100`
open_group_ids | string\[\] | No | Group open id<br>**Example value**: ["od-12121"]<br>**Data validation rules**:<br>- Length range: `0` ～ `100`

### Request body example
```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"
        ]
    }
}
```

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-

### Response body example
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
400 | 2223101 | This tenant has no  relationship with the other tenant | Please verity the relations between the parties.
400 | 2223103 | The rule subject is not within the sharing scope | Please set the collaboration rules body according to [Query the sharing members between the trust party relations](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)
400 | 2223104 | The rule object is not within the sharing scope | Please set the collaboration rules object according to [Query the sharing members between the trust party relations](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/directory-v1/collboration_share_entity/list)
400 | 2223106 | can't set empty entity in subject or object | Please set a valid entity for the subject and object
400 | 2223108 | The update is too frequent. Please try again later | Operation is too frequent, please try again later
400 | 2223107 | The rule id is not exist | Please select a valid rule id
400 | 2223110 | can't set other entity when department is 0 | When the department is set to 0, do not set other entities
400 | 2224001 | No permission to operate | No operation permission, please contact the super admin for the trust party admin role

