Send a message
You can use this action to send a text message, a file message, or an admin message to a specific channel. Sendbird Chat SDKs and the platform API allows you to upload any type of files in messages to the Sendbird server. See Message Overview for more information on each message type.
Messages are sent between client devices running the Sendbird Chat SDK or UIKit as well as programmatically from businesses to their customers. For instance, a delivery app can automatically send a message like "Arriving in one minute!" on behalf of a delivery driver.
HTTP request
Parameters
The following table lists the parameters that this action supports.
Required
Parameter name | Type | Description |
---|---|---|
channel_type | string | Specifies the type of the channel. Acceptable values are |
channel_url | string | Specifies the URL of the target channel. |
Sendbird Chat SDK supports dynamic partitioning open channels where an admin message is sent to all subchannels if the subchannel type is set to Multiple. See Open channel to learn more about how dynamic partitioning open channels work.
Request body
The following tables list the properties of an HTTP request that this action supports for sending a text message, file message, and admin message.
List of properties for sending a text message
Properties
Required | Type | Description |
---|---|---|
message_type | string | Specifies the type of the message. The value of |
user_id | string | Specifies the user ID of the sender. |
message | string | Specifies the content of the message. |
Optional | Type | Description |
---|---|---|
custom_type | string | Specifies a custom message type used for message grouping. The length is limited to 128 characters. |
data | string | Specifies additional message information. This property serves as a container for a long text of any type of characters which can also be a JSON-formatted string like |
send_push | boolean | Determines whether to send a push notification of the message to the channel members. This property only applies to group channels. (Default: |
push_message_template | string or object | Specifies the content of a push notification customized for the message. This property only applies to group channels. |
push_message_template.title | string | Specifies the title of the custom push notification template. You can customize the title using the variables |
push_message_template.body | string | Specifies the body of the custom push notification template. You can customize the body using the variables |
mention_type | string | Specifies whether to mention specific users or all users in the channel. Acceptable values are |
mentioned_user_ids[] | array of strings | Specifies an array of IDs of the users to mention in the message. This property is used only when |
is_silent | boolean | Determines whether to send a message without updating some of the following channel properties. If set to |
mark_as_read | boolean | Determines whether to mark the message as read for the sender. If set to |
sorted_metaarray | array of objects | Specifies an array of JSON objects consisting of key-values items that store additional message information to be used for classification and filtering. Items are saved and returned in the order they've been specified. More details on what can be stored in this field are available here. |
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 the Sendbird server. If specified, the server sets the time of message creation as the property value. |
poll_id | integer | Specifies the unique ID of the poll to be included in a message. To use this property, the polls feature should be turned on in Settings > Chat > Features on Sendbird Dashboard. |
include_poll_details | boolean | Determines whether to include all properties of a poll resource with a full list of options in the results. To use this property, the polls feature should be turned on in Settings > Chat > Features on Sendbird Dashboard. |
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 the Sendbird server. If specified, the server performs a duplicate check using the property value. |
apns_bundle_id | string | Specifies the bundle ID of the client app in order to send a push notification to iOS devices. You can find this in Settings > Chat > Push notifications > Push notification credentials on Sendbird Dashboard. |
apple_critical_alert_options | object | Specifies options that support Apple critical alerts and checks whether the message is a critical alert. |
sound | string | Specifies the name of a sound file that is used for critical alerts. |
volume | float | Specifies the volume of the critical alert sound. The volume ranges from 0.0 to 1.0, which indicates silent and full volume, respectively. (Default: |
| array of objects | (Deprecated) Specifies an array of JSON objects consisting of key-values items to store additional message information. |
List of properties for sending a file message
Properties
Required | Type | Description |
---|---|---|
message_type | string | Specifies the type of the message. The value of |
user_id | string | Specifies the user ID of the sender. |
file | string | When sending a single file with a message, specifies the data of the file to upload to the Sendbird server in raw binary format. When sending a request containing a file, change the value of the |
files | array of objects | When sending a single file through its URL or sending multiple files, specifies the data of files to upload to the Sendbird server either in raw binary format or by their location. When sending a request containing files, change the value of the |
files.url | string | Specifies the URL of the file hosted on the server of your own or other third-party companies. To send a single file through URL, use this field instead of |
| string | (Deprecated) Specifies the URL of the file hosted on the server of your own or other third-party companies. If this |
Optional | Type | Description |
---|---|---|
file.name | string | If the |
file.size | int | If the |
file.type | string | If the |
files.file_name | string | If the |
files.file_size | int | If the |
files.file_type | string | If the |
thumbnails | array of strings or objects | If the |
thumbnail1 | string | If the |
custom_type | string | Specifies a custom message type used for message grouping. The length is limited to 128 characters. |
data | string | Specifies additional message information. This property serves as a container for a long text of any type of characters which can also be a JSON-formatted string like |
require_auth | boolean | Determines whether to require an authentication key to verify if the file is being properly accessed. Only the user who uploaded the file or users who are in the channel where the file was uploaded should have access. The authentication 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. If set to |
send_push | boolean | Determines whether to send a push notification of the message to the channel members. This property only applies to group channels. (Default: |
mention_type | string | Specifies whether to mention specific users or all users in the channel. Acceptable values are |
mentioned_user_ids[] | array of strings | Specifies an array of IDs of the users to mention in the message. This property is used only when |
is_silent | boolean | Determines whether to send a message without updating some of the following channel properties. If set to |
mark_as_read | boolean | Setting |
sorted_metaarray | array of objects | Specifies an array of JSON objects consisting of key-values items that store additional message information to be used for classification and filtering. Items are saved and returned in the order they've been specified. More details on what can be stored in this field are available here. |
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 the 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 the Sendbird server. If specified, the server performs a duplicate check using the property value. |
apns_bundle_id | string | Specifies the bundle ID of the client app in order to send a push notification to iOS devices. You can find this in Settings > Chat > Push notifications > Push notification credentials on the Sendbird Dashboard. |
apple_critical_alert_options | object | Specifies options that support Apple critical alerts and checks whether the message is a critical alert. |
sound | string | Specifies the name of a sound file that is used for critical alerts. |
volume | float | Specifies the volume of the critical alert sound. The volume ranges from |
| string | (Deprecated) Specifies additional data to store for the specified file in the message. |
| array of objects | (Deprecated) Specifies an array of JSON objects consisting of key-values items to store additional message information. |
List of properties for sending an admin message
Properties
Required | Type | Description |
---|---|---|
message_type | string | Specifies the type of the message. The value of |
message | string | Specifies the content of the message. |
Optional | Type | Description |
---|---|---|
custom_type | string | Specifies a custom message type used for message grouping. The length is limited to 128 characters. |
data | string | Specifies additional message information. This property serves as a container for a long text of any type of characters which can also be a JSON-formatted string like |
send_push | boolean | Determines whether to send a push notification of the message to the channel members. Unlike text and file messages, a push notification of an admin message isn't sent by default. This property only applies to group channels. (Default: |
push_message_template | string or object | Specifies the content of a push notification customized for the message. This property only applies to group channels. |
push_message_template.title | string | Specifies the title of the custom push notification template. You can customize the title using the variable |
push_message_template.body | string | Specifies the body of the custom push notification template. You can customize the body using the variable |
mention_type | string | Specifies whether to mention specific users or all users in the channel. Acceptable values are |
mentioned_user_ids[] | array of strings | Specifies an array of IDs of the users to mention in the message. This property is used only when |
is_silent | boolean | Determines whether to send a message without updating some of the following channel properties. If set to |
sorted_metaarray | array of objects | Specifies an array of JSON objects consisting of key-values items that store additional message information to be used for classification and filtering. Items are saved and returned in the order they've been specified. More details on what can be stored in this field are available here. |
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 the 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 the Sendbird server. If specified, the server performs a duplicate check using the property value. |
apns_bundle_id | string | Specifies the bundle ID of the client app in order to send a push notification to iOS devices. You can find this in Settings > Chat > Push notifications > Push notification credentials on Sendbird Dashboard. |
| array of objects | (Deprecated) Specifies an array of JSON objects consisting of key-values items to store additional message information. |
Responses
If successful, this action returns a message resource in the response body.
Note: Sendbird Chat SDK supports the generation of a URL link preview within a message if the given URL has Open Graph (OG) tags, which are included as an
og_tag
property in your response. This feature is turned on by default for Sendbird applications. If this isn't available for your Sendbird application, contact our support team to enable the feature.
Error
In the case of an error, an error object like below is returned. See the error codes section for more details.