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

    Update metadata

    Copy link

    You can update an existing metadata or add a new metadata to a user. Metadata stores additional user information such as their preference settings.

    Note: Do not use PII (Personally Identifiable Information) such as user email address, legal name, or phone number for data security and privacy reason.


    HTTP request

    Copy link
    // 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

    Copy link

    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

    Copy link

    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.

    * Do not use PII (Personally Identifiable Information) such as user email address, legal name, or phone number as it could jeopardize data security and privacy.

    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": {
            "font_preference": "times new roman",   // Updated
            "font_color": "black"   // Added
        },
        "upsert": true
    }
    
    // When updating a specific item by its key
    {
        "value": "gray"
    }
    

    Responses

    Copy link

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

    {
        "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": "\"User\" not found.",
        "code": 400201,
        "error": true
    }