/ Platform API
Platform API
    Chat Platform API v3
    Chat Platform API
    Chat Platform API
    Version 3

    Get number of unread items

    Copy link

    This action retrieves the count of a user's unread messages, unread mentioned messages, or received invitations in group channels. You can use this action to display an unread count in the UI and prompt the user to check unread items. This is only available for group channels.


    HTTP request

    Copy link
    GET https://api-{application_id}.sendbird.com/v3/users/{user_id}/unread_item_count
    

    Parameters

    Copy link

    The following table lists the parameters that this action supports.

    Parameters
    RequiredTypeDescription

    user_id

    string

    Specifies the unique ID of a user.

    item_keys

    string

    Specifies which unread items to count in a comma-separated string. Acceptable values are the following:
    - non_super_group_channel_unread_message_count: Only counts the total number of the user's unread messages in the non-Supergroup channels.
    - super_group_channel_unread_message_count: Only counts the total number of the user's unread messages in the Supergroup channels.
    - group_channel_unread_message_count: Counts the total number of the user's unread messages in all group channels.
    - non_super_group_channel_invitation_count: Only counts the total number of the user's received invitations to the non-Supergroup channels.
    - super_group_channel_invitation_count: Only counts the total number of the user's received invitations to the Supergroup channels.
    - group_channel_invitation_count: Counts the total number of the user's received invitations to all group channels.
    - non_super_group_channel_unread_mention_count: Only counts the total number of the user's mentioned but unread messages in the non-Supergroup channels.
    - super_group_channel_unread_mention_count: Only counts the total number of the user's mentioned but unread message in the Supergroup channels.
    - group_channel_unread_mention_count: Counts the total number of the user's mentioned but unread messages in all group channels.

    OptionalTypeDescription

    custom_types

    string

    Specifies custom channel types in a comma-separated string. If specified, only unread items in channels with the specified custom types are included in the count.


    ?item_keys=non_super_group_channel_unread_message_count,non_super_group_channel_unread_mention_count,non_super_group_channel_invitation_count&custom_types=my-custom-type-1,my-custom-type-2
    

    Responses

    Copy link

    If successful, this action returns the total count of items in the response body.

    {
        "non_super_group_channel_unread_message_count": 6,
        "super_group_channel_unread_message_count": 2,
        "group_channel_unread_message_count": 3,
        "super_group_channel_invitation_count": 1,
        "group_channel_invitation_count": 4,
        "super_group_channel_unread_mention_count": 1,
        "group_channel_unread_mention_count": 2,
        "non_super_group_channel_unread_mention_count": 2,
        "non_super_group_channel_invitation_count": 3
    }
    

    In the case of an error, an error object like below is returned. See the error codes section for more details.

    {
        "message": "\"User\" not found.",
        "code": 400201,
        "error": true
    }