> ## 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 Room Members Ordered by Role > Get room members ordered by their roles. This endpoint sorts the members according to their role in the room in the order `Owners` > `Moderators` > all other members. This can be reversed using the query paramter `sort={"rolePriority":-1}`. You need not be a member of the room. If the room is a broadcast room, you need the `view-broadcast-member-list` permission to view the room members. ### Changelog | Version | Description | | ------- | ----------- | | 7.3.0 | Added | ## OpenAPI ````json GET /api/v1/rooms.membersOrderedByRole { "openapi": "3.0.0", "info": { "version": "1.0.0", "title": "Rooms" }, "servers": [ { "url": "https://apiexplorer.support.rocket.chat" } ], "tags": [ { "name": "Channels" }, { "name": "Directory" }, { "name": "Groups" }, { "name": "Rooms" }, { "name": "Teams" }, { "name": "Room Invites" }, { "name": "Subscriptions" }, { "name": "ABAC" } ], "paths": { "/api/v1/rooms.membersOrderedByRole": { "get": { "summary": "Get Room Members Ordered by Role", "tags": [ "Rooms" ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "members": { "type": "array", "items": { "type": "object", "properties": { "_id": { "type": "string" }, "username": { "type": "string" }, "status": { "type": "string" }, "_updatedAt": { "type": "string" }, "name": { "type": "string" }, "roles": { "type": "array", "items": { "type": "string" } } } } }, "count": { "type": "integer" }, "offset": { "type": "integer" }, "total": { "type": "integer" }, "success": { "type": "boolean" } } }, "examples": { "Example 1": { "value": { "members": [ { "_id": "C38WSSzrGd2NCjzqJ", "username": "test.cat", "status": "online", "_updatedAt": "2025-01-22T07:49:47.83Z", "name": "test.cat", "roles": [ "owner" ] }, { "_id": "P2dgWPPw5veigwcdK", "status": "offline", "_updatedAt": "2025-01-22T07:13:19.734Z", "name": "Fun Smith", "username": "fun.smith", "roles": [ "moderator" ] }, { "_id": "CNmyTxexxauJ4wrTW", "username": "agent1", "status": "offline", "_updatedAt": "2025-01-22T07:32:57.238Z", "name": "agent1" }, { "_id": "FSA63o85Poa2EQvAH", "status": "offline", "name": "cat kate", "username": "cat.kate", "_updatedAt": "2025-01-22T08:04:12.251Z", "roles": [ "leader" ] } ], "count": 4, "offset": 0, "total": 4, "success": true } } } } } }, "400": { "description": "Bad Request", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "error": { "type": "string" }, "errorType": { "type": "string" } } }, "examples": { "Example 1": { "value": { "success": false, "error": "must have required property 'roomId'\n must have required property 'roomName'\n must match exactly one schema in oneOf [invalid-params]", "errorType": "invalid-params" } } } } } }, "401": { "$ref": "#/components/responses/authorizationError" } }, "operationId": "get-api-v1-rooms.membersOrderedByRole", "description": "Get room members ordered by their roles. This endpoint sorts the members according to their role in the room in the order `Owners` > `Moderators` > all other members. This can be reversed using the query paramter `sort={\"rolePriority\":-1}`. You need not be a member of the room.\n\nIf the room is a broadcast room, you need the `view-broadcast-member-list` permission to view the room members.\n\n### Changelog\n| Version | Description |\n| ------- | ----------- |\n| 7.3.0 | Added |", "parameters": [ { "$ref": "#/components/parameters/Auth-Token" }, { "$ref": "#/components/parameters/UserId" }, { "schema": { "type": "string", "example": "66cd971f6fcbb8e8b3cf8e69" }, "in": "query", "name": "roomId", "description": "Enter the room ID.", "required": true }, { "schema": { "type": "string", "example": "test-team" }, "in": "query", "name": "roomName", "description": "Instead of using the room ID, you can enter the room name." }, { "schema": { "type": "string", "example": "user" }, "in": "query", "name": "filter", "description": "Filter the results by using the text that you want to view." }, { "$ref": "#/components/parameters/offset" }, { "$ref": "#/components/parameters/count" }, { "schema": { "type": "string" }, "in": "query", "name": "sort", "description": "Sort the rooms in ascending (`1`) or descending (`-1`) order. The value must be entered as a JSON string. The options are as follows:\n * `rolePriority`: Sort by priority of role (`Owners` > `Moderators` > all other members). For example, `sort={\"rolePriority\":-1}`\n * `username`: Sort by usernames. For example, `sort={\"username\":-1}`" }, { "schema": { "type": "array", "items": { "type": "string" } }, "in": "query", "name": "status", "description": "Enter the user status for which you want the results. For example, `online`, `away`, `offline`." } ] } } }, "components": { "responses": { "authorizationError": { "description": "Unauthorized", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" }, "message": { "type": "string" } } }, "examples": { "Authorization Error": { "value": { "status": "error", "message": "You must be logged in to do this." } } } } } } }, "parameters": { "Auth-Token": { "name": "X-Auth-Token", "in": "header", "description": "The `authToken` of the authenticated user.", "required": true, "schema": { "type": "string" }, "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f" }, "UserId": { "name": "X-User-Id", "in": "header", "description": "The `userId` of the authenticated user.", "required": true, "schema": { "type": "string" }, "example": "rbAXPnMktTFbNpwtJ" }, "offset": { "name": "offset", "in": "query", "description": "Number of items to \"skip\" in the query, i.e. requests return count items, skipping the first offset items. Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more.", "required": false, "schema": { "type": "integer" }, "example": 50 }, "count": { "name": "count", "in": "query", "description": "The number of items to return. Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more.", "required": false, "schema": { "type": "integer" }, "example": 50 } } } } ````