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 of a channel's metadata by their keys or adds new items to the metadata.

    Note: See this page to learn more about differences among data properties.


    HTTP request

    // When updating existing items of a channel metadata by their keys or adding new items to the metadata
    PUT https://api-{application_id}.sendbird.com/v3/{channel_type}/{channel_url}/metadata
    
    // When updating a specific item of a channel metadata by its key
    PUT https://api-{application_id}.sendbird.com/v3/{channel_type}/{channel_url}/metadata/{key}
    

    Parameters

    The following table lists the parameters that this action supports.

    Parameters
    RequiredTypeDescription

    channel_type

    string

    Specifies the type of the channel. Acceptable values are open_channels and group_channels.

    channel_url

    string

    Specifies the URL of the target channel.

    OptionalTypeDescription

    key

    string

    Specifies the key of the metadata item. If not specified, the items in the metadata property are updated. If specified, only the item that matches the parameter value 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 has the key-value items. A key can't contain a comma (,) and its length is limited to 128 characters. A 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 set to true, new key-value items in the metadata property are added when there are no existing items with the keys. If there are already items with the keys, the existing items are updated with the new values. If set to false, only the items with keys that match the ones you specified are updated. (Default: false)

    // When updating existing items by their keys and adding new items to the metadata
    {
        "metadata": {
            "background_image": "https://sendbird.com/main/img/bg/theme_018.png",   // Updated
            "text_size": "small",   // Updated
            "text_color": "purple"  // Added
        },
        "upsert": true
    }
    
    // When updating a specific item by its key
    {
        "value": "https://sendbird.com/main/img/bg/theme_018.png"
    }
    

    Response

    If successful, this action returns the updated or 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.