getSessionList()
Retrieves a list of sessions.
const sessions = await clerkClient.sessions.getSessionList();
Required parameters
Name | Type | Description |
---|---|---|
clientId? | string | The client ID to retrieve the list of sessions for. |
userId? | string | The user ID to retrieve the list of sessions for. |
status? | [SessionStatus](#session-status) | The status of the session. |
SessionStatus
type SessionStatus = "abandoned" | "active" | "ended" | "expired" | "removed" | "replaced" | "revoked";
Value | Description |
---|---|
abandoned | The session was abandoned client-side. |
active | The session is valid and all activity is allowed. |
ended | The user signed out of the session, but the Session remains in the Client object. |
expired | The period of allowed activity for this session has passed. |
removed | The user signed out of the session and the Session was removed from the Client object. |
replaced | The session has been replaced by another one, but the Session remains in the Client object. |
revoked | The application ended the session and the Session was removed from the Client object. |
Example
getSessionList({ clientId, userId })
Retrieve a list of sessions for a specific clientId and userId:
const clientId = 'my-client-id'; const userId = 'my-user-id'; const sessions = await clerkClient.sessions.getSessionList({ clientId, userId });
getSessionList({ clientId, sessionId, status })
Retrieve a list of sessions with a specific status:
const clientId = 'my-client-id'; const userId = 'my-user-id'; const status = 'revoked' // retrieves a list of 'revoked' sessions for a specific clientId and userId const sessions = await clerkClient.sessions.getSessionList({ clientId, sessionId, status });