Sync your OA system with DingTalk Contacts
Prerequisites
Complete the Create an app process.Step 1: Obtain the app credential
- Select the target app and go to the app details page. Click Basic Information > Credentials and Basic Information.
- Obtain the Client ID and Client Secret.
Step 2: Add API permissions
Click Development Configuration > Manage permissions. Enterqyapi_manage_addresslist in the permission search box and request the permission.
Step 3: Obtain the access token of the app
Important
- For differences between Server APIs, see the comparison between the legacy Server API and the new Server API.
- To download the Server API SDK, see Server SDK download.
Step 4: Contacts sync workflow
-
Sync DingTalk Contacts to the OA system contacts:
The key to this sync is that any change in DingTalk Contacts must trigger a corresponding action in the OA system contacts.
- First, refer to the Get all employees in an organization document to import the current DingTalk Organization Structure into the OA system contacts.
- Use the event subscription feature provided by DingTalk and subscribe to contacts events. Changes in DingTalk Contacts will trigger corresponding callback events. For the format of contacts event push messages, see Contacts.
- The OA system receives and processes the contacts events pushed by DingTalk, and updates the OA system contacts accordingly.
-
Sync OA system contacts updates to DingTalk Contacts:
When information in the OA system contacts changes, sync the updates to DingTalk Contacts to keep them consistent.
-
When a department is created in the OA system contacts, call the Create department API to create the same department tier and department name in the DingTalk Client-side based on the department tier and name in the OA system.
-
When a department is created in the OA system contacts, call the Create department API to create the same department tier and department name in the DingTalk Client-side based on the department tier and name in the OA system.
Note
The department ID in DingTalk Contacts is automatically generated and cannot be set manually. When syncing contacts updates, use the department name as the identifier when syncing to DingTalk, and save the corresponding DingTalk Contacts department ID for later use. 2. Add roles to the OA system contacts based on the role information in the OA system.-
Call the Server API Add a role group to create role group information.
-
Call the Server API Create role to create role information for the organization.
-
Call the Create user API to add employees from each department in the OA system to the corresponding departments in DingTalk. During this step, you can also assign role information to the employee.