Sessions
Validate tokens and manage user sessions
Use the session client to inspect session metadata and revoke sessions when users sign out or you detect risk.
Typical flows: load a session by ID after authentication, list a user’s sessions for a security UI, and revoke one session or all of a user’s sessions on logout.
getSession
Section titled “getSession”#asyncgetSession
Retrieves comprehensive metadata and status for a specific user session.
The session identifier to retrieve (format: “ses_…”)
Session metadata including status, user, device, and location.
const session = await scalekit.session.getSession('ses_123456');
console.log('Status:', session.status);console.log('User:', session.userId);console.log('Device:', session.deviceInfo);console.log('Location:', session.geoLocation);getUserSessions
Section titled “getUserSessions”#asyncgetUserSessions
Runs getUserSessions and returns the result.
Scalekit user ID (usr_...).
Optional fields: pageSize, pageToken, filter, status, startTime, endTime.
The response payload for this operation.
// pageSize: Results per page (default 10, max 100)// pageToken: Token for the next page// filter: Scoped tool filter// status: status// startTime: start time// endTime: end timeconst response = await scalekit.session.getUserSessions('usr_123456', { filter: { status: ['active'] }, pageSize: 20});
console.log(`User has ${response.totalSize} active sessions`);revokeSession
Section titled “revokeSession”#asyncrevokeSession
Runs revokeSession and returns the result.
Session ID.
Empty on success.
const response = await scalekit.session.revokeSession('ses_123456');console.log('Session revoked at:', response.revokedAt);revokeAllUserSessions
Section titled “revokeAllUserSessions”#asyncrevokeAllUserSessions
Immediately invalidates all active sessions for a user across all devices and browsers.
The user identifier whose sessions should be revoked.
Empty on success.
const response = await scalekit.session.revokeAllUserSessions('usr_123456');
console.log(`Revoked ${response.totalCount} sessions`);