Chat / Platform API
Current version: v3
    Chat Platform API v3
    Chat Platform API
    Chat
    Platform API
    Home
    /
    Chat
    /
    Platform API

    Block a user

    Allows a user to block another user. The user can no longer receive any messages from the blocked user. Users aren't notified when they are blocked and blocked users can still send messages to the channel. But they can't see any messages from users who blocked them in the channel.

    A user can block other users in 1-to-1 group channels and notifications of their messages in 1-to-N group channels. You can choose whether or not users can see which users they have blocked in the channel UI.

    Sendbird application provides two blocking options: excluding blocked users when sending invitations and turning off push notifications from blocked users. The previous block modes are now deprecated and only available for customers who started using them before.

    • Excluding blocked users when sending invitations: determines whether or not to automatically exclude blocked users when inviting users to a new group channel. The value of this option can only be changed from Sendbird before integrating your Sendbird application to the client app. If you want to change the value, contact our sales team for further assistance. (Default: including)
    • Turning off push notifications from blocked users: determines whether or not to send push notifications for messages that a blocked user sent in a 1-to-N group channel where they are both members. The value of this option can be set individually per channel. If you want to use this option, contact our sales team for further assistance. (Default: off)

    1-to-1 group channel

    Channel listPush notificationsMessages

    A user's channel list will not be updated or rearranged from the blocked user's messages.

    A user will not be notified that the blocked user sent a message.

    New messages sent from the blocked user will not be delivered to the channel, but are saved in the database and displayed in the blocked user's channel view. The blocked user is not aware of their blocked status. A user can only see the messages that the blocked user has sent before being blocked.

    * If the blocked user is unblocked, a user can see all the messages except those that were sent during the blocking period.

    1-to-N group channel

    Channel listPush notificationsMessages

    A user's channel list will be updated and rearranged from a blocked user's message.

    A user will be notified of messages sent by blocked users if push notifications from the blocked users are turned on. Otherwise, they will not be notified.

    All messages from blocked users are delivered to the channel. You can choose whether a user can view which users they have blocked in the UI of the channel.


    HTTP request

    POST https://api-{application_id}.sendbird.com/v3/users/{user_id}/block
    

    Parameters

    The following table lists a parameter that this action supports.

    Required
    Parameter nameTypeDescription

    user_id

    string

    Specifies the unique ID of the user.


    Request body

    The following table lists the properties of an HTTP request that this action supports.

    Optional
    Property nameTypeDescription

    target_id

    string

    Specifies the ID of the user to be blocked.

    user_ids[]

    array of strings

    Specifies an array of IDs of all the users to block. This property can be used interchangeably with the users[] property below when blocking multiple users at once.

    users[]

    array of objects

    Specifies an array of IDs of all users to block. This property can be used interchangeably with the user_ids[] property above when blocking multiple users at once.

    {
        "target_id": "Tom"
    }
    

    Response

    If successful, this action returns the blocked user resource in the response body.

    {
        "user_id": "Tom",
        "nickname": "MissionImpossible",
        "profile_url": "https://sendbird.com/main/img/profiles/profile_42_512px.png",
        "is_online": false,
        "last_seen_at": 2001604082551,
        "metadata": {
            "location": "Los Angeles",
            "marriage": "Y"
        }
    }
    

    Block other users

    A user can block specific users if they don't want to receive any messages in 1-to-1 group channels and notifications of their messages in 1-to-N group channels. You can choose whether or not users can view which users they have blocked in the channel UI.

    Sendbird application provides two blocking options: including or excluding blocked users when sending invitations, and turning on or off push notifications from blocked users. The previous block modes are now deprecated and only supported for customers who started using them before.

    • Including or excluding blocked users when sending invitations: determines whether or not to automatically filter out blocked users when a user invites a group of users to a new group channel. The value of this option can be adjusted only from our side before integrating your Sendbird application to the client app. If you want to change the value, contact our sales team for further assistance. (Default: including)
    • Turning on or off push notifications from blocked users: determines whether or not to send push notifications to a user for messages that the blocked users sent in a specific 1-to-N group channel where they are members together. The value of this option can be set individually per channel. If you want to use this option, contact our sales team for further assistance. (Default: off)

    1-to-1 group channel

    Channel listPush notificationsMessages

    A user's channel list will not be updated or rearranged from the blocked user's messages.

    A user will not be notified that the blocked user sent a message.

    New messages sent from the blocked user will not be delivered to the channel, but are saved in the database and displayed in the blocked user's channel view. The blocked user is not aware of their blocked status. A user can only see the messages that the blocked user has sent before being blocked.

    * If the blocked user is unblocked, a user can see all the messages except those that were sent during the blocking period.

    1-to-N group channel

    Channel listPush notificationsMessages

    For a blocked user's message, a user's channel list will be updated and rearranged.

    A user will be notified of messages sent by blocked users if push notifications from blocked users is turned on. Otherwise, they will not be notified.

    All messages from blocked users are delivered to the channel. You can choose whether a user can view which users they have blocked in the UI of the channel.

    In the case of an error, an error object is returned. A detailed list of error codes is available here.