Documentation Index

Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt

Use this file to discover all available pages before exploring further.

Get Thread Messages

Prev Next
Get
/api/v1/chat.getThreadMessages

Get thread messages.

Use aroundId to load the replies surrounding a specific message. When you provide aroundId, the server calculates the page offset around that message instead of using the requested offset, and returns the calculated value in the response. Hidden message-history records are excluded from the returned messages and pagination totals.

Changelog

Version Description
8.8.0 Added the aroundId parameter and excluded hidden message-history records from results and pagination totals
1.2.0 Remove tlm field which is not supported
1.1.0 Update example results - original message in thread is not returned
1.0.0 Added
Header parameters
X-Auth-Token
stringRequired

The authToken of the authenticated user.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The userId of the authenticated user.

ExamplerbAXPnMktTFbNpwtJ
Query parameters
offset
integer

Number of items to "skip" in the query, i.e. requests return count items, skipping the first offset items. Refer to the official documentation to learn more.

Example50
count
integer

The number of items to return. Refer to the official documentation to learn more.

Example50
sort

List of fields to order by, and in which direction. This is a JSON object, with properties listed in desired order, with values of 1 for ascending, or -1 for descending. For example, { "value": -1, "_id": 1 }. Refer to the official documentation to learn more.

query

This parameter allows you to use MongoDB query operators to search for specific data. For example, to query users with a name that contains the letter "g": query={ "name": { "$regex": "g" }}. Refer to the official documentation to learn more.

fields
string

This parameter accepts a JSON object with properties that have a value of 1 or 0 to include or exclude them in the response. For example, to only retrieve the usernames of users: fields={ "username": 1 }. Refer to the official documentation to learn more.

tmid
stringRequired

The thread message ID.

Example7aDSXtjMA3KPLxLjt
aroundId
string

The ID of the thread's main message or one of its replies. The endpoint returns a page of replies surrounding this message. When you provide this parameter, the server calculates the page offset and ignores the requested offset value. The message must belong to the thread specified by tmid.

ExampleGfhiiJjcjKFyYMuMY
Responses
200

OK

Example
{
  "messages": [
    {
      "_id": "gcGai9bRREqokjyPc",
      "rid": "GENERAL",
      "msg": "Test",
      "ts": "2019-04-08T13:15:52.017Z",
      "u": {
        "_id": "p4a8YxvLQEHmiBKTS",
        "username": "marc.dev",
        "name": "Marc Dev"
      },
      "_updatedAt": "2019-04-08T14:40:27.789Z",
      "mentions": [],
      "channels": [],
      "replies": [
        "p4a8YxvLQEHmiBKTS"
      ],
      "tcount": 5,
      "tlm": "2019-04-08T14:40:27.724Z"
    },
    {
      "_id": "GfhiiJjcjKFyYMuMY",
      "rid": "GENERAL",
      "tmid": "gcGai9bRREqokjyPc",
      "msg": "This is a test!",
      "ts": "2019-04-08T13:20:22.238Z",
      "u": {
        "_id": "p4a8YxvLQEHmiBKTS",
        "username": "marc.dev",
        "name": "Marc Dev"
      },
      "_updatedAt": "2019-04-08T13:20:22.265Z",
      "mentions": [],
      "channels": []
    }
  ],
  "count": 2,
  "offset": 0,
  "total": 2,
  "success": true
}
Expand All
object
messages
Array of object
object
_id
string
rid
string
msg
string
ts
string
u
object
_id
string
username
string
name
string
_updatedAt
string
mentions
Array of object
object
channels
Array of object
object
replies
Array of string
string
tcount
integer
tlm
string
tmid
string
count
integer

The number of visible replies returned in this response.

offset
integer

The starting offset of the returned page. When you provide aroundId, this is the offset calculated by the server.

total
integer

The total number of visible replies in the thread. Hidden message-history records are excluded.

success
boolean
400

Bad Request

Missing parameter
{
  "success": false,
  "error": "The required \"tmid\" query param is missing. [error-invalid-params]",
  "errorType": "error-invalid-params"
}
Invalid Message
{
  "success": false,
  "error": "Invalid Message [error-invalid-message]",
  "errorType": "error-invalid-message"
}
Invalid aroundId
{
  "success": false,
  "error": "The provided \"aroundId\" does not belong to the thread [error-invalid-message]",
  "errorType": "error-invalid-message"
}
object
success
boolean
error
string
errorType
string
401

Unauthorized

Authorization Error
{
  "status": "error",
  "message": "You must be logged in to do this."
}
object
status
string
message
string