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

    Update metadata

    Updates existing items or adds new items to the metadata of a user.


    HTTP request

    // When updating multiple items by their keys and adding new items to the user metadata
    PUT https://api-{application_id}.sendbird.com/v3/users/{user_id}/metadata
    
    // When updating a specific item by its key in the user metadata
    PUT https://api-{application_id}.sendbird.com/v3/users/{user_id}/metadata/{key}
    

    Parameters

    The following table lists the parameters that this action supports.

    Parameters
    RequiredTypeDescription

    user_id

    string

    Specifies the unique ID of a user.

    OptionalTypeDescription

    key

    string

    Specifies the key of a metadata item. If not specified, all items of the metadata are updated. If specified, only the specified item is updated. Urlencoding a key is recommended.


    Request body

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

    Properties
    RequiredTypeDescription

    metadata

    nested object

    Specifies a JSON object that stores key-value items. The key must not have a comma (,) and its length is limited to 128 characters. The value must be a string and its length is limited to 190 characters. This property can have up to 5 items.

    OptionalTypeDescription

    upsert

    boolean

    Determines whether to add new items in addition to updating existing items. If true, the new key-value items are added when the keys don't exist in the metadata property. The existing items are updated with new values when there are already items with the same keys. If false, only the item with a key that you specify is updated. (Default: false)

    // When updating existing items by their keys and adding new items to the metadata
    {
        "metadata": {
            "location": "Philadelphia", // Updated
            "hobbies": "movie,music"    // Added
        },
        "upsert": true
    }
    
    // When updating a specific item by its key
    {
        "value": "Philadelphia"
    }
    

    Response

    If successful, this action returns the updated and added items in the metadata in the response body.

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