Get Room History

Prev Next
Get
/api/v1/rooms.history

Returns the message history of a room of any type, with cursor-based pagination. Hidden system messages are excluded.

When the Allow Anonymous Read (Accounts_AllowAnonymousRead) setting is enabled, public channels can be read without authentication.

This endpoint replaces the deprecated loadHistory, loadNextMessages, and loadSurroundingMessages Realtime API methods, which remain available until 9.0.0.

Permission required: preview-c-room (only to read a public channel you have not joined)

Changelog

Version Description
8.9.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
roomId
stringRequired

The room ID. You must have access to the room.

Example6GFJ3tbmHiyHbahmC
count
integer

The number of messages to return. The default is 20. The value is capped by the Max Record Amount (API_Upper_Count_Limit) setting.

Minimum1
Default20
Example20
previous
string

The cursor.previous value from a previous response. Returns the messages older than that position. If cursor.previous is null, there are no older messages. Cannot be combined with next or aroundId.

Example1790157600000
next
string

The cursor.next value from a previous response. Returns the messages newer than that position. If cursor.next is null, there are no newer messages. Cannot be combined with previous or aroundId.

Example1790157900000
aroundId
string

The ID of a message in the room. It loads messages centered around that message, including the message itself. Use it to jump to a specific message, such as a quoted message or a search result. Cannot be combined with next or previous.

ExampleXq8sLpW3nZr2TmKeA
lastSeen
string (date-time)

An ISO 8601 date-time for the user's last-read position. It does not limit the returned messages. When the oldest returned message is newer than this value, the response includes firstUnread and unreadNotLoaded.

Example2026-09-23T09:00:00.000Z
showThreadMessages
boolean

Whether to include thread replies that were not also sent to the room. The default is true.

Defaulttrue
Exampletrue
Responses
200

OK

Success Example
{
  "messages": [
    {
      "_id": "Xq8sLpW3nZr2TmKeA",
      "rid": "6GFJ3tbmHiyHbahmC",
      "msg": "The release checklist is ready for review.",
      "ts": "2026-09-23T10:05:00.000Z",
      "u": {
        "_id": "rbAXPnMktTFbNpwtJ",
        "username": "dana.reyes",
        "name": "Dana Reyes"
      },
      "_updatedAt": "2026-09-23T10:05:00.000Z",
      "mentions": [],
      "channels": []
    },
    {
      "_id": "Bv5nTq7RkWz3YpLcD",
      "rid": "6GFJ3tbmHiyHbahmC",
      "msg": "Thanks, I will take a look this afternoon.",
      "ts": "2026-09-23T10:00:00.000Z",
      "u": {
        "_id": "kP3wQz8LmNvT5rXyB",
        "username": "sam.okafor",
        "name": "Sam Okafor"
      },
      "_updatedAt": "2026-09-23T10:00:00.000Z",
      "mentions": [],
      "channels": []
    }
  ],
  "cursor": {
    "next": null,
    "previous": "1790157600000"
  },
  "unreadNotLoaded": 0,
  "success": true
}
Expand All
object
messages
Array of object

The messages, ordered newest first.

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
cursor
object
next
string | null

The cursor for newer messages, or null if there are none.

previous
string | null

The cursor for older messages, or null if there are none.

firstUnread
object

The oldest unread message that was not loaded in this response. Returned only when lastSeen is provided and unread messages exist beyond the returned messages.

unreadNotLoaded
integer

The number of unread messages newer than lastSeen that were not loaded in this response.

success
boolean
400

Bad Request

Cursor Conflict
{
  "success": false,
  "error": "Only one of \"next\", \"previous\" and \"aroundId\" can be provided [error-cursor-conflict]",
  "errorType": "error-cursor-conflict"
}
Invalid Cursor
{
  "success": false,
  "error": "Invalid pagination cursor [error-invalid-cursor]",
  "errorType": "error-invalid-cursor"
}
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
403

Forbidden. You cannot access the room, or the room is a public channel that you have not joined and you do not have the preview-c-room permission.

Permission Error
{
  "success": false,
  "error": "unauthorized"
}
object
success
boolean
error
string
404

Not Found. The room does not exist, or the message in aroundId is not a visible message in the room.

Not Found
{
  "success": false,
  "error": "Resource not found"
}
object
success
boolean
error
string