āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/clerk/clerk-docs/reference/backend/sessions/get-session-list ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
getSessionList()'
description: Use Clerk's JS Backend SDK to retrieve a list of sessions.
sdk: js-backend{/* clerk/javascript file: https://github.com/clerk/javascript/blob/main/packages/backend/src/api/endpoints/SessionApi.ts/#L18 */}
Retrieves a list of sessions. Returns a PaginatedResourceResponse object with a data property that contains an array of Session objects, and a totalCount property that indicates the total number of sessions for the specified user.
function getSessionList(
queryParams: SessionListParams,
): Promise<PaginatedResourceResponse<Session[]>>
SessionListParamsgetSessionList() requires either clientId or userId to be provided.
The client ID to retrieve the list of sessions for.
userId?stringThe user ID to retrieve the list of sessions for.
status?SessionStatusThe status of the session.
limit?numberThe number of results to return. Must be an integer greater than zero and less than 501. Can be used for paginating the results together with offset. Defaults to 10.
offset?numberSkip the first offset results when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with limit. Defaults to 0.
</Properties>
SessionStatustype SessionStatus =
| 'abandoned'
| 'active'
| 'pending'
| 'ended'
| 'expired'
| 'removed'
| 'replaced'
| 'revoked'
| Value | Description |
| - | - |
| abandoned | The session was abandoned client-side. |
| active | The session is valid and all activity is allowed. |
| pending | The user has signed in but hasn't completed session tasks. |
| 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. |
Retrieve a list of sessions for a specific userId:
const userId = 'user_123'
const response = await clerkClient.sessions.getSessionList({ userId })
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 })
This method in the SDK is a wrapper around the BAPI endpoint GET/sessions. See the BAPI reference{{ target: '_blank' }} for more information.
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā