Show a user's active or historical sessions
Account security settings
Clerk · Module
Lists sessions for a specified client or user, with optional status filtering and pagination. The result contains session data plus the total matching-session count.
Call this server-side method with a client or user identifier, optionally adding status and pagination controls. The promise resolves to a paginated response whose data contains Session objects and whose totalCount reports the overall number of matching sessions.
function getSessionList(params: SessionListParams): Promise<PaginatedResourceResponse<Session[]>>| Name | Type | Description |
|---|---|---|
clientId | string | The ID of the client to get sessions for. |
userId | string | The ID of the user to get sessions for. |
limit | number | Maximum items per request; an integer greater than zero and less than 501. Defaults to 10. |
offset | number | Number of items to skip while paginating; an integer greater than or equal to zero. Defaults to 0. |
status | SessionStatus | The status of the sessions to get. |
Promise<PaginatedResourceResponse<Session[]>>
const userId = 'user_123'
const { data, totalCount } = await clerkClient.sessions.getSessionList({
userId,
status: 'expired',
limit: 20,
})
console.log(`Found ${totalCount} sessions`)
for (const session of data) {
console.log(session.id, session.status)
}This server-side example retrieves up to 20 expired sessions for one user and reads both the returned session array and its total count.
Account security settings
Administrative support
Paginated dashboards
It accepts a SessionListParams object and returns a promise of PaginatedResourceResponse<Session[]>. The response exposes data for the matching sessions and totalCount for the total number of sessions.
Follow-up: Why should callers destructure totalCount instead of treating the result as an array? The current response is an object containing both data and totalCount, not a direct session array.
The call must include either clientId or userId. It can additionally filter by status and page through results with limit and offset.
Follow-up: How would you retrieve the second page? Supply a positive limit and set offset to the number of items skipped, such as limit: 20 and offset: 20.
Results are ordered newest first by creation date unless the documentation specifies another ordering option. The default limit is 10 and the default offset is 0.
Follow-up: What should a UI use totalCount for? It can determine the total number of matching sessions and calculate page availability.
SessionListParamsPaginatedResourceResponseSessionSessionStatussessions.getSessionsessions.revokeSession