tencent cloud


Callback Before Accepting a Request to Add a User to a Group

Last updated: 2022-05-24 10:58:35

    Feature Description

    This API enables the app backend to promptly view (and reject if so configured) group members' requests to add other users to the group.


    • To enable this callback, you must configure the callback URL and toggle on the corresponding callback protocol. For details on the configuration method, see Third-Party Callback Configuration.
    • The callback route is from the IM backend to the app backend, where the IM backend sends HTTP POST requests.
    • After receiving a callback request, the app backend must check whether SDKAppID in the request URL is consistent with its own SDKAppID.
    • For other security-related matters, see Third-Party Callback Overview: Security Considerations.

    Triggering Scenarios

    • An app user sends a request for adding another user to the group through the user’s client.
    • The app admin adds the user to the group through this RESTful API.

    Callback Triggering Time

    The callback is triggered before the IM backend adds the target user to the group. (If relationship chain hosting exists and the app configures friend relationship verification in IM, this callback will be triggered after the friend relationship is verified as successful.)

    API Description

    Request URL example

    In the following example, the callback URL configured in the app is https://www.example.com.


    Request parameters

    Parameter Description
    https The request protocol is HTTPS, and the request method is POST.
    www.example.com The callback URL.
    SdkAppid The SDKAppID assigned by the IM console when an app is created.
    CallbackCommand Its value is fixed to Group.CallbackBeforeInviteJoinGroup.
    contenttype Its value is fixed to JSON.
    ClientIP The client IP address, for example,
    OptPlatform The client platform. For information on the possible values, see the description of the OptPlatform parameter in Third-Party Callback Overview: Callback Protocols.

    Request packet example

      "CallbackCommand": "Group.CallbackBeforeInviteJoinGroup",
      "GroupId": "@TGS#2J4SZEAEL",
      "Type": "Public",
      "Operator_Account": "leckie",
      "DestinationMembers": [
              "Member_Account": "jared"
              "Member_Account": "leckie"

    Request packet fields

    Field Type Description
    CallbackCommand String Callback command
    GroupId String ID of the group to which a user is added
    Type String The type of the group to be created. For details, see Group Types. The group type can be Public.
    Operator_Account String Request operator’s UserID
    DestinationMembers Array Set of UserID s to be added to the group

    Response packet example

    Allowing all users to join a group

    The app backend allows all users in requests to join the group.

      "ActionStatus": "OK",
      "ErrorInfo": "",
      "ErrorCode": 0 // Indicates that the system can continue to process requests for adding users to the group.

    Rejecting some users to join a group

    The app backend rejects some users in requests to join the group and returns these users’ Identifier s in RefusedMembers_Account.

      "ActionStatus": "OK",
      "ErrorInfo": "",
      "ErrorCode": 0,
      "RefusedMembers_Account": [ // List of rejected users

    Response packet fields

    Field Type Attribute Description
    ActionStatus String Required The request processing result. OK: succeeded. FAIL: failed.
    ErrorCode Integer Required The error code.0: allows group buliding; 1: forbids group buliding; 2: discards the message silently.If the business side wants to use his own error code to forbid a user to bulid group and sendErrorCode and ErrorInfo to the client, ensure that the value of ErrorCode is set within the range of [10100, 10200].
    ErrorInfo String Required Error information.
    RefusedMembers_Account Array Optional The set of rejected users’ IDs.


    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support