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

    Update metadata

    This action updates key-value items used to store additional information about a channel. Values of existing items are updated and new items can be created when there no existing items with the keys.

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


    HTTP request

    // Updates 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
    
    // Updates 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. URL encoding 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. The 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.

    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.

    Error

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

    {
        "message": "\"Channel\" not found.",
        "code": 400201,
        "error": true
    }