List messages
You can retrieve a list of past messages of a specific channel with this API.
By default, this action returns a list of messages in the order they were created. Replies in threaded messages are also listed in the chronological order of their creation like other messages, not grouped with their parent messages.
HTTP request
Parameters
The following table lists the parameters that this action supports.
Note: The
include_parent_message_info
,include_thread_info
, andinclude_reply_type
parameters are related to Sendbird's message threading feature. To learn more, see the message threading page.
Parameters
Required | Type | Description |
---|---|---|
channel_type | string | Specifies the type of the channel. Acceptable values are |
channel_url | string | Specifies the URL of the channel. |
message_ts | long | Specifies the timestamp to be the reference point of the query in Unix milliseconds. Either this or the |
message_id | long | Specifies the unique ID of the message to be the reference point of the query. Either this or the |
Optional | Type | Description |
---|---|---|
prev_limit | int | Specifies the number of previously sent messages to retrieve before |
next_limit | int | Specifies the number of sent messages to retrieve after |
include | boolean | Determines whether to include messages sent exactly on the specified |
reverse | boolean | Determines whether to sort the results in reverse chronological order. If set to |
sender_id | string | Restricts the search scope to only retrieve messages sent by the user with the specified ID. |
sender_ids | string | Restricts the search scope to only retrieve messages sent by one or more users with the specified IDs listed in a comma-separated string. |
operator_filter | string | Restricts the search scope to only retrieve messages sent by operators or non-operator users of the channel. Acceptable values are |
message_type | string | Specifies a message type to retrieve. Acceptable values are |
custom_types | string | Specifies a comma-separated string of one or more custom message types to retrieve. The value set to this parameter can serve as a filter as follows: |
including_removed | boolean | Determines whether to include messages removed from the channel in the results. (Default: |
include_parent_message_info | boolean | Determines whether to include information of the parent message in the results. (Default: |
include_thread_info | boolean | Determines whether to include thread information in the results. (Default: |
include_reply_type | string | Specifies the type of message to include in the results. |
include_reactions | boolean | Determines whether to include reactions added to messages in the channel in the results. (Default: |
include_poll_details | boolean | Determines whether to include all properties of a poll resource with a full list of options in the results. If set to |
with_sorted_meta_array | boolean | Determines whether to include the |
show_subchannel_messages_only | boolean | Determines whether to retrieve messages from a subchannel where the user specified in the |
user_id | string | Specifies the unique ID of a user to restrict the scope to the user's subchannel. Messages in the user's subchannel are retrieved. This parameter should be specified in conjunction with the |
| string | (Deprecated) Specifies the custom message type to filter the messages with the corresponding custom type. If not specified, all messages are retrieved. |
| boolean | (Deprecated) Determines whether to include the |
| boolean | (Deprecated) Determines whether to include replies as messages in the results. If set to |
| boolean | (Deprecated) Determines whether to include the text of parent messages as the |
Note : To access an encrypted file in a file message, you can use an
HTTP GET
request containing anApi-Token
header specified with either your master API token or secondary API token regardless of therequire_auth
parameter. The URL of the encrypted file you want to retrieve should be specified in the request.
Response
If successful, this action returns a list of message resources that match the specified parameters 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 as well. This feature is turned on by default for Sendbird applications. To enable this functionality, visit this page.
List of response properties
Property name | Type | Description |
---|---|---|
messages[] | array of objects | An array of messages that match the specified optional parameters. |
In the case of an error, an error object is returned. A detailed list of error codes is available here.