getSessionList()
Gets a list of sessions for either the specified client or user. Requires either clientId or userId to be provided. By default, the list is returned in descending order by creation date (newest first).
Returns a PaginatedResourceResponse object with a data property containing an array of Session objects and a totalCount property containing the total number of sessions.
function getSessionList(params: SessionListParams): Promise<PaginatedResourceResponse<Session[]>>- Name
clientId?- Type
string- Description
The ID of the client to get sessions for.
- Name
status?- Type
- SessionStatus
- Description
The status of the sessions to get.
- Name
userId?- Type
string- Description
The ID of the user to get sessions for.
Get a list of sessions for a specific userId:
const userId = 'user_123'
const response = await clerkClient.sessions.getSessionList({ userId })Filter by session status
In this example, a list of sessions with a status of 'expired' is retrieved. You can see that the returned PaginatedResourceResponse includes data, which is an array of Session objects, and totalCount, which indicates the total number of sessions for the specified user.
const userId = 'user_123'
const status = 'expired'
const response = await clerkClient.sessions.getSessionList({ userId, status })Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint GET/sessions. See the BAPI reference for more information.
Feedback
Last updated on