Inspect one session
A backend endpoint needs details about a known authenticated session.
Clerk · Module
Retrieves a specific Clerk Session by its session ID. It returns a promise resolving to the Session object.
Call clerkClient.sessions.getSession with a Clerk session ID to retrieve the corresponding Session object asynchronously. The SDK method wraps Clerk's Backend API endpoint for fetching an individual session.
function getSession(sessionId: string): Promise<Session>| Name | Type | Description |
|---|---|---|
sessionId | string | The ID of the session to get. |
Promise<Session>
clerkClient depends on the Clerk SDK in use; follow that SDK's setup guidance.import { clerkClient } from '@clerk/nextjs/server'
const sessionId = 'sess_123'
const session = await clerkClient.sessions.getSession(sessionId)
console.log(session.id)Fetches a session by its Clerk session ID and logs the returned session identifier.
A backend endpoint needs details about a known authenticated session.
Server-side code has a session ID and needs associated session properties.
An administrative workflow needs to fetch a session through Clerk's backend client.
sessions.getSession?It accepts one string argument, sessionId, and returns a Promise<Session>. The method retrieves the specified Clerk session through the backend SDK.
Follow-up: What backend operation does it represent? It is an SDK wrapper around GET/sessions/{session_id}.
sessions.getSession?Pass the session identifier to clerkClient.sessions.getSession. Await the promise to receive the corresponding Session object.
Follow-up: How would you adapt the call across Clerk integrations? Use the integration's documented way to access clerkClient, because that setup varies by SDK.
getSession differ from a session-list operation?The method is intended for backend use through Clerk's backend client. It retrieves one session rather than listing sessions for a user or client.
Follow-up: Which related operation lists multiple sessions? sessions.getSessionList returns a paginated response and requires either a client ID or user ID.
clerkClientsessions.getSessionListSessionuserId