# Update a user group

Call this interface to update the name or description of the specified user group.

## Precautions

- The contacts permission range of the application needs to meet any of the following settings before this interface can be called successfully. To understand the permission scope of the application contacts, please refer to [Permission Scope Resource Introduction](https://open.feishu.cn/document/ukTMukTMukTM/uETNz4SM1MjLxUzM/v3/guides/scope_authority).

- The contacts permission scope is set to **All members**.
   - The enterprise administrator sets the visibility range of the application in the management background to include the user group currently to be updated, and then sets the application's contacts permission range to **Identical to the availability of app**.

- The API method does not currently support updating dynamic user groups.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/contact/v3/group/:group_id
HTTP Method | PATCH
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 user group information(contact:group)
Required field scopes | **Notice**：The response body of the API contains the following sensitive fields, and they will be returned only after corresponding scopes are added. If you do not need the fields, it is not recommended that you request the scopes.<br>Obtain user ID(contact:user.employee_id:readonly)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer t-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
---|---|---
group_id | string | User group ID.<br>The user group ID can be obtained from the return value when creating the user group. You can also call the [Query User Group List](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/group/simplelist) interface to obtain the user group ID.<br>**Example value**: "g187131"

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
user_id_type | string | No | User ID categories<br>**Example value**: open_id<br>**Optional values are**:<br>- open_id：Identifies a user to an app. The same user has different Open IDs in different apps. [How to get Open ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-openid)<br>- union_id：Identifies a user to a tenant that acts as a developer. A user has the same Union ID in apps developed by the same developer, and has different Union IDs in apps developed by different developers. A developer can use Union ID to link the same user's identities in multiple apps.[How to get Union ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-union-id)<br>- user_id：Identifies a user to a tenant. The same user has different User IDs in different tenants. In one single tenant, a user has the same User ID in all apps （including store apps）. User ID is usually used to communicate user data between different apps. [How to get User ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)<br>**Default value**: `open_id`<br>**When the value is `user_id`, the following field scopes are required**:<br>Obtain user ID(contact:user.employee_id:readonly)
department_id_type | string | No | The type of department ID in this call. For a detailed introduction to department ID, please refer to [Department ID Description](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/department/field-overview#23857fe0).<br>**Example value**: open_department_id<br>**Optional values are**:<br>- department_id：Supports user-defined configuration of department IDs. The deleted department_id can be reused when customizing the configuration, so department_id is unique within the scope of the department that has not been deleted.<br>- open_department_id：Department ID automatically generated by the system. The ID prefix is fixed to `od-` and is globally unique within the tenant.

### Request body

Parameter | Type | Required | Description
---|---|---|---
name | string | No | User group name cannot exceed 100 characters in length.<br>**Note**: The user group name is unique within the enterprise. If it is set repeatedly, the creation will fail.<br>**Default value**: empty, indicating that the user group name will not be updated.<br>**Example value**: "IT outsourcing user group"
description | string | No | User group description, cannot exceed 500 characters in length.<br>**Default value**: empty, indicating not to update the user group description.<br>**Example value**: "IT outsourcing user group, for which fine-grained permission control is required"

### Request body example
```json
{
    "name": "IT outsourcing user group",
    "description": "IT outsourcing user group, for which fine-grained permission control is required"
}
```

## 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
---|---|---|---
500 | 40003 | internal error | Internal error, you can get the X-Request-Id of the request and contact [Technical Support](https://applink.feishu.cn/TLJpeNdW).
400 | 42002 | invalid group_id | Invalid user group ID. Please check whether the incoming user group ID is correct. You can call the [Query User Group List](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/group/simplelist) interface to obtain the user group ID.
400 | 42013 | group name exceeds limit | The length of the user group name exceeds the maximum limit. The length of the name parameter value during request cannot exceed 100 characters.
400 | 42014 | group description exceed limit | The user group description length exceeds the maximum limit. When requesting, the length of the description value cannot exceed 500 characters.
403 | 42009 | no userGroup authority error | Missing user group permissions. The application's contacts permission range needs to meet any of the following settings before this interface can be called successfully.<br>- The contacts permission scope is set to **All members**.<br>- The enterprise administrator sets the visibility range of the application in the management background to include the user group currently to be updated, and then sets the application's contacts permission range to **Identical to the availability of app**.<br>To understand the permission scope of the application contacts, please refer to [Permission Scope Resource Introduction](https://open.feishu.cn/document/ukTMukTMukTM/uETNz4SM1MjLxUzM/v3/guides/scope_authority).
400 | 42015 | user group disabled | Missing user group permissions. The application's contacts permission range needs to meet any of the following settings before this interface can be called successfully.<br>- The contacts permission scope is set to **All members**.<br>- The enterprise administrator sets the visibility range of the application in the management background to include the user group currently to be updated, and then sets the application's contacts permission range to **Identical to the availability of app**.<br>To understand the permission scope of the application contacts, please refer to [Permission Scope Resource Introduction](https://open.feishu.cn/document/ukTMukTMukTM/uETNz4SM1MjLxUzM/v3/guides/scope_authority).
400 | 47009 | duplicated name error | Duplicate user group name. The user group name is unique within the enterprise. You can try changing it to another name and try again.
400 | 40001 | parameter invalid | Parameter error. Please check whether the input parameters are set incorrectly. You can refer to the parameter descriptions in the interface document to repair the input parameter values.
400 | 42018 | exist invalid dynamic group rule | There are illegal dynamic user group rules, please check the request parameters and try again
400 | 42019 | exist invalid dynamic group rule expression | Dynamic user group matching rule error
400 | 42020 | exist unsupported dynamic group rule expression field | Unsupported member property passed into matching rule expression for dynamic user group
400 | 42021 | exist unsupported dynamic group operatrion | An unsupported relational operation instruction was passed into the matching rule expression of the dynamic user group
400 | 42022 | exist invalid expression value or values | Invalid, unsupported values, or single-value, multi-value, and relational operators were passed in the matching rule expression for the dynamic user group
400 | 42024 | no permission to create a dynamic group | Lack of permission to create dynamic user groups, please confirm and try again
400 | 42025 | invalid joiner rule | Invalid Joinner rule, please adjust and try again
400 | 42026 | department scope exceed limit | Department scope exceed limit, please confirm and try again
400 | 42027 | group visible scope is not valid | Group visible scope is not valid.

For more error code information, see [General error codes](https://open.feishu.cn/document/ukTMukTMukTM/ugjM14COyUjL4ITN).

