List user's chat messages
GET {{baseUrl}}/chat/users/:userId/messages?to_contact=<email>&to_channel=<string>&date=<date>&from=<dateTime>&to=<dateTime>&page_size=10&next_page_token=<string>&include_deleted_and_edited_message=<boolean>&search_type=file&search_key=<string>&exclude_child_message=false&download_file_formats=audio/mp4
Searches chat messages or shared files between a user and an individual contact or a chat channel. For user-level apps, pass
the
me
value
instead of the
userId
parameter.
Note: For an account-level OAuth app , this API can only be used on behalf of a user who is assigned with a role that has the View or Edit permission for Chat Messages .
Scopes:
chat_message:read
,
chat_message:read:admin
Rate Limit Label
:
Medium
Request Params
| Key | Datatype | Required | Description |
| to_contact
| string | | This field allows you to query by the email address or user ID or member ID of a chat contact with whom the user communicated. The API only returns messages sent and/or received between the user and the queried contact.
Note:
- You must provide either the
to_contact
or theto_channel
query parameter. - When you call the
search_key
andsearch_type
query parameters, this query parameter is optional and not required. | |to_channel
| string | | This field queries by the channel ID of a channel in which the user had chat conversations. The API only returns messages sent and/or received by the user in the queried channel.
Note:
- You must provide either the
to_contact
or theto_channel
query parameter. - When you call the
search_key
andsearch_type
query parameters, this query parameter is optional and not required. | |date
| string | | The query date from which to retrieve the chat messages. This value defaults to the current date.
Note: If you do not provide the date
or from
query parameters, the API defaults to the date
query parameter. |
| from
| string | | The query start date, in yyyy-MM-dd'T'HH:mm:ss'Z'
format.
Note: If you provide both the date
and from
query parameters, the API queries using the date
value. |
| to
| string | | The query end date, in yyyy-MM-dd'T'HH:mm:ss'Z'
format. This value defaults to the current date. |
| page_size
| number | | The number of records returned with a single API call. |
| next_page_token
| string | | The next page token paginates through a large set of results. A next page token is returned whenever the set of available results exceeds the current page size. This token's expiration period is 15 minutes. |
| include_deleted_and_edited_message
| string | | Optional <br>
Set the value of this field to true
to include edited and deleted messages in the response. |
| search_type
| string | | The type of search:
message
— Search messages.file
— Search files.
Note:
- If you use this query parameter, you must also include a
search_key
query parameter value. - The
to_contact
and theto_channel
query parameters are not required when you query this parameter. If you do not call them, the API returns all contact and channel messages that match thesearch_type
query. - If you query this parameter, you cannot also query the
include_deleted_and_edited_message
parameter. This query parameter does not support the return of deleted or updated messages. | |search_key
| string | | The messages or files query string, up to 256 characters.
Note:
- If you use this query parameter, you must also include a
search_type
query parameter value. - The
to_contact
and theto_channel
query parameters are not required when you query this parameter. If you do not call them, the API returns all contact and channel messages that match thesearch_key
query. - If you query this parameter, you cannot also query the
include_deleted_and_edited_message
parameter. This query parameter does not support the return of deleted or updated messages. | |exclude_child_message
| boolean | | This parameter is used to exclude returning all child messages in a chat, leaving only the parent messages. | |download_file_formats
| string | | This field returns the download URL in the specified format for different types of files. Currently, we only support the download URL in the mp4 format for audio files. If this parameter is not specified, will return the download URL of the file in its default format. |
HEADERS
| Key | Datatype | Required | Description |
| Accept
| string | | |
RESPONSES
status: OK
{"date":"\u003cdate\u003e","from":"\u003cdateTime\u003e","messages":[{"bot_message":{},"date_time":"\u003cdateTime\u003e","files":[{"download_url":"\u003cstring\u003e","file_id":"\u003cstring\u003e","file_name":"\u003cstring\u003e","file_size":"\u003cinteger\u003e"},{"download_url":"\u003cstring\u003e","file_id":"\u003cstring\u003e","file_name":"\u003cstring\u003e","file_size":"\u003cinteger\u003e"}],"rich_text":[{"start_position":"\u003cinteger\u003e","end_position":"\u003cinteger\u003e","format_type":"Strikethrough","format_attr":"\u003cstring\u003e"},{"start_position":"\u003cinteger\u003e","end_position":"\u003cinteger\u003e","format_type":"BackgroundColor","format_attr":"\u003cstring\u003e"}],"download_url":"\u003cstring\u003e","file_id":"\u003cstring\u003e","file_name":"\u003cstring\u003e","file_size":"\u003cinteger\u003e","id":"\u003cstring\u003e","message":"\u003cstring\u003e","reply_main_message_id":"\u003cstring\u003e","reply_main_message_timestamp":"\u003clong\u003e","sender":"\u003cstring\u003e","sender_member_id":"\u003cstring\u003e","sender_display_name":"\u003cstring\u003e","status":"Deleted","timestamp":"\u003clong\u003e","at_items":[{"at_contact":"\u003cstring\u003e","at_contact_member_id":"\u003cstring\u003e","at_type":2,"end_position":"\u003cinteger\u003e","start_position":"\u003cinteger\u003e"},{"at_contact":"\u003cstring\u003e","at_contact_member_id":"\u003cstring\u003e","at_type":1,"end_position":"\u003cinteger\u003e","start_position":"\u003cinteger\u003e"}]},{"bot_message":{},"date_time":"\u003cdateTime\u003e","files":[{"download_url":"\u003cstring\u003e","file_id":"\u003cstring\u003e","file_name":"\u003cstring\u003e","file_size":"\u003cinteger\u003e"},{"download_url":"\u003cstring\u003e","file_id":"\u003cstring\u003e","file_name":"\u003cstring\u003e","file_size":"\u003cinteger\u003e"}],"rich_text":[{"start_position":"\u003cinteger\u003e","end_position":"\u003cinteger\u003e","format_type":"FontColor","format_attr":"\u003cstring\u003e"},{"start_position":"\u003cinteger\u003e","end_position":"\u003cinteger\u003e","format_type":"Strikethrough","format_attr":"\u003cstring\u003e"}],"download_url":"\u003cstring\u003e","file_id":"\u003cstring\u003e","file_name":"\u003cstring\u003e","file_size":"\u003cinteger\u003e","id":"\u003cstring\u003e","message":"\u003cstring\u003e","reply_main_message_id":"\u003cstring\u003e","reply_main_message_timestamp":"\u003clong\u003e","sender":"\u003cstring\u003e","sender_member_id":"\u003cstring\u003e","sender_display_name":"\u003cstring\u003e","status":"Edited","timestamp":"\u003clong\u003e","at_items":[{"at_contact":"\u003cstring\u003e","at_contact_member_id":"\u003cstring\u003e","at_type":2,"end_position":"\u003cinteger\u003e","start_position":"\u003cinteger\u003e"},{"at_contact":"\u003cstring\u003e","at_contact_member_id":"\u003cstring\u003e","at_type":1,"end_position":"\u003cinteger\u003e","start_position":"\u003cinteger\u003e"}]}],"next_page_token":"\u003cstring\u003e","page_size":10,"to":"\u003cdateTime\u003e"}