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

    Reply to a message


    Replies to a specific message in a channel. You can only reply to text and file messages, not admin messages.

    Note: Sending reply messages works much like sending regular messages to a channel except replies require an additional parent_message_id property.


    HTTP request

    POST https://api-{application_id}.sendbird.com/v3/{channel_type}/{channel_url}/messages
    

    Parameters

    The following table lists the parameters that this action supports.

    Required
    Parameter nameTypeDescription

    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.


    Request body

    The following tables list the properties of an HTTP request that this action supports for a text message, file message, and admin message.

    List of properties for text message

    Properties
    RequiredTypeDescription

    message_type

    string

    Specifies the type of the message. The value of MESG represents a text message.

    user_id

    string

    Specifies the user ID of the sender.

    message

    string

    Specifies the content of the message.

    parent_message_id

    long

    Specifies the unique ID of a message to add a reply to.

    OptionalTypeDescription

    custom_type

    string

    Specifies a custom message type used for message grouping. The length is limited to 128 characters.

    * Custom types are also used to segment metrics within Sendbird's Advanced analytics, which enables the sub-classification of data views.

    data

    string

    Specifies additional message information such as custom font size, font type, or JSON formatted string.

    send_push

    boolean

    Determines whether to send a push notification of the message to the channel members. This property only applies to group channels.

    If the value of the application attribute enable_push_for_replies is false, no push notifications are sent. If the value of the user attribute enable_push_for_replies is also false, the user doesn't receive any push notifications from replies. (Default: true)

    mention_type

    string

    Specifies the mentioning method that indicates which user gets a notification of the message. Acceptable values are users and channels. If set to users, only the users specified in the mentioned_user_ids property below get notified. If set to channels, all users in the channel get notified. (Default: users)

    mentioned_user_ids[]

    array of strings

    Specifies an array of one or more IDs of the users who get a notification of the message.

    mark_as_read

    boolean

    Determines whether to mark the message as read for the sender. If set to false, the sender's unread_count and read_receipt remain unchanged after the message is sent. (Default: true)

    sorted_metaarray

    array of objects

    Specifies an array of one or more JSON objects consisting of key-values items to store additional message information. Items are saved and returned in the order they've been specified.

    created_at

    long

    Specifies the time when the message was sent in Unix milliseconds format. This property can be used when migrating messages in other systems to Sendbird server. If specified, the server sets the time of message creation as the property value.

    dedup_id

    string

    Specifies a unique ID for the message created by another system. In general, this property is used to prevent the same message data from getting inserted when migrating messages from another system to Sendbird server. If specified, the server checks for duplicates using the property value.

    reply_to_channel

    boolean

    Determines whether to send the message as a reply to the channel. (Default: false)

    List of properties for file message

    Properties
    RequiredTypeDescription

    message_type

    string

    Specifies the type of the message. The value of FILE represents a file message.

    user_id

    string

    Specifies the user ID of the sender.

    parent_message_id

    long

    Specifies the unique ID of a message to add a reply to.

    root_message_id

    long

    (Deprecated) Reserved value. This must be the same as parent_message_id.

    file

    string

    Depending on the file upload method, this specifies the data of the file to upload to Sendbird server either in raw binary format or by the file's location. When sending a request containing a file, you must change the value of the content-type header to multipart/form-data; boundary = {your_unique_boundary_string} in the request.
    For code examples of HTTP multipart request and cURL, see how to send a file message. If this file property is specified, the url property is not required.

    * This property doesn't allow a converted base64-encoded string from a file as its value.

    url

    string

    Specifies the URL of the file hosted on the server of your own or other third-party companies. If this url property is specified, the file property is not required.

    OptionalTypeDescription

    file_name

    string

    If the file property is used for file upload, this property is automatically specified by Sendbird server. Otherwise, specify the name of the file directly.

    file_size

    int

    If the file property is used for file upload, this property is automatically specified by Sendbird server. Otherwise, specify the size of the file directly.

    file_type

    string

    If the file property is used for file upload, this property is automatically specified by Sendbird server. Otherwise, specify the media type of the file directly.

    thumbnails[]

    array of strings

    Specifies an array of one or more URLs of external thumbnail images that are generated from the image specified by the url property.

    * If you're using the auto-thumbnail generation feature, up to three thumbnails of the uploaded image or video file can be generated by specifying the width and height in an HTTP multipart request. For more information on how to make the request, refer to Request body and Response samples of sending a file message.

    custom_type

    string

    Specifies a custom message type used for message grouping. The length is limited to 128 characters.

    * Custom types are also used to segment metrics within Sendbird's Advanced analytics, which enables the sub-classification of data views.

    data

    string

    Specifies additional message information regarding the file in JSON format.

    require_auth

    boolean

    Determines whether the files and thumbnail images in a message are only accessible by users who are in the same channel. This property is only effective when using the share encrypted files feature. This feature encrypts any type of uploaded files and the automatically-generated thumbnail images with AES256, stores them securely in the Sendbird server, and only allows the users with access to share the files. You can use this property to restrict access to the files.

    If set to true, the files are uploaded first, then encrypted, and finally stored along with the thumbnail images which are encrypted as well. When accessing them, the parameter auth, which is specified with an encryption key of the user such as ?auth=RW5b2RIHaMdGV4eA==, should be added at the end of the file URLs. An encryption key managed internally by the Sendbird system is generated every time a user logs in to the Sendbird server and is valid for three days starting from the last login. The system mainly uses the key to check if a user is properly accessing the data of the application. (Default: false)

    send_push

    boolean

    Determines whether to send a push notification of the message to the channel members. This property only applies to group channels.

    If the value of the application attribute enable_push_for_replies is false, no push notifications are sent. If the value of the user attribute enable_push_for_replies is also false, the user doesn't receive any push notifications from replies. (Default: true)

    mention_type

    string

    Specifies the mentioning method that indicates which user gets a notification of the message. Acceptable values are users and channels. If set to users, only the users specified in the mentioned_user_ids property below get notified. If set to channels, all users in the channel get notified. (Default: users)

    mentioned_user_ids[]

    array of strings

    Specifies an array of one or more IDs of the users who get a notification of the message.

    mark_as_read

    boolean

    Determines whether to mark the message as read for the sender. If set to false, the sender's unread_count and read_receipt remain unchanged after the message is sent. (Default: true)

    sorted_metaarray

    array of objects

    Specifies an array of one or more JSON objects consisting of key-values items to store additional message information. Items are saved and returned in the order they've been specified.

    created_at

    long

    Specifies the time when the message was sent in Unix milliseconds format. This property can be used when migrating messages from another system to Sendbird server. If specified, the server sets the time of message creation as the property value.

    dedup_id

    string

    Specifies the unique message ID created by another system. In general, this property is used to prevent the same message data from getting inserted when migrating messages from another system to Sendbird server. If specified, the server checks for duplicates using the property value.

    reply_to_channel

    boolean

    Determines whether to send the message as a reply to the channel. (Default: false)


    Response

    If successful, this action returns a message resource in the response body.

    {
        "message_id": 1972,
        "type": "MESG",
        "is_silent": false,
        "parent_message_id": 1970,
        "custom_type": "Sports",
        "channel_url": "uefa_footballgroup_g_001",
        "user": {
            "user_id": "cindy123",
            "nickname": "Cindy_",
            "profile_url": "",
            "metadata": {}
        },
        "mention_type": "users",
        "mentioned_users": [],
        "is_removed": false,
        "message": "The game starts in an hour.",
        "translations": {},
        "data": "{\"font\":\"arial\"}",
        "created_at": 1590786264170,
        "updated_at": 0,
        "file": {},
        "message_survival_seconds": -1
        "parent_message_info": {  // This replaces `parent_message_text`.
            "message": "https://football.com/example-image.jpg",
            "user": {
                "user_id": "user id",
                "nickname": "nickname",
                "profile_url": "url",
                "metadata": {},
                },
            "type": "FILE",  // The value can be MESG or FILE.
            "file": {  // This part is included only when the message type is FILE.
                "name": "filename.jpg",
                "type": "image/jpg",
                "url": "https://url",
                "require_auth": "false"
            },
            "ts": 1544421761159
        },
        "is_reply_to_channel": true,
    }
    

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