# Update common settings of a document

This API is used to update the common settings of a document based on a filetoken.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/drive/v1/permissions/:token/public
HTTP Method | PATCH
Rate Limit | [100 per minute](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App、Store App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.**<br>Enable any scope from the list | View, edit, and manage Wiki(wiki:wiki)<br>View, comment, edit, and manage Docs(docs:doc)<br>Modify permission settings of document(docs:permission.setting:write_only)<br>View, comment, edit, and manage all files in My Space(drive:drive)<br>Upload and download files to My Space(drive:file)<br>View, comment, edit, and manage Sheets(sheets:spreadsheet)<br>View, comment, edit, and manage Base (In Suite)(bitable:bitable)

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

For more information about how to call the AccessToken in the Docs API, see [Get started with the Docs API](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN).

### Path parameters

Parameter | Type | Description
---|---|---
token | string | Token of the file. For more information about how to obtain the token, see [How to get the token of docs resources](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#036e0b0f).<br>**Example value**: "doccnBKgoMyY5OMbUG6FioTXuBe"

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
type | string | Yes | File type, which needs to match the token of the file<br>**Example value**: doc<br>**Optional values are**:<br>- doc：Doc<br>- sheet：Sheet<br>- file：File in My Space<br>- wiki：Wiki node<br>- bitable：Bitable<br>- docx：Upgraded Docs<br>- mindnote：Mindnote<br>- minutes：Minutes<br>- slides：slides

**Note** `wiki`: Wiki node. The following settings are not supported:
- `external_access`: Specifies whether sharing out of the tenant is allowed.
- `share_entity`: Specifies who can add and manage collaborators.
- `invite_external`: Specifies whether users without full access and non-owners are allowed to invite external participants.
- `link_share_entity`: Settings of link sharing.
  - `tenant_readable`: All users who obtain the link can read the document.
  - `tenant_editable`: All users who obtain the link can edit the document.

### Request body

Parameter | Type | Required | Description
---|---|---|---
external_access | boolean | No | Indicates whether sharing out of the tenant is allowed.<br>**Example value**: true
security_entity | string | No | Settings of the permission to make a copy of, print, export, and copy the document.<br>**Example value**: "anyone_can_view"<br>**Optional values are**:<br>- anyone_can_view：All users who can access this document.<br>- anyone_can_edit：Users with the edit permission.<br>- only_full_access：Users with manageable privileges (including me)
comment_entity | string | No | Settings of the permission to comment on the document.<br>**Example value**: "anyone_can_view"<br>**Optional values are**:<br>- anyone_can_view：All users who can access this document.<br>- anyone_can_edit：Users with the edit permission.
share_entity | string | No | Indicates who can add and manage collaborators.<br>**Example value**: "anyone"<br>**Optional values are**:<br>- anyone：All users who can read or edit this document.<br>- same_tenant：All users who can read or edit this document in the organization.<br>- only_full_access：Only users with full access.
link_share_entity | string | No | Link sharing<br>**Example value**: "tenant_readable"<br>**Optional values are**:<br>- tenant_readable：Users who obtain the link in the organization can read the document.<br>- tenant_editable：Users who obtain the link in the organization can edit the document.<br>- anyone_readable：All users who obtain the link can read the document. (This option is valid only when `external_access`)<br>- anyone_editable：All users who obtain the link can edit the document.  (This option is valid only when `external_access`)<br>- closed：Closed share link.
invite_external | boolean | No | Specifies whether users without full access and non-owners are allowed to invite external participants.<br>**Example value**: true

### Request body example
```json
{
    "external_access": true,
    "security_entity": "anyone_can_view",
    "comment_entity": "anyone_can_view",
    "share_entity": "anyone",
    "link_share_entity": "tenant_readable",
    "invite_external": true
}
```

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-
permission_public | permission_public | New common settings of the document after the current update.
external_access | boolean | Indicates whether sharing out of the tenant is allowed.
security_entity | string | Settings of the permission to make a copy of, print, export, and copy the document.<br>**Optional values are**:<br>- anyone_can_view：All users who can access this document.<br>- anyone_can_edit：Users with the edit permission.<br>- only_full_access：Users with manageable privileges (including me)
comment_entity | string | Settings of the permission to comment on the document.<br>**Optional values are**:<br>- anyone_can_view：All users who can access this document.<br>- anyone_can_edit：Users with the edit permission.
share_entity | string | Indicates who can add and manage collaborators.<br>**Optional values are**:<br>- anyone：All users who can read or edit this document.<br>- same_tenant：All users who can read or edit this document in the organization.<br>- only_full_access：Only users with full access.
link_share_entity | string | Link sharing<br>**Optional values are**:<br>- tenant_readable：Users who obtain the link in the organization can read the document.<br>- tenant_editable：Users who obtain the link in the organization can edit the document.<br>- anyone_readable：All users who obtain the link can read the document. (This option is valid only when `external_access`)<br>- anyone_editable：All users who obtain the link can edit the document.  (This option is valid only when `external_access`)<br>- closed：Closed share link.
invite_external | boolean | Specifies whether users without full access and non-owners are allowed to invite external participants.
lock_switch | boolean | Node lock state

### Response body example
```json
{"code":0,
"msg":"success",
"data":{"permission_public":{"external_access":true,
"security_entity":"anyone_can_view",
"comment_entity":"anyone_can_view",
"share_entity":"anyone",
"link_share_entity":"tenant_readable",
"invite_external":true,
"lock_switch":False}}}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
400 | 1063001 | Invalid parameter | The parameter is abnormal, which may be due to the following reasons:<br>- The parameter types do not match, for example, the token and type of the document do not match.<br>- Abnormal parameter filling, such as token or type filling, which does not meet the requirements of the document.
403 | 1063002 | Permission denied | Unauthorized operation may be due to the following reasons: <br>- There is no permission to call the identity, such as: the user corresponding to the calling identity is not in the collaborator of the cloud document, and there is no permission to operate. <br>- Visibility restrictions, such as: inviting group collaborators who are not in the group, inviting department collaborators who are not in the department.
400 | 1063003 | Invalid operation | Illegal operation, which may be due to the following reasons: <br>- The number of collaborators has reached the upper limit. <br>- Modify cloud document permission settings but cannot be modified due to enterprise control.
403 | 1063004 | User has no share permission | The user does not have sharing permissions, please confirm whether the calling identity has sharing permissions for the document.
404 | 1063005 | Resource is deleted | The resource has been deleted, please confirm that the cloud document still exists.
500 | 1066001 | Internal Error | Internal service error, such as timeout or failure in processing error codes.
500 | 1066002 | Concurrency error, please retry | Internal service error. Please try again.

