Skip to main content

Session Operations

This section covers GraphQL operations related to user session management.

Queries​

My Active Sessions​

Retrieves all active sessions for the currently authenticated user.

query MyActiveSessions {
myActiveSessions {
id
token
user
expiresAt
createdAt
isActive
ipAddress
countryCode
userCountryCode
state
timezone
context {
OS
OSVersion
browser
browserVersion
}
currentDevice
}
}

Response:

{
"data": {
"myActiveSessions": [
{
"id": "session-id-1",
"token": "session-token-1",
"user": "user-id",
"expiresAt": "2023-01-02T00:00:00Z",
"createdAt": "2023-01-01T00:00:00Z",
"isActive": true,
"ipAddress": "192.168.1.1",
"countryCode": "US",
"userCountryCode": "US",
"state": "California",
"timezone": "America/Los_Angeles",
"context": {
"OS": "macOS",
"OSVersion": "12.6",
"browser": "Chrome",
"browserVersion": "108.0.0"
},
"currentDevice": true
},
{
"id": "session-id-2",
"token": "session-token-2",
"user": "user-id",
"expiresAt": "2023-01-02T00:00:00Z",
"createdAt": "2023-01-01T00:00:00Z",
"isActive": true,
"ipAddress": "192.168.1.2",
"countryCode": "GB",
"userCountryCode": "US",
"state": null,
"timezone": "Europe/London",
"context": {
"OS": "iOS",
"OSVersion": "16.0",
"browser": "Safari",
"browserVersion": "16.0"
},
"currentDevice": false
}
]
}
}

Stream Chat Token​

Retrieves a Stream Chat token for the currently authenticated user.

query StreamChatToken {
streamChatToken
}

Response:

{
"data": {
"streamChatToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}

Session Model​

Fields​

FieldTypeDescription
idIDUnique identifier for the session
tokenStringSession token
userIDID of the user the session belongs to
expiresAtDateDate and time when the session expires
createdAtDateDate and time when the session was created
isActiveBooleanWhether the session is currently active
ipAddressStringIP address associated with the session
countryCodeCountryCodeCountry code detected from the IP address
userCountryCodeCountryCodeCountry code set by the user in their profile
stateStringState or region of the session
timezoneStringTimezone of the session
contextSessionContextAdditional context information about the session
currentDeviceBooleanWhether the session is from the current device

Session Context Fields​

FieldTypeDescription
OSStringOperating system name
OSVersionStringOperating system version
browserStringBrowser name
browserVersionStringBrowser version