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

    Update a user

    Copy link

    You can update information about a user using this API. In addition to changing a user's nickname or profile image, you can issue a new access token for the user. The new access token replaces the previous one as the necessary token for authentication.

    You can also deactivate or reactivate a user using this API request. If the leave_all_when_deactivated is set to true, a user leaves all joined group channels and becomes deactivated.

    Note: Issuing session tokens through the /users/{user_id} endpoint is now deprecated and it's replaced with /users/{user_id}/token endpoint for greater efficiency. For those who are currently using the old endpoint, you can start issuing tokens using the new endpoint.


    HTTP request

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

    Parameters

    Copy link

    The following table shows a parameter that this action supports.

    Required
    Parameter nameTypeDescription

    user_id

    string

    Specifies the unique ID of the user.


    Request body

    Copy link

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

    Optional
    Property nameTypeDescription

    nickname

    string

    Specifies the user's nickname. The length is limited to 80 characters.

    profile_url

    string

    Specifies the URL of the user's profile image. If left empty, no profile image is set for the user. The length is limited to 2,048 characters.

    * The domain filter filters out the request if the value of this property matches the filter's domain set.

    profile_file

    file

    Uploads the file of the user's profile image. Acceptable image file types are limited to JPG (.jpg), JPEG (.jpeg), or PNG (.png) of up to 5 MB.

    issue_access_token

    boolean

    Determines whether to revoke the existing access token and create a new one for the user. If true, an opaque string token is issued and provided upon creation. The token is required each time the user logs in. If false, no access tokens will be issued or required when the user logs in. (Default: false)

    is_active

    boolean

    Determines whether to activate or deactivate the user within the Sendbird application.

    * Monthly Active Users (MAU) isn't calculated based on this property.

    last_seen_at

    long

    Specifies the time the user went offline in Unix milliseconds format to indicate when the user was last connected to the Sendbird server.

    * This property isn't updated by default. To update last_seen_at, visit this page and contact us on Sendbird Dashboard.

    discovery_keys[]

    array of strings

    Specifies an array of unique keys of the user, which is provided to Sendbird server when searching for friends. The unique key acts as an identifier for users' friends to find each other. The server uses discovery keys to identify and match the user with other users.

    preferred_languages[]

    array of strings

    Specifies an array of one or more language codes to translate notification messages to preferred languages. Up to four languages can be set for the user. If messages are sent in one of the preferred languages, notification messages won't be translated. If messages are sent in a language other than the preferred languages, notification messages will be translated into the first language in the array. Messages translated into other preferred languages will be provided in the sendbird property of the notification message payload.

    leave_all_when_deactivated

    boolean

    Determines whether the user leaves all joined group channels upon deactivation. This property should be specified in conjunction with the is_active property above. (Default: true)

    issue_session_token

    boolean

    (Deprecated) Determines whether to add a new session token for the user. If true, an opaque string token is issued and provided upon creation, which should be passed whenever the user logs in. If false, a session token is not required when the user logs in. (Default: false)

    * This property is deprecated and we encourage you to issue session tokens with the new /users/{user_id}/token endpoint for all Sendbird applications.

    session_token_expires_at

    long

    (Deprecated) Specifies the time for the issued session token to expire in Unix milliseconds format. The length should be 13. If not specified and the issue_session_token property above is true, the value of this property is set to the sum of the current timestamp and 604800000 by default, meaning 7 days starting from the current timestamp.

    * This property is deprecated and we encourage you to use the expires_at property for all Sendbird applications when issuing session tokens with the new /users/{user_id}/token endpoint.

    Note: If you want to upload a profile picture by passing an image file, refer to Multipart requests.


    Responses

    Copy link

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

    {
        "user_id": "Jacob",
        "nickname": "Asty",
        "profile_url": "https://sendbird.com/main/img/profiles/profile_05_512px.png",
        "access_token": "07a0ccf6d3e801223e65b06b6066352e0512b43c",
        "is_online": false,
        "last_seen_at": -1,
        "discovery_keys": ["123-456-7890", "654-321-0987"],
        "preferred_languages": [],
        "has_ever_logged_in": false,
        "metadata": {
            "font_preference": "times new roman",
            "font_color": "gray" 
        }
    }
    

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

    {
        "message": "\"issue_access_token\" must be a boolean.",
        "code": 400104,
        "error": true
    }