# Contact scope changed

After the app subscribes to this event, if the app's address book permission scope changes, the event will be triggered.{Usage Examples}(url=/api/tools/api_explore/api_explore_config?project=contact&version=v3&resource=scope&event=updated)

## Prerequisites

You need to configure event subscriptions in your application so that you can receive event data when the event is triggered. To learn about event subscription, see [Event Subscription Overview](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM).

## Event

Facts | &nbsp;
---|---
Event type | contact.scope.updated_v3
Supported app types | Custom App、Store App
Required scopes<br>**To subscribe to this event, enable any of the listed scopes.**<br>Enable any scope from the list | Get basic information in contacts(contact:contact.base:readonly)<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Access Contacts as an app(contact:contact:access_as_app)
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>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Get user's seat information(contact:user.assign_info:read)<br>Obtain user's basic information(contact:user.base:readonly)<br>Obtain user's organization information(contact:user.department:readonly)<br>Obtain member's department path(contact:user.department_path:readonly)<br>Obtain user's employment information(contact:user.employee:readonly)<br>View member's Employee Number(contact:user.employee_number:read)<br>Obtain user's gender(contact:user.gender:readonly)<br>Assign seat for user(contact:user.subscription_ids:write)<br>Obtain user ID(contact:user.employee_id:readonly)<br>Obtain user's mobile number(contact:user.phone:readonly)<br>Obtain user's email information(contact:user.email:readonly)<br>View user's job family(contact:user.job_family:readonly)<br>View user's job level(contact:user.job_level:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
Push Mode | [Webhook](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM)

### Event body

