Links

Get Current User Sessions

Get sessions of the authenticated user.
Retrieves all sessions of the authenticated user making the request. It supports the Pagination parameters.
URL
Requires Auth
HTTP Method
/api/v1/sessions/list
yes
GET

Headers

Argument
Example
Required
Description
X-User-Id
myuser-name
Required
The authenticated user ID.
X-Auth-Token
myauth-token
Required
Auth token.

Query Parameter

Argument
Example
Required
Description
filter
windows
Optional
Filter sessions list using regex

Example Call

curl --location 'http://localhost:3000/api/v1/sessions/list' \
--header 'X-Auth-Token: 4uBKb3a7jl28SM1uIAiXnqGvg9CBre9FA8cWxp8AaA6' \
--header 'X-User-Id: rbAXPnMktTFbNpwtJ'

Example Result

Success

{
"sessions": [
{
"sessionId": "QoYYFw2t9oKks2niG",
"userId": "rbAXPnMktTFbNpwtJ",
"device": {
"type": "browser",
"name": "Chrome",
"longVersion": "113.0.0.0",
"os": {
"name": "Windows",
"version": "10"
},
"version": "113.0.0"
},
"host": "localhost:3000",
"ip": "172.20.0.2",
"loginAt": "2023-05-23T16:33:45.202Z",
"_id": "QoYYFw2t9oKks2niG"
},
{
"sessionId": "WJ2giBwm4B9mcojFi",
"userId": "rbAXPnMktTFbNpwtJ",
"device": {
"type": "mobile",
"name": "Chrome",
"longVersion": "112.0.0.0",
"os": {
"name": "Android",
"version": "10"
},
"version": "112.0.0"
},
"host": "localhost:3000",
"ip": "172.20.0.2",
"loginAt": "2023-05-23T12:43:52.023Z",
"_id": "WJ2giBwm4B9mcojFi"
}
],
"total": 2,
"count": 50,
"offset": 0,
"success": true
}

Error

Any of the following errors can occur on the endpoint.
  • Authorization: Requires an authentication token for the request to be made.
Authorization
{
"status": "error",
"message": "You must be logged in to do this."
}

Change Log

Version
Description
5.0.0
Added
Last modified 2mo ago
Deprecation for cloud services and apps is now extended to November 20, 2023. Rocket.Chat versions receive support for six months after release.