Sessions API
The Sessions API provides visibility and control over user sessions across the tenant. Administrators can list active sessions, revoke individual sessions, 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/admin/sessionsRequires: manage:sessionsList sessions across the tenant. Supports filtering by user ID and session status. Returns session metadata including device information, IP address, and authentication method. Sessions are ordered by last activity time descending. The response always includes aggregate stats for the tenant.
Query parameters
Success response
The response is a flat object — there is no ok wrapper. Sessions are under the top-level sessions key. Aggregate stats are always included.
{
"sessions": [
{
"id": "clxyz123",
"tenantId": "clt_abc",
"userId": "clu_xyz789",
"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",
"revoked": false,
"createdAt": "2025-02-18T08:00:00Z",
"updatedAt": "2025-02-18T09:45:00Z",
"expiresAt": "2025-02-19T08:00:00Z",
"user": {
"email": "[email protected]",
"firstName": "Alice",
"lastName": "Smith"
}
},
{
"id": "cldef456",
"tenantId": "clt_abc",
"userId": "clu_abc123",
"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",
"revoked": true,
"createdAt": "2025-02-18T07:30:00Z",
"updatedAt": "2025-02-18T09:30:00Z",
"expiresAt": "2025-02-19T07:30:00Z",
"user": {
"email": "[email protected]",
"firstName": "Bob",
"lastName": "Jones"
}
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 156,
"totalPages": 8
},
"stats": {
"active": 143,
"last24h": 42
}
}Session object fields
The session object reflects the raw Prisma LoginSession model enriched with a nested user object:
stats object
There is no separate /api/admin/sessions/stats endpoint — aggregate stats are returned inline with every list response.
Get Session
GET /api/admin/sessions/[id] is not yet implemented. Only the DELETE method exists on this route. Attempting a GET will return 405.
Revoke Session
/api/admin/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
{
"success": true
}Error codes
The API does not check whether a session is already revoked before updating it. Revoking an already-revoked session returns { "success": true } without error.
Revoke All User Sessions
POST /api/admin/sessions/revoke-all is not yet implemented. This route does not exist in the codebase.
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/realm-settingsRequires: admin:allRetrieve 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/realm-settingsRequires: admin:allUpdate session and security policy settings. The request body must use a sectioned envelope specifying which group of settings to update. Changes take effect for new sessions immediately. Existing sessions are not retroactively affected.
Request body
The body must include a section field identifying which settings group to update, and a data object with the fields for that section.
{
"section": "tokens",
"data": {
"accessTokenExpiry": 600,
"refreshTokenExpiry": 604800,
"sessionMaxLifetime": 43200,
"sessionIdleTimeout": 3600
}
}Supported section values
Success response
The response uses success (not ok) and returns the full nested realm settings object as returned by getRealmSettings():
{
"success": true,
"data": {
"tokens": {
"accessTokenExpiry": 600,
"refreshTokenExpiry": 604800,
"sessionMaxLifetime": 43200,
"sessionIdleTimeout": 3600
},
"login": { "...": "..." },
"bruteForce": { "...": "..." },
"general": { "...": "..." },
"security": { "...": "..." },
"tokenClaims": { "...": "..." }
}
}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 (revoked: false)
|
+--- User makes API requests ---> updatedAt refreshed
|
+--- 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 (revoked: true)Permissions Reference
Individual users can view and revoke their own sessions through the user profile endpoints (GET /api/user/security/sessions, DELETE /api/user/security/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