Expected result
The user information page is shown below:Integration flow overview
This article describes how to create an internal app and use the user management APIs provided by Contacts management to create, retrieve, update, and delete employees in your organization. Step 1: Obtain the app credential, including the client ID and Client Secret. Step 2: Request API permissions for Contacts management. Step 3: Obtain the access_token of the internal app as the app access credential. The access token is used to authenticate the caller when an API is called. Step 4: Call the Contacts APIs:-
Call the Server API Create a user to create a user and obtain the
userid.- To add an employee to the root department, pass
1as the parameter. This example adds the employee to the root department. - To add an employee to a specific department, first call Obtain the list of sub-department IDs to get the department ID, and then pass it as the department parameter when creating the user.
- To add an employee to the root department, pass
-
With the
userid, call the Server API Query user details to retrieve the user’s detailed information. -
With the
userid, call the Server API Update user information to update the user’s information. -
With the
userid, call the Server API Delete a user to delete the user.
Prerequisites
Complete the app creation and configuration flow.Step 1: Obtain the app credential
- Select the target app to enter the app details page, and click Basic information > Credentials and basic information.
- Obtain the client ID and Client Secret.
Step 2: Add API permissions
Click Development configuration > Manage permissions. In the permission search box, enterqyapi_manage_addresslist and qyapi_get_department_list, and request the permissions.
Step 3: Obtain the app access credential (access token)
Important
- For differences between Server API versions, see Legacy API vs. New API.
- To download the Server API SDK, see Server-side SDK download.
Step 4: Call the Contacts APIs
-
Call the Server API Create a user to create a user and obtain the
userid.- To add an employee to the root department, pass
1as the parameter. This example adds the employee to the root department. - To add an employee to a specific department, first call Obtain the list of sub-department IDs to get the department ID, and then pass it as the department parameter when creating the user.
- To add an employee to the root department, pass
-
With the
userid, call the Server API Query user details to retrieve the user’s detailed information.
Note
Some fields returned by the Query user details API have specific requirements. See the field descriptions in the Query user details API documentation.- With the
userid, call the Server API Update user information to update the user’s information.
Note
The Update user information API does not currently support updating the mobile number.-
With the
userid, call the Server API Delete a user to delete the user.