Setting the Unread Message Count of a Member

Last updated: 2021-01-05 10:32:29

    Feature Description

    • This API is used by app admins to set the unread message count of a group member. When this API is called, no callback is triggered and no notification is sent.
    • When the app needs to be migrated from another IM system to Tencent Cloud IM, this API is used to set the unread message count of group members.

    API Calling Description

    Applicable group types

    Group Type ID Is this RESTful API Supported?
    Private Yes. Same as Work (work group for friends) in the new version.
    Public Yes.
    ChatRoom Yes. Same as Meeting (temporary meeting group) in the new version.
    AVChatRoom No.

    These are the 4 built-in group types in IM. For detailed information, see the Group System.


    ChatRooms and AVChatrooms do not support unread message counts. Therefore, you cannot set an unread message count for members of these two group types. However, no error will be returned if you try.

    Sample request URL

    Request parameters

    The list below contains only the parameters commonly used when calling this API and their descriptions. For more parameters, see RESTful API Overview.

    Parameter Description
    v4/group_open_http_svc/set_unread_msg_num Request API
    sdkappid SDKAppID assigned by the IM console when the application is created
    identifier The value must be the app admin account. For more information, see App Admins.
    usersig Signature generated by the app admin account. For details on how to generate the signature, see Generating UserSig.
    random A random 32-bit unsigned integer ranging from 0 to 4294967295

    Maximum calling frequency

    The maximum calling frequency is 200 calls per second.

    Sample request packet

    In the following example, the unread message count of a specified group member is set.
    If the unread message count specified by this API is greater than the current number of messages in the group, the unread message count is set to the current number of messages in the group.

        "GroupId": "@TGS#2CLUZEAEJ", // Target group (required)
        "Member_Account": "bob", // Target group member (required)
        "UnreadMsgNum":5          // Unread message count of this member

    Request packet fields

    Field Type Required Description
    GroupId String Required ID of the target group
    Member_Account String Required Target group member
    UnreadMsgNum Integer Required Unread message count of the member

    Sample response packet body

        "Action1Status": "OK",
        "ErrorInfo": "",
        "ErrorCode": 0

    Response packet fields

    Field Type Description
    ActionStatus String Result of the request. OK indicates that the request was successful, and FAIL indicates that the request failed.
    ErrorInfo String Detailed error information
    ErrorCode Integer Error code. 0 indicates that the request was successful, and any non-zero value indicates that the request failed.

    Error Codes

    Unless a network error (such as error 502) occurs, the returned HTTP status code for this API is always 200. The specific error code and details can be found in the response packet fields such as ErrorCode and ErrorInfo.
    For public error codes (60000 to 79999), see Error Codes.
    The list below contains error codes specific to this API:

    Error Code Description
    10002 An internal server error occurred. Please try again.
    10003 The request command word is invalid.
    10004 A parameter is invalid. Check the error description and troubleshoot the issue.
    10007 The operation permissions are insufficient. For example, to remove someone from a public group requires admin permissions.
    10010 The group does not exist, or once existed but has been disbanded.
    10015 The group ID is invalid. Be sure to use the correct group ID.

    API Debugging Tool

    Use the online debugging tool for RESTful APIs to debug this API.


    Sending system messages in a group (v4/group_open_http_svc/send_group_system_notification)

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback