Skip to main content

Callback Overview

DingTalk pushes subscribed callback events to Third-party enterprise apps, including app activation, App authorization changes, and Department changes. By subscribing to these events, developers can integrate more effectively with DingTalk. When developing a Third-party enterprise app, you must register a callback to receive the enterprise app activation event. This event notifies your Third-party app which Organization has activated the app. After your Third-party app backend receives this event, initialize the Organization information. DingTalk currently supports the following push methods:
  • RDS push
  • HTTP push
  • SyncHTTP push
SyncHTTP pushes data to the ISV service through HTTP callbacks, using the same fields and format as RDS push. Service providers can save the data received over HTTP to a self-built database or RDS, following the RDS push method and types. Note After SyncHTTP receives a callback, save it to the database immediately and then return a success response. To handle other business logic, use asynchronous processing. With SyncHTTP, you do not need to manually call the app activation API. After receiving the pushed ticket, use it to call the Server-side API directly. Note The egress IPs for SyncHTTP push and HTTP push are:
  • 203.119.0.0/16
  • 203.119.128.0/17
  • 140.205.0.0/16
  • 106.11.0.0/16
  • 198.11.0.0/16
  • 59.82.0.0/16

Callback Event Registration Process

The callback event subscription process is shown in the following figure. First, configure an HTTP request endpoint on the DingTalk Open Platform to receive pushed subscription events, and then set the events you want to subscribe to. After you configure the request endpoint, the DingTalk Open Platform sends a POST request to it. The event subscription is completed only if you correctly return an encrypted string containing “success” within the specified time.

Configure the Request Endpoint and Subscribe to Callback Events

To receive callback events pushed by DingTalk through SyncHTTP, first configure an HTTP callback URL. When a subscribed event is triggered, DingTalk sends a corresponding HTTP POST request to this URL.
  1. Sign in to the Developer Console. Find the app you created and open its details page.
  2. Click Development Management, then click Edit, and select SyncHTTP Push as the push type.
  3. Configure the HTTP endpoint used to receive requests.
    • token: Each time DingTalk pushes event data to your endpoint, it includes a token used to generate the Signature and verify the legitimacy of the callback request. It must consist of English letters or Numbers and be 3 to 32 characters long.
    • Encryption AES Key: Click Generate Automatically to generate an AES key. This is the parameter used to encrypt and decrypt callback message Content. It is the Base64 encoding of the AES key. For details, see Message Encryption and Decryption below.
    • Callback URL: The URL used to receive subscribed event requests. When a subscribed event is triggered, DingTalk sends a corresponding HTTP POST request to this URL. Note Each app can configure only one Callback URL. All event Notifications for the app’s subscriptions are sent to this request URL.
  4. After the configuration is complete, when you click the Verify Validity button, the Open Platform pushes an application/json POST request to the URL you configured to verify its legitimacy, as shown below:
    When you receive the POST verification request from the Open Platform, decrypt it and return an encrypted string containing success to DingTalk within 1,200 ms. If you do not respond in time, requests may be rate limited.
  5. After the request endpoint is configured successfully, in the Callback Events list area, select the callback events you want to subscribe to, and then click Save in the upper-right corner. Note If a callback event cannot be selected, apply for the corresponding API permission on the Manage Permissions page in the Developer Console.

Pushed Data Description

After you configure the Callback URL, when you click the Verify Validity button, the Open Platform pushes an application/json POST request to the URL you configured to verify its legitimacy, as shown below:
Decrypt the received message Content. For details, see Message Encryption and Decryption below. The decrypted event types are as follows:
  • check_url: Test callback event Decrypted data:
  • check_create_suite_url: Verification callback event Decrypted data:
  • check_update_suite_url: Callback URL update event Decrypted data:
  • SYNC_HTTP_PUSH_HIGH: High-priority data, such as app activation
  • SYNC_HTTP_PUSH_MEDIUM: Normal-priority data, such as Contacts changes
The bizData of the SYNC_HTTP_PUSH_HIGH and SYNC_HTTP_PUSH_MEDIUM types is exactly the data in the open_sync_biz_data and open_sync_biz_data_medium tables of RDS push. For the specific format, see Data Formats.

Receive and Respond to Callback Events

Start an HTTP service (as shown below). In the service’s response logic, decrypt and store the callback (pushed) data. Complete code example: <https://github.com/opendingtalk/eapp-isv-quick-start-java/blob/master/src/main/java/com/controller/CallbackController.java>

Message Encryption and Decryption

To ensure secure data transmission, when DingTalk pushes subscribed callback events to the Callback URL, it includes the configured token to verify the event source. It also uses the key to symmetrically encrypt the message Content. Click here to get the callback encryption and decryption library and its demo. The DingTalk server encodes the plaintext of the msg message body into encrypt. encrypt = Base64_Encode(AES_Encrypt[random(16B) + msg_len(4B) + msg + $key]) is the Base64 encoding of the encrypted plaintext message msg. Where:
  • random is a 16-byte random string.
  • msg_len is the 4-byte length of msg, in network byte order.
  • msg is the plaintext of the message body.
  • key is the suiteKey of the app.
Extract the encrypt field from the returned JSON:
  • Base64-decode the ciphertext: aes_msg = Base64_Decode(encrypt).
  • Use the AESKey to perform AES decryption: rand_msg = AES_Decrypt(aes_msg).
An encryption and decryption code example is shown below. For the complete example, see DingTalk Third-Party Enterprise App - Mini Program - Quickstart (Java): Note The encryption and decryption process in this code example depends on the DingCallbackCrypto utility class. See dingtalk-callback-Crypto.