Mini Program Private Messages

View Markdown

Last edited on 2026-07-23

Feature Introduction

The Mini Program private message feature is a capability that works as follows: after a sharer shares a Mini Program card with other users or WeChat groups, when those users click the Mini Program card, the developer can identify whether the user clicking the card has been sent a Mini Program card by the sharer.

Usage Instructions

1. Sharing

After creating a business activity and before sharing the Mini Program message, you must create an activityId via the backend API createActivityId to establish a unique association between an activityId and a business activity ID.

Then, use the wx.updateShareMenu API to declare the current shared message as a private message. Private messages cannot be forwarded further.

Once declared, private messages can be shared with individuals or group chats via the top-right menu, the share button component, or wx.shareAppMessage (Mini Games only).

Scenario 1: Individual sharing with an individual

A --> B

Scenario 2: Individual shares to a group

A --> [B, C, D, E]

Sample code

wx.updateShareMenu({
  withShareTicket: true,
  isPrivateMessage: true,
  activityId: 'xxx',
})

2. Verification

When entering Mini Program from a group chat or one-on-one chat message card, you can use the wx.authPrivateMessage interface to verify whether the current user is the recipient of the private message, i.e., whether the message was forwarded directly from A to B or forwarded from A to the group that B belongs to.

Before using this interface, you must log in to Mini Program via the wx.login() interface.

Interface Parameters

Parameter Type Description
shareTicket string shareTicket

success Callback

Parameter Type Description
valid Boolean Whether the verification passed
iv String The initialization vector of the encryption algorithm. See Decryption Algorithm for Encrypted Data for details
encryptedData String The encrypted activityId. Decrypting it yields the original activityId. If the decrypted activityId matches the activity ID in the developer backend, the verification is successful; otherwise, it indicates that the valid field is unreliable (has been tampered with). See Decryption Algorithm for Encrypted Data for details

Notes

  • If the returned valid field is false, it indicates that the verification has failed.
  • If the returned valid field is true, it indicates that the verification has passed. However, for security reasons and to prevent potential tampering of the valid field, you can pass encryptedData and iv to the developer backend for decryption. If the decrypted activityId matches the activityId of the current activity, the verification is successful; otherwise, it is considered failed.
  • When a private message is shared to a group, validity is determined based on whether the user is in the group at the time of verification.
  • An activityId is valid for sharing for 7 days and valid for verification for 120 days after creation.

Sample Code

wx.authPrivateMessage({
  shareTicket: 'xxxxxx',
  success(res) {
    console.log('authPrivateMessage success', res)
    // res
    // {
    //   errMsg: 'authPrivateMessage:ok'
    //   valid: true
    //   iv: 'xxxx',
    //   encryptedData: 'xxxxxx'
    // }
  },
  fail(res) {
    console.log('authPrivateMessage fail', res)
  }
})