Overview
The Sessions API provides endpoints for managing user authentication sessions. Sessions track active login instances across different devices and browsers, allowing users and administrators to monitor and control access.Get My Sessions
Retrieve all active sessions for the currently authenticated user.HTTP Request
GET /api/v1/identity/sessions/me
Authorization
RequiresPermissions.Sessions.View permission.
Response
Returns an array ofUserSessionDto objects.
Session’s unique identifier
User ID associated with the session
Username of the session owner
Email address of the session owner
IP address from which the session was created
Type of device (e.g., Desktop, Mobile, Tablet)
Browser name (e.g., Chrome, Firefox, Safari)
Browser version number
Operating system name (e.g., Windows, macOS, Linux, iOS, Android)
Operating system version
Timestamp when the session was created
Timestamp of the last activity in this session
Timestamp when the session will expire
Whether the session is currently active
Whether this is the current session making the request
Response Example
Revoke Session
Revoke a specific session for the currently authenticated user.HTTP Request
DELETE /api/v1/identity/sessions/{sessionId}
Authorization
RequiresPermissions.Sessions.Revoke permission.
Path Parameters
The unique identifier of the session to revoke
Response
Returns200 OK if the session was successfully revoked, or 404 Not Found if the session doesn’t exist or doesn’t belong to the current user.
Notes
- Users can only revoke their own sessions
- Revoking a session immediately invalidates the associated access and refresh tokens
- The current session (the one making the request) can be revoked, which will log out the user
Revoke All Sessions
Revoke all active sessions for the currently authenticated user.HTTP Request
DELETE /api/v1/identity/sessions
Authorization
RequiresPermissions.Sessions.Revoke permission.
Response
Returns200 OK on successful revocation of all sessions.
Notes
- This endpoint revokes ALL sessions for the current user, including the current session
- After calling this endpoint, the user will be logged out from all devices
- Useful for security purposes when a user suspects their account has been compromised
Admin: Get User Sessions
Retrieve all active sessions for a specific user (admin operation).HTTP Request
GET /api/v1/identity/users/{userId}/sessions
Authorization
Requires administrative permissions.Path Parameters
The unique identifier of the user
Response
Returns an array ofUserSessionDto objects for the specified user.
Admin: Revoke User Session
Revoke a specific session for any user (admin operation).HTTP Request
DELETE /api/v1/identity/admin/sessions/{sessionId}
Authorization
Requires administrative permissions.Path Parameters
The unique identifier of the session to revoke
Response
Returns200 OK on successful revocation.
Admin: Revoke All User Sessions
Revoke all active sessions for a specific user (admin operation).HTTP Request
DELETE /api/v1/identity/admin/users/{userId}/sessions
Authorization
Requires administrative permissions.Path Parameters
The unique identifier of the user
Response
Returns200 OK on successful revocation of all user sessions.
Session Management
Automatic Cleanup
The system automatically cleans up expired sessions through a background service:- Sessions are checked periodically for expiration
- Expired sessions are removed from the database
- This helps maintain optimal database performance
Session Lifecycle
Best Practices
Sessions track device and browser information for security auditing purposes. This information is captured during login and stored with the session.
Security Considerations
Multi-Device Support
- Users can have multiple active sessions across different devices
- Each session is independent and can be revoked individually
- Session IDs are unique and cannot be guessed or forged
Session Revocation
- Revoking a session immediately invalidates associated tokens
- Users are notified (depending on configuration) when sessions are revoked
- Administrative session revocation is logged for audit purposes
Token Rotation
- Refresh tokens are rotated on each use
- Old refresh tokens are invalidated immediately
- This prevents token replay attacks