Parameter | Type | Description
---|---|---
schema | string | Event schema
header | event_header | Event header
event_id | string | Event ID
event_type | string | Event type
create_time | string | Event creation timestamp(in ms)
token | string | Event token
app_id | string | App ID
tenant_key | string | Tenant key
event | \- | \-
added | scope | Object added when the contact scope is changed.
departments | department\[\] | Department object.
name | string | Department name.<br>**Data validation rules**:<br>- Minimum length: `1` characters<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
i18n_name | department_i18n_name | Internationalized department name.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
zh_cn | string | Department's Chinese name.
ja_jp | string | Department's Japanese name.
en_us | string | Department's English name.
parent_department_id | string | Parent department ID. This value is "0" for a root department.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
department_id | string | Custom department ID for the department. For an introduction to department_id and open_department_id, please see [General Parameters](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/terminology).<br>**Data validation rules**:<br>- Maximum length: `64` characters<br>- Regular expression: `^[a-zA-Z0-9][a-zA-Z0-9_\-@.]{0,63}$`<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
open_department_id | string | The department's open_department_id. For an introduction to department_id and open_department_id, please see [General Parameters](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/terminology).
leader_user_id | string | Department manager's user ID (open_id). For an explanation of user ID, see [User-related ID concepts](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
chat_id | string | Department group ID.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
order | string | Department order, i.e. the order in which the department is displayed among the departments at the same level. The smaller the value, the higher the order.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
unit_ids | string\[\] | List of the department unit's custom IDs. Only one custom ID is supported currently.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
member_count | int | Number of users under the department<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
status | department_status | Department status<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
is_deleted | boolean | Whether it is deleted.<br>**Possible values are:**<br>- true<br>- false
leaders | departmentLeader\[\] | Head of department.
leaderType | int | Person in charge type.<br>**Optional values are**:<br>- 1：Main person in charge.<br>- 2：Deputy responsible person.
leaderID | string | The user open_id of the person responsible. To learn about user ID, please refer to [User-related ID concepts](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
group_chat_employee_types | int\[\] | Department group employee type restriction. [] When the list is empty, it means that there is no employee type. The type field can contain the following values, and supports multiple type values; if there are multiple values, separate them with ',' in English:<br>1. Regular employees<br>2. Intern<br>3. Outsourcing<br>4. Labor<br>5. Consultant<br>6. For other custom type fields, you can get the name of the tenant's custom employee type through the interface below, see [Get Personnel Type](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/list) .
primary_member_count | int | Number of users directly under the department<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
users | user\[\] | User
union_id | string | User's union_id. For information about different IDs, see [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).
user_id | string | Unique identifier of the user in the tenant, namely the user's user_id. For information of different IDs, refer to [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes**:<br>Obtain user ID(contact:user.employee_id:readonly)
open_id | string | User's open_id. For information about different IDs, see [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).
name | string | User name.<br>**Data validation rules**:<br>- Minimum length: `1` characters<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
en_name | string | English name.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
nickname | string | Alias.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
email | string | Email Address.<br>**Required field scopes**:<br>Obtain user's email information(contact:user.email:readonly)
mobile | string | Phone number.<br>**Required field scopes**:<br>Obtain user's mobile number(contact:user.phone:readonly)
gender | int | Gender.<br>**Optional values are**:<br>- 0：Unknown.<br>- 1：Male.<br>- 2：Female.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's gender(contact:user.gender:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
avatar | avatar_info | User's profile photo.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
avatar_72 | string | Link of profile photo in 72*72 px.
avatar_240 | string | Link of profile photo in 240*240 px.
avatar_640 | string | Link of profile photo in 640*640 px.
avatar_origin | string | Link of the original profile photo.
status | user_status | User status，enumeration types, including is_frozen, is_resigned, is_activated, is_exited.<br>User state transition see: [User State Diagram](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/field-overview#4302b5a1).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
is_frozen | boolean | Whether the user is frozen.<br>**Possible values are:**<br>- true<br>- false
is_resigned | boolean | Whether the user is terminated.<br>**Possible values are:**<br>- true<br>- false
is_activated | boolean | Whether the user is activated.<br>**Possible values are:**<br>- true<br>- false
is_exited | boolean | Whether the user left voluntarily.The user's status will be automatically changed to terminated after the user has left for a specific time of period.<br>**Possible values are:**<br>- true<br>- false
is_unjoin | boolean | Whether the user has not joined. The user must confirm in person to join the team.<br>**Possible values are:**<br>- true<br>- false
leader_user_id | string | User ID of the user's direct manager. The ID value matches the user_id_type in the query parameter.<br>For information about different IDs, see [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's organization information(contact:user.department:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
city | string | work city.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
country | string | Country or region code. Refer to the [list of country/region codes](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/country-code-description) for details.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
work_station | string | Seat ID.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
join_time | int | Entry time, in timestamp format, in seconds since January 1, 1970.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
employee_no | string | Employee ID.<br>**Required field scopes (Satisfy any)**:<br>Obtain user's employment information(contact:user.employee:readonly)<br>View member's Employee Number(contact:user.employee_number:read)<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
employee_type | int | Employee type. Optional values are:<br>- `1`: Regular<br>- `2`: Intern<br>- `3`: Outsourcing<br>- `4`: Contractor<br>- `5`: Consultant   <br>The int value of the custom employee type can also be read, and the name of the custom employee type for the tenant can be obtained through the API:   <br>[Obtain workforce type](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/list).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
custom_attrs | user_custom_attr\[\] | Custom field. <br>More detail see [FQAs](https://open.feishu.cn/document/ugTN1YjL4UTN24CO1UjN/uQzN1YjL0cTN24CN3UjN#77061525).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
type | string | Custom field type   <br>- `TEXT`: Text<br>- `HREF`: Webpage<br>- `ENUMERATION`: Enumeration<br>- `PICTURE_ENUM`: Image<br>- `GENERIC_USER`: User
id | string | Custom field ID.
value | user_custom_attr_value | Custom field value.
text | string | - When the field type is `TEXT`, this parameter defines the field value and is required.<br>- When the field type is `HREF`, this parameter defines the webpage title and is required.
url | string | When the field type is `HREF`, this parameter defines the default URL.
pc_url | string | When the field type is `HREF`, this parameter defines URL on the PC.
option_id | string | When the field type is `ENUMERATION` or `PICTURE_ENUM`, this parameter defines the option value.
option_value | string | Option value.
name | string | Name.
picture_url | string | Image link.
generic_user | custom_attr_generic_user | When the field type is `GENERIC_USER`, this parameter defines the user referenced.
id | string | The user_id of the referrer. For detailed description of user ID, please refer to [User-related ID concepts](https://open.feishu.cn/document/home/user-identity-introduction/introduction).
type | int | User type. Currently, the fixed value is 1, which represents the user.
enterprise_email | string | Business email. Make sure that Feishu Business Mail has been enabled in Admin.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
job_title | string | Job title.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
is_frozen | boolean | Whether to freeze the user.<br>**Possible values are:**<br>- true<br>- false
job_level_id | string | Job level ID.<br>**Required field scopes**:<br>View user's job level(contact:user.job_level:readonly)
job_family_id | string | Job family ID.<br>**Required field scopes**:<br>View user's job family(contact:user.job_family:readonly)
subscription_ids | string\[\] | The list of seat IDs assigned to users needs to be enabled with the **Assign User Seats** permission.<br>**Required field scopes**:<br>Assign seat for user(contact:user.subscription_ids:write)
assign_info | user_assign_info\[\] | User seat list.<br>**Required field scopes**:<br>Get user's seat information(contact:user.assign_info:read)
subscription_id | string | Seat ID.
license_plan_key | string | License plan key.
product_name | string | Seat name.
i18n_name | product_i18n_name | Internationalized name.
zh_cn | string | Seat Chinese name.
ja_jp | string | Seat Japanese name.
en_us | string | Seat English name.
start_time | string | Seat start time.
end_time | string | Seat end time.
department_path | department_detail\[\] | Department path.<br>**Required field scopes**:<br>Obtain member's department path(contact:user.department_path:readonly)
department_id | string | Department ID.
department_name | department_path_name | Department name.
name | string | Department name.
i18n_name | department_i18n_name | Department international name.
zh_cn | string | Department's Chinese name.
ja_jp | string | Department's Japanese name.
en_us | string | Department's English name.
department_path | department_path | Department path.
department_ids | string\[\] | Department Path IDs.
department_path_name | department_path_name | Department path name.
name | string | Department name.
i18n_name | department_i18n_name | Department international name.
zh_cn | string | Department's Chinese name.
ja_jp | string | Department's Japanese name.
en_us | string | Department's English name.
user_groups | user_group\[\] | User group object.
user_group_id | string | Custom ID of the user group.<br>**Data validation rules**:<br>- Length range: `1` ～ `64` characters
name | string | User group name.<br>**Data validation rules**:<br>- Length range: `1` ～ `100` characters
type | int | User group type.<br>**Optional values are**:<br>- 1：Common user group.<br>- 2：Dynamic group.
member_count | int | Number of members.
status | int | User group status.<br>**Optional values are**:<br>- 0：Unknown.<br>- 1：Calculation completed.<br>- 2：Calculating.<br>- 3：Calculation failed.
removed | scope | Object removed when the range of contacts data that an app can access is changed.
departments | department\[\] | Department object.
name | string | Department name.<br>**Data validation rules**:<br>- Minimum length: `1` characters<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
i18n_name | department_i18n_name | Internationalized department name.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
zh_cn | string | Department's Chinese name.
ja_jp | string | Department's Japanese name.
en_us | string | Department's English name.
parent_department_id | string | Parent department ID. This value is "0" for a root department.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
department_id | string | Custom department ID for the department. For an introduction to department_id and open_department_id, please see [General Parameters](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/terminology).<br>**Data validation rules**:<br>- Maximum length: `64` characters<br>- Regular expression: `^[a-zA-Z0-9][a-zA-Z0-9_\-@.]{0,63}$`<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
open_department_id | string | The department's open_department_id. For an introduction to department_id and open_department_id, please see [General Parameters](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/terminology).
leader_user_id | string | Department manager's user ID (open_id). For an explanation of user ID, see [User-related ID concepts](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
chat_id | string | Department group ID.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
order | string | Department order, i.e. the order in which the department is displayed among the departments at the same level. The smaller the value, the higher the order.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
unit_ids | string\[\] | List of the department unit's custom IDs. Only one custom ID is supported currently.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
member_count | int | Number of users under the department<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
status | department_status | Department status<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's basic information(contact:department.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
is_deleted | boolean | Whether it is deleted.<br>**Possible values are:**<br>- true<br>- false
leaders | departmentLeader\[\] | Head of department.
leaderType | int | Person in charge type.<br>**Optional values are**:<br>- 1：Main person in charge.<br>- 2：Deputy responsible person.
leaderID | string | The user open_id of the person responsible. To learn about user ID, please refer to [User-related ID concepts](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
group_chat_employee_types | int\[\] | Department group employee type restriction. [] When the list is empty, it means that there is no employee type. The type field can contain the following values, and supports multiple type values; if there are multiple values, separate them with ',' in English:<br>1. Regular employees<br>2. Intern<br>3. Outsourcing<br>4. Labor<br>5. Consultant<br>6. For other custom type fields, you can get the name of the tenant's custom employee type through the interface below, see [Get Personnel Type](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/list) .
primary_member_count | int | Number of users directly under the department<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain department's organizational structure in contacts(contact:department.organize:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
users | user\[\] | User
union_id | string | User's union_id. For information about different IDs, see [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).
user_id | string | Unique identifier of the user in the tenant, namely the user's user_id. For information of different IDs, refer to [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes**:<br>Obtain user ID(contact:user.employee_id:readonly)
open_id | string | User's open_id. For information about different IDs, see [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).
name | string | User name.<br>**Data validation rules**:<br>- Minimum length: `1` characters<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
en_name | string | English name.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
nickname | string | Alias.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
email | string | Email Address.<br>**Required field scopes**:<br>Obtain user's email information(contact:user.email:readonly)
mobile | string | Phone number.<br>**Required field scopes**:<br>Obtain user's mobile number(contact:user.phone:readonly)
gender | int | Gender.<br>**Optional values are**:<br>- 0：Unknown.<br>- 1：Male.<br>- 2：Female.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's gender(contact:user.gender:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
avatar | avatar_info | User's profile photo.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's basic information(contact:user.base:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
avatar_72 | string | Link of profile photo in 72*72 px.
avatar_240 | string | Link of profile photo in 240*240 px.
avatar_640 | string | Link of profile photo in 640*640 px.
avatar_origin | string | Link of the original profile photo.
status | user_status | User status，enumeration types, including is_frozen, is_resigned, is_activated, is_exited.<br>User state transition see: [User State Diagram](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/field-overview#4302b5a1).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
is_frozen | boolean | Whether the user is frozen.<br>**Possible values are:**<br>- true<br>- false
is_resigned | boolean | Whether the user is terminated.<br>**Possible values are:**<br>- true<br>- false
is_activated | boolean | Whether the user is activated.<br>**Possible values are:**<br>- true<br>- false
is_exited | boolean | Whether the user left voluntarily.The user's status will be automatically changed to terminated after the user has left for a specific time of period.<br>**Possible values are:**<br>- true<br>- false
is_unjoin | boolean | Whether the user has not joined. The user must confirm in person to join the team.<br>**Possible values are:**<br>- true<br>- false
leader_user_id | string | User ID of the user's direct manager. The ID value matches the user_id_type in the query parameter.<br>For information about different IDs, see [User-related IDs](https://open.feishu.cn/document/home/user-identity-introduction/introduction).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's organization information(contact:user.department:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
city | string | work city.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
country | string | Country or region code. Refer to the [list of country/region codes](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/country-code-description) for details.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
work_station | string | Seat ID.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
join_time | int | Entry time, in timestamp format, in seconds since January 1, 1970.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
employee_no | string | Employee ID.<br>**Required field scopes (Satisfy any)**:<br>Obtain user's employment information(contact:user.employee:readonly)<br>View member's Employee Number(contact:user.employee_number:read)<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
employee_type | int | Employee type. Optional values are:<br>- `1`: Regular<br>- `2`: Intern<br>- `3`: Outsourcing<br>- `4`: Contractor<br>- `5`: Consultant   <br>The int value of the custom employee type can also be read, and the name of the custom employee type for the tenant can be obtained through the API:   <br>[Obtain workforce type](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/list).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
custom_attrs | user_custom_attr\[\] | Custom field. <br>More detail see [FQAs](https://open.feishu.cn/document/ugTN1YjL4UTN24CO1UjN/uQzN1YjL0cTN24CN3UjN#77061525).<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
type | string | Custom field type   <br>- `TEXT`: Text<br>- `HREF`: Webpage<br>- `ENUMERATION`: Enumeration<br>- `PICTURE_ENUM`: Image<br>- `GENERIC_USER`: User
id | string | Custom field ID.
value | user_custom_attr_value | Custom field value.
text | string | - When the field type is `TEXT`, this parameter defines the field value and is required.<br>- When the field type is `HREF`, this parameter defines the webpage title and is required.
url | string | When the field type is `HREF`, this parameter defines the default URL.
pc_url | string | When the field type is `HREF`, this parameter defines URL on the PC.
option_id | string | When the field type is `ENUMERATION` or `PICTURE_ENUM`, this parameter defines the option value.
option_value | string | Option value.
name | string | Name.
picture_url | string | Image link.
generic_user | custom_attr_generic_user | When the field type is `GENERIC_USER`, this parameter defines the user referenced.
id | string | The user_id of the referrer. For detailed description of user ID, please refer to [User-related ID concepts](https://open.feishu.cn/document/home/user-identity-introduction/introduction).
type | int | User type. Currently, the fixed value is 1, which represents the user.
enterprise_email | string | Business email. Make sure that Feishu Business Mail has been enabled in Admin.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
job_title | string | Job title.<br>**Required field scopes (Satisfy any)**:<br>Read Contacts as an app(contact:contact:readonly_as_app)<br>Obtain user's employment information(contact:user.employee:readonly)<br>Access Contacts as an app(contact:contact:access_as_app)<br>Read contacts(contact:contact:readonly)
is_frozen | boolean | Whether to freeze the user.<br>**Possible values are:**<br>- true<br>- false
job_level_id | string | Job level ID.<br>**Required field scopes**:<br>View user's job level(contact:user.job_level:readonly)
job_family_id | string | Job family ID.<br>**Required field scopes**:<br>View user's job family(contact:user.job_family:readonly)
subscription_ids | string\[\] | The list of seat IDs assigned to users needs to be enabled with the **Assign User Seats** permission.<br>**Required field scopes**:<br>Assign seat for user(contact:user.subscription_ids:write)
assign_info | user_assign_info\[\] | User seat list.<br>**Required field scopes**:<br>Get user's seat information(contact:user.assign_info:read)
subscription_id | string | Seat ID.
license_plan_key | string | License plan key.
product_name | string | Seat name.
i18n_name | product_i18n_name | Internationalized name.
zh_cn | string | Seat Chinese name.
ja_jp | string | Seat Japanese name.
en_us | string | Seat English name.
start_time | string | Seat start time.
end_time | string | Seat end time.
department_path | department_detail\[\] | Department path.<br>**Required field scopes**:<br>Obtain member's department path(contact:user.department_path:readonly)
department_id | string | Department ID.
department_name | department_path_name | Department name.
name | string | Department name.
i18n_name | department_i18n_name | Department international name.
zh_cn | string | Department's Chinese name.
ja_jp | string | Department's Japanese name.
en_us | string | Department's English name.
department_path | department_path | Department path.
department_ids | string\[\] | Department Path IDs.
department_path_name | department_path_name | Department path name.
name | string | Department name.
i18n_name | department_i18n_name | Department international name.
zh_cn | string | Department's Chinese name.
ja_jp | string | Department's Japanese name.
en_us | string | Department's English name.
user_groups | user_group\[\] | User group object.
user_group_id | string | Custom ID of the user group.<br>**Data validation rules**:<br>- Length range: `1` ～ `64` characters
name | string | User group name.<br>**Data validation rules**:<br>- Length range: `1` ～ `100` characters
type | int | User group type.<br>**Optional values are**:<br>- 1：Common user group.<br>- 2：Dynamic group.
member_count | int | Number of members.
status | int | User group status.<br>**Optional values are**:<br>- 0：Unknown.<br>- 1：Calculation completed.<br>- 2：Calculating.<br>- 3：Calculation failed.

### Event body example
```json
{
    "schema": "2.0",
    "header": {
        "event_id": "5e3702a84e847582be8db7fb73283c02",
        "event_type": "contact.scope.updated_v3",
        "create_time": "1608725989000",
        "token": "rvaYgkND1GOiu5MM0E1rncYC6PLtF7JV",
        "app_id": "cli_9f5343c580712544",
        "tenant_key": "2ca1d211f64f6438"
    },
    "event": {
        "added": {
            "departments": [
                {
                    "name": "DemoName",
                    "i18n_name": {
                        "zh_cn": "Demo name",
                        "ja_jp": "Name",
                        "en_us": "Demo Name"
                    },
                    "parent_department_id": "D067",
                    "department_id": "D096",
                    "open_department_id": "Od-4e6ac4d14bcd5071a37a39de902c7141",
                    "leader_user_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
                    "chat_id": "oc_5ad11d72b830411d72b836c20",
                    "order": "100",
                    "unit_ids": [
                        "custom_unit_id"
                    ],
                    "member_count": 100,
                    "status": {
                        "is_deleted": False
                    },
                    "leaders": [
                        {
                            "leaderType": 1,
                            "leaderID": "ou_7dab8a3d3cdcc9da365777c7ad535d62"
                        }
                    ],
                    "group_chat_employee_types": [
                        1,2,3
                    ],
                    "primary_member_count": 100
                }
            ],
            "users": [
                {
                    "union_id": "on_94a1ee5551019f18cd73d9f111898cf2",
                    "user_id": "3e3cf96b",
                    "open_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
                    "name": "John",
                    "en_name": "San Zhang",
                    "nickname": "Alex Zhang",
                    "email": "Alex@gmail.com",
                    "mobile": "13011111111(Other examples, Mobile numbers in mainland China：13011111111 or +8613011111111；
Overseas mobile numbers: +41446681800)",
                    "gender": 1,
                    "avatar": {
                        "avatar_72": "https://foo.icon.com/xxxx",
                        "avatar_240": "https://foo.icon.com/xxxx",
                        "avatar_640": "https://foo.icon.com/xxxx",
                        "avatar_origin": "https://foo.icon.com/xxxx"
                    },
                    "status": {
                        "is_frozen": false,
                        "is_resigned": false,
                        "is_activated": true,
                        "is_exited": false,
                        "is_unjoin": false
                    },
                    "leader_user_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
                    "city": "Hangzhou",
                    "country": "CN",
                    "work_station": "North building-H34",
                    "join_time": 2147483647,
                    "employee_no": "1",
                    "employee_type": 1,
                    "custom_attrs": [
                        {
                            "type": "TEXT",
                            "id": "DemoId",
                            "value": {
                                "text": "DemoText",
                                "url": "http://www.fs.cn",
                                "pc_url": "http://www.fs.cn",
                                "option_id": "edcvfrtg",
                                "option_value": "option",
                                "name": "name",
                                "picture_url": "https://xxxxxxxxxxxxxxxxxx",
                                "generic_user": {
                                    "id": "9b2fabg5",
                                    "type": 1
                                }
                            }
                        }
                    ],
                    "enterprise_email": "demo@mail.com",
                    "job_title": "xxxxx",
                    "is_frozen": false,
                    "job_level_id": "mga5oa8ayjlp9rb",
                    "job_family_id": "mga5oa8ayjlp9rb",
                    "subscription_ids": [
                        "7179609168571645971"
                    ],
                    "assign_info": [
                        {
                            "subscription_id": "7079609167680782300",
                            "license_plan_key": "suite_enterprise_e5",
                            "product_name": "旗舰版 E5",
                            "i18n_name": {
                                "zh_cn": "zh_cn_name",
                                "ja_jp": "ja_jp_name",
                                "en_us": "en_name"
                            },
                            "start_time": "1674981000",
                            "end_time": "1674991000"
                        }
                    ],
                    "department_path": [
                        {
                            "department_id": "od-4e6ac4d14bcd5071a37a39de902c7141",
                            "department_name": {
                                "name": "测试部门名1",
                                "i18n_name": {
                                    "zh_cn": "Demo name",
                                    "ja_jp": "Name",
                                    "en_us": "Demo Name"
                                }
                            },
                            "department_path": {
                                "department_ids": [
                                    "od-4e6ac4d14bcd5071a37a39de902c7141"
                                ],
                                "department_path_name": {
                                    "name": "测试部门名1",
                                    "i18n_name": {
                                        "zh_cn": "Demo name",
                                        "ja_jp": "Name",
                                        "en_us": "Demo Name"
                                    }
                                }
                            }
                        }
                    ]
                }
            ],
            "user_groups": [
                {
                    "user_group_id": "test",
                    "name": "userGroupName",
                    "type": 1,
                    "member_count": 10,
                    "status": 1
                }
            ]
        },
        "removed": {
            "departments": [
                {
                    "name": "DemoName",
                    "i18n_name": {
                        "zh_cn": "Demo name",
                        "ja_jp": "Name",
                        "en_us": "Demo Name"
                    },
                    "parent_department_id": "D067",
                    "department_id": "D096",
                    "open_department_id": "Od-4e6ac4d14bcd5071a37a39de902c7141",
                    "leader_user_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
                    "chat_id": "oc_5ad11d72b830411d72b836c20",
                    "order": "100",
                    "unit_ids": [
                        "custom_unit_id"
                    ],
                    "member_count": 100,
                    "status": {
                        "is_deleted": False
                    },
                    "leaders": [
                        {
                            "leaderType": 1,
                            "leaderID": "ou_7dab8a3d3cdcc9da365777c7ad535d62"
                        }
                    ],
                    "group_chat_employee_types": [
                        1,2,3
                    ],
                    "primary_member_count": 100
                }
            ],
            "users": [
                {
                    "union_id": "on_94a1ee5551019f18cd73d9f111898cf2",
                    "user_id": "3e3cf96b",
                    "open_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
                    "name": "John",
                    "en_name": "San Zhang",
                    "nickname": "Alex Zhang",
                    "email": "Alex@gmail.com",
                    "mobile": "13011111111(Other examples, Mobile numbers in mainland China：13011111111 or +8613011111111；
Overseas mobile numbers: +41446681800)",
                    "gender": 1,
                    "avatar": {
                        "avatar_72": "https://foo.icon.com/xxxx",
                        "avatar_240": "https://foo.icon.com/xxxx",
                        "avatar_640": "https://foo.icon.com/xxxx",
                        "avatar_origin": "https://foo.icon.com/xxxx"
                    },
                    "status": {
                        "is_frozen": false,
                        "is_resigned": false,
                        "is_activated": true,
                        "is_exited": false,
                        "is_unjoin": false
                    },
                    "leader_user_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
                    "city": "Hangzhou",
                    "country": "CN",
                    "work_station": "North building-H34",
                    "join_time": 2147483647,
                    "employee_no": "1",
                    "employee_type": 1,
                    "custom_attrs": [
                        {
                            "type": "TEXT",
                            "id": "DemoId",
                            "value": {
                                "text": "DemoText",
                                "url": "http://www.fs.cn",
                                "pc_url": "http://www.fs.cn",
                                "option_id": "edcvfrtg",
                                "option_value": "option",
                                "name": "name",
                                "picture_url": "https://xxxxxxxxxxxxxxxxxx",
                                "generic_user": {
                                    "id": "9b2fabg5",
                                    "type": 1
                                }
                            }
                        }
                    ],
                    "enterprise_email": "demo@mail.com",
                    "job_title": "xxxxx",
                    "is_frozen": false,
                    "job_level_id": "mga5oa8ayjlp9rb",
                    "job_family_id": "mga5oa8ayjlp9rb",
                    "subscription_ids": [
                        "7179609168571645971"
                    ],
                    "assign_info": [
                        {
                            "subscription_id": "7079609167680782300",
                            "license_plan_key": "suite_enterprise_e5",
                            "product_name": "旗舰版 E5",
                            "i18n_name": {
                                "zh_cn": "zh_cn_name",
                                "ja_jp": "ja_jp_name",
                                "en_us": "en_name"
                            },
                            "start_time": "1674981000",
                            "end_time": "1674991000"
                        }
                    ],
                    "department_path": [
                        {
                            "department_id": "od-4e6ac4d14bcd5071a37a39de902c7141",
                            "department_name": {
                                "name": "测试部门名1",
                                "i18n_name": {
                                    "zh_cn": "Demo name",
                                    "ja_jp": "Name",
                                    "en_us": "Demo Name"
                                }
                            },
                            "department_path": {
                                "department_ids": [
                                    "od-4e6ac4d14bcd5071a37a39de902c7141"
                                ],
                                "department_path_name": {
                                    "name": "测试部门名1",
                                    "i18n_name": {
                                        "zh_cn": "Demo name",
                                        "ja_jp": "Name",
                                        "en_us": "Demo Name"
                                    }
                                }
                            }
                        }
                    ]
                }
            ],
            "user_groups": [
                {
                    "user_group_id": "test",
                    "name": "userGroupName",
                    "type": 1,
                    "member_count": 10,
                    "status": 1
                }
            ]
        }
    }
}
```

### Sample code for event subscriptions

For event subscription process, refer to:[Event Subscription overview](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM)，Guide for beginners:[Tutorial](https://open.feishu.cn/document/uAjLw4CM/uMzNwEjLzcDMx4yM3ATM/develop-an-echo-bot/introduction)

**

package main

import (
	"context"
	"fmt"

larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
	larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
	"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
	"github.com/larksuite/oapi-sdk-go/v3/service/contact/v3"
	larkws "github.com/larksuite/oapi-sdk-go/v3/ws"
)

// SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
	// 注册事件 Register event
	eventHandler := dispatcher.NewEventDispatcher("", "").
		OnP2ScopeUpdatedV3(func(ctx context.Context, event *larkcontact.P2ScopeUpdatedV3) error {
			fmt.Printf("[ OnP2ScopeUpdatedV3 access ], data: %s\n", larkcore.Prettify(event))
			return nil
		})

// 构建 client Build client
	cli := larkws.NewClient("YOUR_APP_ID", "YOUR_APP_SECRET",
		larkws.WithEventHandler(eventHandler),
		larkws.WithLogLevel(larkcore.LogLevelDebug),
	)

// 建立长连接 Establish persistent connection
	err := cli.Start(context.Background())

if err != nil {
		panic(err)
	}
}

# SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
import lark_oapi as lark

def do_p2_contact_scope_updated_v3(data: lark.contact.v3.P2ContactScopeUpdatedV3) -> None:
    print(f'[ do_p2_contact_scope_updated_v3 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_contact_scope_updated_v3(do_p2_contact_scope_updated_v3) \
    .build()

def main():
    # 构建 client Build client
    cli = lark.ws.Client("APP_ID", "APP_SECRET",
                        event_handler=event_handler, log_level=lark.LogLevel.DEBUG)
    # 建立长连接 Establish persistent connection
    cli.start()

if __name__ == "__main__":
    main()

package com.example.sample;

import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.contact.ContactService;
import com.lark.oapi.service.contact.v3.model.P2ScopeUpdatedV3;
import com.lark.oapi.event.EventDispatcher;
import com.lark.oapi.ws.Client;

// SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
public class Sample {
    // 注册事件 Register event
    private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("", "")
            .onP2ScopeUpdatedV3(new ContactService.P2ScopeUpdatedV3Handler() {
                @Override
                public void handle(P2ScopeUpdatedV3 event) throws Exception {
                    System.out.printf("[ onP2ScopeUpdatedV3 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
                }
            })
            .build();

public static void main(String[] args) {
        // 构建 client Build client
        Client client = new Client.Builder("APP_ID", "APP_SECRET")
                .eventHandler(EVENT_HANDLER)
                .build();
        // 建立长连接 Establish persistent connection
        client.start();
    }
}

// SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import * as Lark from '@larksuiteoapi/node-sdk';
const baseConfig = {
    appId: 'APP_ID',
    appSecret: 'APP_SECRET'
}
// 构建 client Build client
const wsClient = new Lark.WSClient(baseConfig);
// 建立长连接 Establish persistent connection
wsClient.start({
    // 注册事件 Register event
    eventDispatcher: new Lark.EventDispatcher({}).register({
        'contact.scope.updated_v3': async (data) => {
            console.log(data);
        }
    })
});

package main

import (
	"context"
	"fmt"
	"net/http"

larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
	"github.com/larksuite/oapi-sdk-go/v3/core/httpserverext"
	larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
	"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
	"github.com/larksuite/oapi-sdk-go/v3/service/contact/v3"
)

// SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
	// 注册事件 Register event
	eventHandler := dispatcher.NewEventDispatcher("", "").
		OnP2ScopeUpdatedV3(func(ctx context.Context, event *larkcontact.P2ScopeUpdatedV3) error {
			fmt.Printf("[ OnP2ScopeUpdatedV3 access ], data: %s\n", larkcore.Prettify(event))
			return nil
		})

// 创建路由处理器 Create route handler
	http.HandleFunc("/webhook/event", httpserverext.NewEventHandlerFunc(handler, larkevent.WithLogLevel(larkcore.LogLevelDebug)))

err := http.ListenAndServe(":7777", nil)

if err != nil {
		panic(err)
	}
}

# SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
from flask import Flask
from lark_oapi.adapter.flask import *
import lark_oapi as lark

app = Flask(__name__)

def do_p2_contact_scope_updated_v3(data: lark.contact.v3.P2ContactScopeUpdatedV3) -> None:
    print(f'[ do_p2_contact_scope_updated_v3 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_contact_scope_updated_v3(do_p2_contact_scope_updated_v3) \
    .build()

# 创建路由处理器 Create route handler
@app.route("/webhook/event", methods=["POST"])
def event():
    resp = event_handler.do(parse_req())
    return parse_resp(resp)

if __name__ == "__main__":
    app.run(port=7777)

package com.lark.oapi.sample.event;

import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.contact.ContactService;
import com.lark.oapi.service.contact.v3.model.P2ScopeUpdatedV3;
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
@RestController
public class EventController {

// 注册事件 Register event
    private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("verificationToken", "encryptKey")
            .onP2ScopeUpdatedV3(new ContactService.P2ScopeUpdatedV3Handler() {
                @Override
                public void handle(P2ScopeUpdatedV3 event) throws Exception {
                    System.out.printf("[ onP2ScopeUpdatedV3 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
                }
            })
            .build();

// 注入 ServletAdapter 实例 Inject ServletAdapter instance
    @Autowired
    private ServletAdapter servletAdapter;

// 创建路由处理器 Create route handler
    @RequestMapping("/webhook/event")
    public void event(HttpServletRequest request, HttpServletResponse response)
            throws Throwable {
        // 回调扩展包提供的事件回调处理器 Callback handler provided by the extension package
        servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
    }
}

// SDK 使用说明 SDK user guide：https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import http from 'http';
import * as lark from '@larksuiteoapi/node-sdk';

// 注册事件 Register event
const eventDispatcher = new lark.EventDispatcher({
    encryptKey: '',
    verificationToken: '',
}).register({
    'contact.scope.updated_v3': async (data) => {
        console.log(data);
        return 'success';
    },
});

const server = http.createServer();
// 创建路由处理器 Create route handler
server.on('request', lark.adaptDefault('/webhook/event', eventDispatcher));
server.listen(3000);

