Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

getSessionList()

Retrieves a list of sessions.

const sessions = await clerkClient.sessions.getSessionList();

Required parameters

NameTypeDescription
clientId?stringThe client ID to retrieve the list of sessions for.
userId?stringThe 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";
ValueDescription
abandonedThe session was abandoned client-side.
activeThe session is valid and all activity is allowed.
endedThe user signed out of the session, but the Session remains in the Client object.
expiredThe period of allowed activity for this session has passed.
removedThe user signed out of the session and the Session was removed from the Client object.
replacedThe session has been replaced by another one, but the Session remains in the Client object.
revokedThe 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 });

What did you think of this content?

Clerk © 2023