RoomsRoom ManagementList Rooms

List Rooms

Overview

This endpoint allows you to retrieve the list of rooms that the current user has joined, with support for pagination, sorting, and conditional filtering. It is suitable for scenarios such as displaying room lists and incremental synchronization.


API Endpoint

Get Room List

Retrieve the list of rooms the current user has joined, with support for pagination, sorting, and conditional filtering.

GET /rooms

Headers

ParameterTypeRequiredDescription
IM-CLIENT-KEYstringClient key
IM-CLIENT-IDstringCurrent user’s client ID (required by this endpoint to calculate unread counts and other user-specific data)
IM-AuthorizationstringClient token

Query Parameters

ParameterTypeRequiredDescription
sortstringSort criteria; multiple fields can be combined, separated by spaces; prefix - indicates descending order
skipintegerPagination offset, defaults to 0
limitintegerMaximum number of rooms to return, defaults to 0 (no limit)
updatedAfterstring or integerFilter rooms that have new messages or were created after the specified timestamp; supports ISO-8601 string or millisecond Epoch integer
prefJSONFilter by the user’s room preference settings, e.g., {"tags": "some-tag"}
sortUnreadFirstintegerWhen non-zero, rooms with unread messages are sorted first

sort Parameter Examples

Sort by latest message and creation time in descending order:

-lastMessage -createdTime

Sort by creation time in ascending order:

createdTime

Example Request

Example 1: Get room list (pagination + time filter)

cURL Example:

curl "https://your-app.imkit.io/rooms?skip=0&limit=20&sort=-lastMessage&updatedAfter=2020-10-15T03:28:54Z" \
     -H 'IM-CLIENT-KEY: {IM-CLIENT-KEY}' \
     -H 'IM-CLIENT-ID: {IM-CLIENT-ID}' \
     -H 'IM-Authorization: {IM-Authorization}'

JavaScript Example:

const response = await axios.get(
  "https://your-app.imkit.io/rooms",
  {
    params: {
      skip: 0,
      limit: 20,
      sort: "-lastMessage",
      updatedAfter: "2020-10-15T03:28:54Z",
    },
    headers: {
      "IM-CLIENT-KEY": `${IM_CLIENT_KEY}`,
      "IM-CLIENT-ID": `${CLIENT_ID}`,
      "IM-Authorization": `${TOKEN}`,
    },
  }
);

Example 2: Filter rooms by tag and prioritize unread rooms

const response = await axios.get(
  "https://your-app.imkit.io/rooms",
  {
    params: {
      pref: JSON.stringify({ tags: "some-tag" }),
      sortUnreadFirst: 1,
    },
    headers: {
      "IM-CLIENT-KEY": `${IM_CLIENT_KEY}`,
      "IM-CLIENT-ID": `${CLIENT_ID}`,
      "IM-Authorization": `${TOKEN}`,
    },
  }
);

Response

Success Response (200 OK)

ParameterTypeDescription
RCnumberResponse code (0 indicates success)
RMstringResponse message
result.totalCountnumberTotal number of rooms matching the criteria
result.dataarrayArray of room objects
result.inspectobjectDiagnostic information (query criteria and duration)

Room Object Fields

ParameterTypeDescription
_idstringRoom unique identifier
namestringRoom name
coverstringRoom cover image URL
descriptionstringRoom description
roomTypestringRoom type ("direct" or "group")
webhookstringWebhook key or URL
botStatestringBot state
botModebooleanWhether bot mode is enabled
encryptedbooleanWhether encryption is enabled
serviceStatusnumberService status
roomTagsarray[string]Room tags array
statusnumberRoom status (1 indicates active)
unreadnumberUnread message count for the current user
mutedbooleanWhether the current user has muted this room
lastMessageobjectLatest message object
membersarray[object]Room members array
prefobjectCurrent user’s personal preference settings for this room
createdTimeMSnumberRoom creation timestamp (milliseconds)

Preference Object Fields (pref)

ParameterTypeDescription
tagsarray[string]Custom tags the user has set for this room
tagColorsobjectColor for each tag (hex color code)
hiddenbooleanWhether this room is hidden
stickybooleanWhether this room is pinned
mutedbooleanWhether notifications for this room are muted
folderstringFolder name this room belongs to

Example Response

{
  "RC": 0,
  "RM": "OK",
  "result": {
    "totalCount": 1,
    "inspect": {
      "query": {
        "appID": "SampleApp",
        "members": "sss",
        "$or": [
          { "lastMessage": { "$gt": "5f87c2cf0000000000000000" } },
          { "createdTime": { "$gt": "2020-10-15T03:32:31.000Z" } }
        ],
        "status": 1
      },
      "tookMS": 22
    },
    "data": [
      {
        "_id": "demo-room",
        "name": "Demo Demo",
        "cover": "http://loremflickr.com/240/240/style?demo",
        "description": "public demo room",
        "roomType": "group",
        "webhook": "meet-taipei-intro",
        "botState": "CONTACT",
        "botMode": false,
        "encrypted": false,
        "serviceStatus": 0,
        "roomTags": ["demo", "foo", "bar"],
        "status": 1,
        "unread": 0,
        "muted": false,
        "lastMessage": {
          "_id": "5f890cf37d980e06f6aaf349",
          "message": "Hello SIKTMLNP 11:01:07",
          "room": "demo-room",
          "sender": {
            "_id": "sss",
            "nickname": "Elsa",
            "avatarUrl": "https://example.com/avatar.jpg",
            "id": "sss",
            "lastLoginTimeMS": 0
          },
          "messageType": "text",
          "appID": "SampleApp",
          "messageTime": "2020-10-16T03:01:07.923Z",
          "id": "5f890cf37d980e06f6aaf349",
          "messageTimeMS": 1602817267923,
          "updatedAtMS": 1602817267925,
          "createdAtMS": 1602817267925,
          "reactionCount": 0
        },
        "members": [
          {
            "_id": "sss",
            "nickname": "Elsa",
            "avatarUrl": "https://example.com/avatar.jpg",
            "isRobot": false,
            "id": "sss",
            "lastLoginTimeMS": 1588744338369
          }
        ],
        "pref": {
          "tags": ["demo", "sample"],
          "tagColors": {
            "demo": "#f2d700",
            "sample": "#ffa01a"
          },
          "hidden": false,
          "sticky": false,
          "muted": false,
          "folder": "Some-Folder"
        },
        "id": "demo-room",
        "createdTimeMS": 1525001412492
      }
    ]
  }
}

Error Response

When a request fails, you will receive an error response containing error details. Common error scenarios include:

  • Invalid client key or authorization token
  • Incorrect updatedAfter time format
  • Invalid JSON format for the pref parameter
  • Internal server error

Use Cases

Room List Display

  • Home page room list: Use pagination and sorting to retrieve the user’s room list
  • Tag filtering: Filter specific rooms by tags using the pref parameter

Incremental Synchronization

  • Efficient sync: Use updatedAfter with the timestamp from the last request to fetch only updated rooms

Notes

  • Incremental sync: Use updatedAfter with the timestamp from the last request to achieve efficient incremental synchronization, avoiding full data pulls each time
  • Pagination recommendation: It is recommended to use limit and skip for pagination to avoid returning too much data at once, which can impact performance
  • Sorting: The sort field separates multiple criteria by spaces, with a - prefix indicating descending order
  • pref filtering: The pref parameter is in JSON format and must be URL-encoded before being passed
  • inspect field: For debugging purposes only; contains the actual query criteria and execution time, and can be ignored in production environments
© 2026 FUNTEK Software Inc. All rights reserved.