Sessions API
The Sessions API provides visibility and control over user sessions across the tenant. Administrators can list active sessions, inspect session details, revoke individual sessions or all sessions for a user, and configure session lifetime policies.
A session is created when a user successfully authenticates (via password, magic link, social login, or SSO). Each session tracks the device, IP address, last activity time, and authentication method used. Sessions remain active until they expire, are revoked by an administrator, or the user logs out.
Session Management
List Sessions
/api/sessionsRequires: manage:sessionsList sessions across the tenant. Supports filtering by user ID and active/inactive status. Returns session metadata including device information, IP address, and authentication method. Sessions are ordered by last activity time descending.
Query parameters
Success response
{
"ok": true,
"data": {
"data": [
{
"id": "sess_abc123",
"userId": "usr_xyz789",
"userEmail": "[email protected]",
"userName": "Alice Smith",
"ipAddress": "203.0.113.50",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
"device": "Chrome on macOS",
"authMethod": "password",
"isActive": true,
"createdAt": "2025-02-18T08:00:00Z",
"lastActivityAt": "2025-02-18T09:45:00Z",
"expiresAt": "2025-02-19T08:00:00Z"
},
{
"id": "sess_def456",
"userId": "usr_abc123",
"userEmail": "[email protected]",
"userName": "Bob Jones",
"ipAddress": "198.51.100.42",
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15",
"device": "Safari on iOS",
"authMethod": "magic_link",
"isActive": true,
"createdAt": "2025-02-18T07:30:00Z",
"lastActivityAt": "2025-02-18T09:30:00Z",
"expiresAt": "2025-02-19T07:30:00Z"
},
{
"id": "sess_ghi789",
"userId": "usr_xyz789",
"userEmail": "[email protected]",
"userName": "Alice Smith",
"ipAddress": "203.0.113.51",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"device": "Edge on Windows",
"authMethod": "sso",
"isActive": false,
"revokedAt": "2025-02-17T16:00:00Z",
"revokedBy": "usr_admin001",
"createdAt": "2025-02-17T08:00:00Z",
"lastActivityAt": "2025-02-17T15:55:00Z",
"expiresAt": "2025-02-18T08:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 156,
"totalPages": 8
}
}
}Authentication methods: password, magic_link, social, sso, device_code, m2m.
Get Session
/api/sessions/[id]Requires: manage:sessionsRetrieve detailed information about a specific session, including the full user agent string, authentication context, and revocation details if the session has been revoked.
Success response
{
"ok": true,
"data": {
"id": "sess_abc123",
"userId": "usr_xyz789",
"userEmail": "[email protected]",
"userName": "Alice Smith",
"ipAddress": "203.0.113.50",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
"device": "Chrome on macOS",
"authMethod": "password",
"isActive": true,
"mfaVerified": true,
"mfaMethod": "totp",
"acr": "urn:auris:mfa",
"amr": ["pwd", "otp"],
"createdAt": "2025-02-18T08:00:00Z",
"lastActivityAt": "2025-02-18T09:45:00Z",
"expiresAt": "2025-02-19T08:00:00Z"
}
}Error codes
Revoke Session
/api/sessions/[id]Requires: manage:sessionsRevoke a specific session. The associated refresh token is immediately invalidated. The access token continues to be valid until it expires naturally (JWTs are stateless). For immediate lockout, combine session revocation with short access token lifetimes.
Access tokens are JWTs and cannot be individually revoked without a blocklist. Auris relies on short access token lifetimes (default 15 minutes) for security. When a session is revoked, the refresh token is invalidated, so the user cannot obtain a new access token after the current one expires.
Success response
{
"ok": true,
"data": {
"revoked": true,
"sessionId": "sess_abc123"
}
}Error codes
Revoke All User Sessions
/api/sessions/revoke-allRequires: manage:sessionsRevoke all active sessions for a specific user. This is useful when an account may be compromised or when an administrator needs to force a user to re-authenticate on all devices. All associated refresh tokens are immediately invalidated.
Request body
{
"userId": "usr_xyz789"
}Success response
{
"ok": true,
"data": {
"revoked": true,
"sessionsRevoked": 3,
"userId": "usr_xyz789"
}
}The sessionsRevoked count indicates how many active sessions were terminated.
Error codes
Revoking all sessions logs the user out of every device and browser. They will need to re-authenticate on each one. Consider notifying the user via email when performing this action.
Session Statistics
/api/sessions/statsRequires: manage:sessionsGet aggregate session statistics for the tenant. Useful for monitoring active users and identifying trends.
Success response
{
"ok": true,
"data": {
"activeSessions": 156,
"uniqueUsers": 89,
"last24Hours": {
"newSessions": 42,
"expiredSessions": 31,
"revokedSessions": 3
},
"byAuthMethod": {
"password": 98,
"magic_link": 23,
"social": 25,
"sso": 10
},
"byDevice": {
"desktop": 87,
"mobile": 52,
"tablet": 12,
"unknown": 5
}
}
}Session Policies
Session policies control the lifetime of sessions and tokens across the tenant. These settings apply to all users unless overridden by application-specific configuration.
Get Security Settings
/api/settings/securityRequires: manage:security_settingsRetrieve the current session and security policy settings for the tenant.
Success response
{
"ok": true,
"data": {
"sessionMaxLifetime": 86400,
"sessionIdleTimeout": 3600,
"refreshTokenExpiry": 604800,
"accessTokenExpiry": 900,
"maxConcurrentSessions": 5,
"requireMfaForAdmin": true,
"passwordMinLength": 8,
"passwordRequireUppercase": true,
"passwordRequireLowercase": true,
"passwordRequireNumbers": true,
"passwordRequireSpecial": false,
"passwordHistoryCount": 5,
"lockoutThreshold": 5,
"lockoutDuration": 900,
"updatedAt": "2025-02-10T14:00:00Z"
}
}Session and token settings
MFA settings
Password policy settings
Lockout settings
Update Security Settings
/api/settings/securityRequires: manage:security_settingsUpdate session and security policy settings. All fields are optional — only provided fields are updated. Changes take effect for new sessions immediately. Existing sessions are not retroactively affected (they continue with their original expiry times).
Request body
{
"sessionMaxLifetime": 43200,
"accessTokenExpiry": 600,
"maxConcurrentSessions": 3,
"requireMfaForAdmin": true,
"passwordMinLength": 12,
"lockoutThreshold": 3,
"lockoutDuration": 1800
}Success response
{
"ok": true,
"data": {
"sessionMaxLifetime": 43200,
"sessionIdleTimeout": 3600,
"refreshTokenExpiry": 604800,
"accessTokenExpiry": 600,
"maxConcurrentSessions": 3,
"requireMfaForAdmin": true,
"passwordMinLength": 12,
"passwordRequireUppercase": true,
"passwordRequireLowercase": true,
"passwordRequireNumbers": true,
"passwordRequireSpecial": false,
"passwordHistoryCount": 5,
"lockoutThreshold": 3,
"lockoutDuration": 1800,
"updatedAt": "2025-02-18T11:00:00Z"
}
}Error codes
Validation rules
accessTokenExpirymust be between 60 (1 minute) and 86400 (24 hours)refreshTokenExpirymust be between 3600 (1 hour) and 2592000 (30 days)sessionMaxLifetimemust be>=accessTokenExpirysessionIdleTimeoutmust be<=sessionMaxLifetimemaxConcurrentSessionsmust be between 0 and 100passwordMinLengthmust be between 6 and 128lockoutThresholdmust be between 1 and 100lockoutDurationmust be between 60 (1 minute) and 86400 (24 hours)
Setting very short access token lifetimes (under 5 minutes) increases the frequency of token refresh requests. Setting very long lifetimes reduces security. The recommended range is 5 to 30 minutes.
Concurrent Session Enforcement
When maxConcurrentSessions is set to a non-zero value, Auris enforces a limit on the number of active sessions per user. When a new session is created and the user already has the maximum number of sessions:
- The oldest session (by
createdAt) is automatically revoked. - The new session is created normally.
- The user receives a notification that an older session was terminated (if in-app notifications are enabled).
This behavior ensures that users are never prevented from logging in due to stale sessions, while still maintaining a reasonable cap on concurrent access.
Session Lifecycle
User authenticates
|
v
Session created (isActive: true)
|
+--- User makes API requests ---> lastActivityAt updated
|
+--- Access token expires ---> User refreshes token
| (refreshToken still valid)
|
+--- Idle timeout reached ---> Session expired
|
+--- Max lifetime reached ---> Session expired
|
+--- Admin revokes session ---> Session revoked
|
+--- User logs out ---> Session revoked
|
v
Session inactive (isActive: false)Permissions Reference
Individual users can view and revoke their own sessions through the user profile endpoints (GET /api/user/sessions, DELETE /api/user/sessions/[id]) without needing admin permissions. The endpoints documented on this page are for tenant-wide administration.
Related
- Sessions & Token Rotation — How sessions, tokens, and rotation work together
- Session Management Guide — Configure session policies and enforcement
- Session Management — Monitor and revoke sessions from the Console
- Authentication API — Login and token endpoints that create sessions