Force logout
An administrator needs to force a user's particular device or browser session to end.
Clerk · Module
Revokes a specific Clerk session by ID and signs the user out from its associated client. The operation returns the revoked Session.
This backend method revokes the session identified by the supplied ID. The associated client is signed out, and the asynchronous operation resolves to the revoked Session object.
function revokeSession(sessionId: string): Promise<Session>| Name | Type | Description |
|---|---|---|
sessionId | string | The ID of the session to revoke. |
Promise<Session>
const sessionId = "sess_123";
const revokedSession = await clerkClient.sessions.revokeSession(sessionId);
console.log(revokedSession.id);Pass the target session ID to the backend Clerk client and await the returned revoked Session object.
An administrator needs to force a user's particular device or browser session to end.
A backend receives a security signal for one active session.
Call clerkClient.sessions.revokeSession(sessionId) with the session ID. The promise resolves to the revoked Session.
Follow-up: What does the operation target? It revokes one specific session rather than requiring a user-wide session operation.
The sessionId parameter is a string containing the ID of the session to revoke. The method returns Promise<Session>.
Follow-up: Why await it? The operation is asynchronous because the SDK performs a backend request before returning the resulting Session.
The SDK method wraps the Backend API endpoint POST /sessions/{session_id}/revoke. Use the SDK method when working through clerkClient.
Follow-up: What must be substituted into the endpoint path? Replace {session_id} with the target session's identifier.
clerkClientSessionBAPI endpoint POST /sessions/{session_id}/revoke