# How to secure, monitor, and revoke user sessions with Clerk

List a user's active [sessions](https://clerk.com/glossary.md#session) with `user.getSessions()` or the active devices list in `<UserProfile />`. Revoke one device with `session.revoke()` or, on the server, `clerkClient.sessions.revokeSession()`. To sign a user out everywhere, loop over `getSessionList()` with `revokeSession()`, or pass `signOutOfOtherSessions: true` on a password change.

Wrap user-initiated revocations in `useReverification()`. A session token issued before a revocation keeps passing local verification for up to 60 seconds, so sensitive routes also need a live session check.

This part builds on the [Next.js](https://clerk.com/glossary.md#next-js) 16 [Clerk quickstart](https://clerk.com/docs/nextjs/getting-started/quickstart.md) and covers how users sign out their own devices, how admins revoke sessions and offboard accounts (with an Express version of the admin endpoint), and where the same controls live in the Clerk Dashboard. Plan details and Dashboard labels reflect Clerk's docs as of October 2026. For concepts such as session hijacking and fixation, and for an evaluation checklist, read the [session management overview](https://clerk.com/blog/what-is-session-management.md).

> Tested on November 19, 2026 with `next` 16.4.6, [`@clerk/nextjs`](https://www.npmjs.com/package/@clerk/nextjs) 7.10.5, and `@clerk/express` 2.1.94 ([release notes](https://github.com/clerk/javascript/pull/10916)). The quickstart's [lockfile](https://github.com/clerk/clerk-nextjs-app-quickstart/blob/98fa16f453b5c9408e4c07bc21e933112e420ff1/pnpm-lock.yaml#L11-L16) resolves older versions (`@clerk/nextjs` 7.9.17, `next` 16.4.2) within its [`package.json`](https://github.com/clerk/clerk-nextjs-app-quickstart/blob/98fa16f453b5c9408e4c07bc21e933112e420ff1/package.json#L11-L16) caret ranges, so update `@clerk/nextjs` and `next` first.

## Why session invalidation is hard

**Session invalidation, also called [session revocation](https://clerk.com/glossary.md#session-revocation), ends a signed-in session before it expires so the credentials tied to it stop working.** The Open Worldwide Application Security Project (OWASP) says to "invalidate the session on both sides, client and server. The latter is the most relevant and mandatory from a security perspective" ([Session Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-expiration)).

Without revocation:

1. A lost or stolen laptop keeps access until its session expires. [Mandiant's M-Trends 2026](https://services.google.com/fh/files/misc/m-trends-2026-executive-edition-en.pdf) says of harvested long-lived [OAuth](https://clerk.com/glossary.md#oauth) tokens and session cookies: "Because these often remain valid post-logout, attackers can hijack sessions without triggering MFA alerts." The fix is [revoking that device](#revoke-one-device-with-sessionrevoke).
2. A password reset leaves an attacker's session alive, and OWASP recommends ending existing sessions after a reset ([Forgot Password Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html#user-resets-password)). The fix is [signing out everywhere](#sign-out-everywhere-revoke-sessions-after-a-password-reset-or-suspected-compromise).
3. An offboarded employee keeps working until their session ends. The fix is an [offboarding action](#offboarding-what-ban-lock-delete-and-scim-deprovisioning-do-to-sessions) that ends sessions and blocks sign-in.

**The JWT revocation problem.** A [JSON Web Token](https://clerk.com/glossary.md#json-web-token) (JWT) is verified from its own signature with no server lookup, so "JWTs cannot be revoked due to their self-contained nature" ([How Clerk works](https://clerk.com/docs/guides/how-clerk-works/overview.md#stateless-authentication)).

Session revocation and active-session visibility map to three requirements in the OWASP [Application Security Verification Standard (ASVS)](https://clerk.com/glossary.md#owasp-application-security-verification-standard) 5.0.0 ([V7](https://github.com/OWASP/ASVS/blob/v5.0.0_release/5.0/en/0x16-V7-Session-Management.md)): v5.0.0-7.5.2 (users view and end their sessions after authenticating again), v5.0.0-7.4.3 (offer to end other sessions after a factor change), and v5.0.0-7.4.5 (admins end a user's sessions).

## Approaches to multi-device session management and revocation

Each design trades per-request cost against revocation delay:

| Approach                                                                                                                                                                   | How revocation works                                                                                                                              | Cost per request                                                                                                                                            | Revocation delay                                          |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [Stateful server session](https://clerk.com/docs/guides/how-clerk-works/overview.md#stateful-authentication)                                                               | Delete the server record. The next lookup fails.                                                                                                  | A store lookup on every request                                                                                                                             | Next request                                              |
| [Stateless JWT](https://clerk.com/docs/guides/how-clerk-works/overview.md#stateless-authentication)                                                                        | Rotate the signing key, which signs everyone out                                                                                                  | None (local verification)                                                                                                                                   | Until the token's `exp`                                   |
| [JWT plus deny list](https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_Cheat_Sheet.html#jwt-denylist)                                                          | Add the token or session ID to a list that verifiers check                                                                                        | A list lookup per request, so sessions stop being fully stateless                                                                                           | Next check                                                |
| [Short-lived access token](https://www.rfc-editor.org/rfc/rfc7009.html#section-3) plus [refresh-token rotation](https://www.rfc-editor.org/rfc/rfc9700.html#section-2.2.2) | Revoke the [refresh token](https://clerk.com/glossary.md#refresh-token). The [access token](https://clerk.com/glossary.md#access-token) runs out. | A refresh call when the access token expires                                                                                                                | Up to the access token's lifetime                         |
| [Hybrid (Clerk)](https://clerk.com/docs/guides/how-clerk-works/overview.md#clerks-authentication-model)                                                                    | Revoke the server-side session so Clerk can't issue a new 60-second token                                                                         | None. The [software development kit (SDK)](https://clerk.com/glossary.md#software-development-kit-sdk) refreshes in the background on a 50-second interval. | Up to 60 seconds for a token issued before the revocation |

OWASP's Top 10:2025 advises: "Ideally, use a premade, well-trusted system to handle authentication, identity, and session management" ([A07:2025](https://top10.owasp.org/2025/A07_2025-Authentication_Failures/)).

## How Clerk session management works

[How Clerk works](https://clerk.com/docs/guides/how-clerk-works/overview.md) documents Clerk's full [authentication](https://clerk.com/glossary.md#authentication) model. Three parts of it determine how revocation behaves.

### Clients, sessions, and multi-session apps

A client is one browser or device, and Clerk's [`Client` object](https://clerk.com/docs/nextjs/reference/objects/client.md) "keeps track of the authenticated sessions in the current device." A session is one signed-in account on that client, so a user on a laptop and a phone has two clients with one session each.

A multi-session application "allows multiple accounts to be signed in from the same browser at the same time" ([session options](https://clerk.com/docs/guides/secure/session-options.md#multi-session-applications)). Multi-device sign-in works in either mode, because the multi-session setting governs accounts within one browser.

To enable multi-session apps, in the Clerk Dashboard, navigate to the [**Sessions**](https://dashboard.clerk.com/~/sessions) page and turn on **Multi-session handling**. Multi-session apps ("Simultaneous sessions" on the [pricing](https://clerk.com/pricing) page) are included in the Pro, Business, and Enterprise plans.

Only `active` and `pending` sessions are still open. A `pending` session has unfinished [session tasks](https://clerk.com/docs/guides/configure/session-tasks.md), and Clerk treats it as signed out. The other six [`SessionStatus`](https://clerk.com/docs/nextjs/reference/types/session-status.md) values, such as `revoked`, `ended`, and `expired`, mark finished sessions.

### Session lifetime and inactivity timeout

For web browser sessions, the maximum lifetime defaults to 7 days and the inactivity timeout is off. "Either one or both must be enabled at all times" ([session options](https://clerk.com/docs/guides/secure/session-options.md#session-lifetime)).

To set them, in the Clerk Dashboard, navigate to the [**Sessions**](https://dashboard.clerk.com/~/sessions) page, or run [`clerk config patch`](https://clerk.com/docs/cli.md#what-you-can-do) under `session_settings`. A custom maximum lifetime and the inactivity timeout need a paid plan for production use and are free in development. Hobby production instances keep a fixed 7-day lifetime ([pricing](https://clerk.com/pricing)).

Choosing a session lifetime is "a trade-off between security and user experience" ([session options](https://clerk.com/docs/guides/secure/session-options.md#session-lifetime)). A shorter maximum lifetime or inactivity timeout limits exposure from a forgotten or stolen device but makes users sign in more often. Neither setting changes the [revocation window](#the-60-second-session-token-and-the-revocation-window).

For reference points, OWASP says "Common idle timeouts ranges are 2-5 minutes for high-value applications and 15-30 minutes for low risk applications" ([Session Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-expiration)). The National Institute of Standards and Technology (NIST) SP 800-63B-4 says the overall reauthentication timeout SHOULD be no more than 24 hours at authenticator assurance level 2 ([AAL2](https://pages.nist.gov/800-63-4/sp800-63b.html#aal2reauth)) and SHALL be no more than 12 hours at [AAL3](https://pages.nist.gov/800-63-4/sp800-63b.html#aal3reauth). Its inactivity timeouts SHOULD be no more than 1 hour at AAL2 and 15 minutes at AAL3.

### The 60-second session token and the revocation window

Clerk splits a signed-in session across two tokens ([How Clerk works](https://clerk.com/docs/guides/how-clerk-works/overview.md#clerks-authentication-model)). In production, the long-lived client token sits in an [HttpOnly](https://clerk.com/glossary.md#httponly-cookies) `__client` cookie on the [Frontend API](https://clerk.com/glossary.md#frontend-api) domain and is "the source of truth for authentication state" ([client token](https://clerk.com/docs/guides/how-clerk-works/overview.md#client-token)). The session token is a JWT in the `__session` cookie "that expires after 60 seconds," and Clerk's frontend SDKs refresh it on a [50-second interval](https://clerk.com/docs/guides/how-clerk-works/overview.md#token-refresh-mechanism).

In Next.js, `clerkMiddleware()` verifies the session token's signature and expiry locally for `auth()`, without asking Clerk whether the session is still active. [`authenticateRequest()`](https://clerk.com/docs/reference/backend/authenticate-request.md) is "Networkless if the `jwtKey` is provided."

**After you revoke a session, Clerk stops issuing session tokens for it, but a token issued before the revocation keeps passing local verification until it expires, up to 60 seconds later by default.** The revoked browser signs out at its next refresh. This revocation window is the trade-off for fast, local verification on every request.

[JWT template](https://clerk.com/docs/guides/sessions/jwt-templates.md) tokens and Backend API tokens created with a longer `expires_in_seconds` ([Backend API spec](https://github.com/clerk/openapi-specs/blob/cdd59c4139088a7f733e7fdf2aa73eb74877d967/bapi/2026-05-12.yml#L1236-L1263)) outlive a revocation until their own expiry. For sensitive actions, [Part 2](https://clerk.com/articles/how-to-secure-monitor-and-revoke-user-sessions-with-clerk-2.md#close-the-revocation-window-with-a-live-session-check) adds a live session check that closes the window.

## Let users see and sign out their own devices

Multi-device [session management](https://clerk.com/glossary.md#session-management) starts with a page where users list their active sessions and sign out any device they don't recognize. Clerk ships a drop-in component and the APIs to build your own.

### Drop-in: the active devices list in `<UserProfile />`

In the quickstart, selecting **Manage account** in `<UserButton />` opens `<UserProfile />`. Its **Security** page lists **Active devices**: each device's type, browser and version, IP address with city and country, and last active time, with a "This device" badge on the current one ([`<UserButton />`](https://clerk.com/docs/nextjs/reference/components/user/user-button.md), [source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/ui/src/components/UserProfile/ActiveDevicesSection.tsx#L20-L168)).

Every other device's three-dot menu has **Sign out of device** ([source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/localizations/src/en-US.ts#L2445-L2446)). Every Clerk plan, Hobby included, has device tracking and revocation ([pricing](https://clerk.com/pricing)).

Clerk requires a recent sign-in or reverification before a device sign-out, since "Revoke session" is a [protected sensitive action](https://clerk.com/docs/guides/secure/reverification.md#sensitive-actions-that-require-reverification). The password form on the same page has a **Sign out of all other devices** checkbox, checked by default ([source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/ui/src/components/UserProfile/PasswordForm.tsx#L88-L125)).

To give the profile its own page, render `<UserProfile />` on an optional catch-all route. The component reads the URL from the request, so wrap it in `<Suspense>`. Without the boundary, `next build` fails in apps that use [Cache Components](https://clerk.com/docs/guides/development/rendering-modes.md#prebuilt-components-on-catch-all-routes), which the quickstart enables:

filename: app/user-profile/[[...user-profile]]/page.tsx
```tsx
import { UserProfile } from '@clerk/nextjs'
import { Suspense } from 'react'

export default function UserProfilePage() {
  return (
    <Suspense>
      <UserProfile />
    </Suspense>
  )
}
```

Then pass `userProfileMode="navigation"` and `userProfileUrl="/user-profile"` to `<UserButton />` so **Manage account** navigates to `/user-profile`.

### List active sessions with `user.getSessions()`

For your own UI, `user.getSessions()` "Gets all active sessions for this user" ([`User` object](https://clerk.com/docs/nextjs/reference/objects/user.md#getsessions)). Each [`SessionWithActivities`](https://clerk.com/docs/nextjs/reference/types/session-with-activities.md) has `id`, `status`, `lastActiveAt`, `expireAt`, `abandonAt`, and a `latestActivity` object with the [fields](https://clerk.com/docs/nextjs/reference/types/session-with-activities.md#sessionactivity) `browserName`, `browserVersion`, `deviceType`, `isMobile`, `ipAddress`, `city`, and `country`. This client component lists them and marks the current device:

filename: app/devices/active-devices.tsx
```tsx
'use client'

import { useReverification, useSession, useUser } from '@clerk/nextjs'
import { isClerkAPIResponseError, isReverificationCancelledError } from '@clerk/nextjs/errors'
import type { SessionWithActivitiesResource } from '@clerk/nextjs/types'
import { useEffect, useState } from 'react'

export function ActiveDevices() {
  const { user } = useUser()
  const { session: current } = useSession()
  const [sessions, setSessions] = useState<SessionWithActivitiesResource[]>([])

  useEffect(() => {
    if (!user) return
    let ignore = false
    user.getSessions().then((list) => {
      if (!ignore) setSessions(list)
    })
    return () => {
      ignore = true
    }
  }, [user])

  // Paste the hooks and handlers from the next two sections here

  return (
    <div>
      <ul>
        {sessions.map((s) => {
          const a = s.latestActivity
          return (
            <li key={s.id}>
              {a.browserName} {a.browserVersion} ({a.isMobile ? 'mobile' : a.deviceType})
              <br />
              {a.city}, {a.country} ({a.ipAddress})
              <br />
              Last active {s.lastActiveAt.toLocaleString()}
              {s.id === current?.id ? (
                <strong> This device</strong>
              ) : (
                <button onClick={() => signOutDevice(s)}>Sign out of device</button>
              )}
            </li>
          )
        })}
      </ul>
      {sessions.length > 1 && (
        <button onClick={signOutOtherDevices}>Sign out of other listed devices</button>
      )}
    </div>
  )
}
```

Render `<ActiveDevices />` on any signed-in page, such as `app/devices/page.tsx`. Clerk resolves city and country by IP address geolocation, so treat them as approximate ([`SessionActivity`](https://clerk.com/docs/reference/backend/types/backend-session-activity.md)). There's no operating-system field, so branch on `isMobile` and use `deviceType` as a display label.

`getSessions()` [uses a cache](https://clerk.com/docs/nextjs/reference/objects/user.md#getsessions) ([source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/clerk-js/src/core/resources/User.ts#L307-L314)), so the component keeps the list in [React](https://clerk.com/glossary.md#react) state and updates it after each revocation. The `ignore` flag drops a response that arrives after the user switches accounts in a multi-session app. In multi-session apps, [`useSessionList()`](https://clerk.com/docs/nextjs/reference/hooks/use-session-list.md) returns the sessions registered on this browser, while `user.getSessions()` returns the user's active sessions across devices.

### Revoke one device with `session.revoke()`

`revoke()` ends the session it's called on, with two limits: "If this is the active session, the attempt to revoke it will fail. Users can revoke only their own sessions" ([`revoke()`](https://clerk.com/docs/nextjs/reference/types/session-with-activities.md#revoke)). The component hides the button on the current device, where `signOut()` applies.

Once the [reverification window](https://clerk.com/docs/guides/secure/reverification.md#customize-the-reverification-window) passes (10 minutes by default), a revoke request fails with [`session_reverification_required`](https://clerk.com/docs/guides/development/errors/frontend-api.md#sessionreverificationrequired) until the user verifies again. [`useReverification()`](https://clerk.com/docs/nextjs/reference/hooks/use-reverification.md) shows Clerk's prompt and retries the call, so wrap every custom `revoke()` call in it:

filename: app/devices/active-devices.tsx
```tsx
const revokeDevice = useReverification((s: SessionWithActivitiesResource) => s.revoke())

async function signOutDevice(s: SessionWithActivitiesResource) {
  try {
    const revoked = await revokeDevice(s)
    if (revoked.status === 'revoked') {
      setSessions((prev) => prev.filter((p) => p.id !== s.id))
    }
  } catch (err) {
    if (isReverificationCancelledError(err)) return
    console.error(err)
  }
}
```

If the browser is offline, the request fails without an error and `revoke()` resolves with the session unchanged ([source](https://github.com/clerk/javascript/blob/50defde36b6b8811217b1f0dafe6269316134276/packages/clerk-js/src/core/resources/Base.ts#L122-L131)), so the device stays listed and the user can try again.

Canceling the prompt rejects the call with a `ClerkRuntimeError` coded `reverification_cancelled` ([source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/shared/src/react/hooks/useReverification.ts#L124-L130)). Catch it with [`isReverificationCancelledError()`](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/shared/src/errors/helpers.ts#L97-L99) from `@clerk/nextjs/errors` and return quietly. Log any other error, since rethrowing from a click handler leaves an unhandled rejection.

### Sign out of all other devices

Skip the current session, and keep sessions whose status is `active` or `pending` (Clerk's own list [shows both](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/ui/src/components/UserProfile/ActiveDevicesSection.tsx#L53-L57)). Revoke them with `Promise.allSettled` inside one `useReverification()` wrapper. That way, the user sees one prompt, and the hook then [retries the callback once](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/shared/src/react/hooks/useReverification.ts#L157-L165):

filename: app/devices/active-devices.tsx
```tsx
const revokeOtherDevices = useReverification(async () => {
  const others = sessions.filter(
    (s) => s.id !== current?.id && (s.status === 'active' || s.status === 'pending'),
  )
  const results = await Promise.allSettled(others.map((s) => s.revoke()))
  const revokedIds = results.flatMap((r) =>
    r.status === 'fulfilled' && r.value.status === 'revoked' ? [r.value.id] : [],
  )
  setSessions((prev) => prev.filter((s) => !revokedIds.includes(s.id)))
  const errors = results.flatMap((r) => (r.status === 'rejected' ? [r.reason] : []))
  const failed =
    errors.find(
      (e) =>
        isClerkAPIResponseError(e) &&
        e.errors.some((x) => x.code === 'session_reverification_required'),
    ) ?? errors[0]
  if (failed) throw failed
})

async function signOutOtherDevices() {
  try {
    await revokeOtherDevices()
  } catch (err) {
    if (isReverificationCancelledError(err)) return
    console.error(err)
  }
}
```

The hook prompts only for a `session_reverification_required` error and rethrows anything else ([source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/shared/src/react/hooks/useReverification.ts#L17-L32)). Rethrowing that error ahead of other failures means a network error on one device can't hide the prompt, and the retry covers only the devices left.

The button renders only once another device is listed, and it signs out the devices that `getSessions()` loaded when the page opened. For sessions created after the page loaded, use the [backend `revokeAllSessions()` helper](#sign-out-everywhere-revoke-sessions-after-a-password-reset-or-suspected-compromise).

**`signOut()` ends the session in the current browser. The user's sessions on other devices stay active until you revoke them with `session.revoke()` or `revokeSession()`** ([sign-out guide](https://clerk.com/docs/guides/development/custom-flows/authentication/sign-out.md)). To sign a user out of every listed device from the browser, revoke the other sessions, then call `signOut()`.

### Multi-session apps: `signOut({ sessionId })` vs. `signOut()`

In a multi-session app, `signOut({ sessionId })` from the [`Clerk` object](https://clerk.com/docs/nextjs/reference/objects/clerk.md#signout) signs out one account in this browser, and `signOut()` signs out every account in this browser. Neither touches other devices.

Custom `signOut()` calls redirect to their `redirectUrl` option or the `afterSignOutUrl` prop on [`<ClerkProvider>`](https://clerk.com/glossary.md#clerkprovider). Prebuilt components use the `afterMultiSessionSingleSignOutUrl` prop on `<ClerkProvider>` when other accounts stay signed in ([source](https://github.com/clerk/javascript/blob/750e7fc544361b763089c21113f3297cb15b7ef2/packages/ui/src/components/UserButton/useMultisessionActions.tsx#L33-L40)).

## Manage and revoke user sessions from the backend

Backend API calls can revoke any user's sessions, so every admin route in this section runs server-side and checks the caller's [authorization](https://clerk.com/glossary.md#authorization) inside the handler. Clerk's [`clerkMiddleware()` reference](https://clerk.com/docs/nextjs/reference/clerk-middleware.md#protecting-routes) says to "protect access as close to the resource as possible, in the code that reads or mutates the data."

The examples use Clerk's Basic role-based access control ([RBAC](https://clerk.com/glossary.md#role-based-access-control-rbac)) pattern for apps that, like the quickstart, don't use [Organizations](https://clerk.com/glossary.md#organizations) ([Basic RBAC](https://clerk.com/docs/guides/secure/basic-rbac.md)). Apps on Organizations can check `has({ permission })` instead ([authorization checks](https://clerk.com/docs/guides/secure/authorization-checks.md)).

To set it up:

1. In the Clerk Dashboard, navigate to the [**Sessions**](https://dashboard.clerk.com/~/sessions) page. Under **Customize session token**, add `{ "metadata": "{{user.public_metadata}}" }` to the session token's [claims](https://clerk.com/glossary.md#claim) in the **Claims** editor and select **Save**.
2. Declare `CustomJwtSessionClaims` in `types/globals.d.ts` as the Basic RBAC guide shows.
3. To make yourself an admin, in the Clerk Dashboard, navigate to the [**Users**](https://dashboard.clerk.com/~/users) page and select your account. Select **Edit** next to **Public** in the **User metadata** section, add `{ "role": "admin" }`, and select **Save**.

Without that [role](https://clerk.com/glossary.md#roles), the admin routes below return 403 to every signed-in caller. Session-token claims can lag the underlying data by up to 60 seconds ([customize session tokens](https://clerk.com/docs/guides/sessions/customize-session-tokens.md)), so the highest-impact route re-reads the caller with `users.getUser()`.

### List a user's active sessions with `getSessionList()`

For an admin or support view, this route returns a user's active sessions with the same device details the client SDK exposes:

filename: app/api/admin/users/[userId]/sessions/route.ts
```ts
import { auth, clerkClient } from '@clerk/nextjs/server'
import { NextResponse, type NextRequest } from 'next/server'

type Context = { params: Promise<{ userId: string }> }

export async function GET(_req: NextRequest, { params }: Context) {
  const { isAuthenticated, sessionClaims } = await auth()
  if (!isAuthenticated) {
    return NextResponse.json({ error: 'Unauthenticated' }, { status: 401 })
  }
  if (sessionClaims?.metadata?.role !== 'admin') {
    return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
  }

  const { userId } = await params
  const client = await clerkClient()
  const { data, totalCount } = await client.sessions.getSessionList({
    userId,
    status: 'active',
    limit: 100,
  })

  const sessions = data.map((s) => ({
    id: s.id,
    lastActiveAt: s.lastActiveAt,
    impersonated: s.actor !== null && s.actor.type !== 'agent',
    activity: s.latestActivity,
  }))

  return NextResponse.json({ sessions, totalCount })
}
```

`getSessionList()` "Requires either `clientId` or `userId`" and returns `{ data, totalCount }`, newest first. `limit` defaults to 10 and goes up to 500 ([`getSessionList()`](https://clerk.com/docs/reference/backend/sessions/get-session-list.md)). "Old and inactive sessions are periodically cleaned up" ([API spec](https://github.com/clerk/openapi-specs/blob/cdd59c4139088a7f733e7fdf2aa73eb74877d967/bapi/2026-05-12.yml#L995-L1050)), so the list omits them.

A non-null `actor` marks an impersonation session ([`Session`](https://clerk.com/docs/reference/backend/types/backend-session.md)) or, when `actor.type` is `'agent'`, an [Agent Task](https://clerk.com/docs/guides/development/testing/agent-tasks.md) session ([`agent`](https://clerk.com/docs/nextjs/reference/objects/session.md#agent)). Flag impersonations in admin views.

### Revoke one session with `revokeSession()`

`await client.sessions.revokeSession(sessionId)` "Revokes the given session. The user will be signed out from the client the session is associated with" ([`revokeSession()`](https://clerk.com/docs/reference/backend/sessions/revoke-session.md)). The status becomes `revoked`, "an unauthenticated state" ([API spec](https://github.com/clerk/openapi-specs/blob/cdd59c4139088a7f733e7fdf2aa73eb74877d967/bapi/2026-05-12.yml#L1209-L1235)), and the device loses access within the [revocation window](#the-60-second-session-token-and-the-revocation-window).

### Sign out everywhere: revoke sessions after a password reset or suspected compromise

To sign a user out of all devices, revoke every active or pending session. Two of the three common cases need no loop.

**Password changes.** Pass `signOutOfOtherSessions: true`. On the client, call `user.updatePassword()` inside `useReverification()` ([update password flow](https://clerk.com/docs/guides/development/custom-flows/account-updates/update-password.md)). On the backend, `users.updateUser(userId, { password, signOutOfOtherSessions: true })` accepts the flag only with a new password ([`updateUser()`](https://clerk.com/docs/reference/backend/user/update-user.md), [API spec](https://github.com/clerk/openapi-specs/blob/cdd59c4139088a7f733e7fdf2aa73eb74877d967/bapi/2026-05-12.yml#L2490-L2493)).

In the Core 3 reset flow from `useSignIn()`, call `signIn.resetPasswordEmailCode.submitPassword({ password, signOutOfOtherSessions: true })`, then call `signIn.finalize()` once `signIn.status` is `'complete'` ([forgot password flow](https://clerk.com/docs/guides/development/custom-flows/authentication/forgot-password.md)). If the status is `'needs_second_factor'`, complete the [multi-factor flow](https://clerk.com/docs/guides/development/custom-flows/authentication/multi-factor-authentication.md) before finalizing.

**Suspected compromise.** `users.setPasswordCompromised(userId, { revokeAllSessions: true })` revokes every session and prompts a password reset at the next sign-in ([`setPasswordCompromised()`](https://clerk.com/docs/reference/backend/user/set-password-compromised.md)). New instances have the reset-password [session task](https://clerk.com/docs/guides/configure/session-tasks.md) on by default. For older instances, in the Clerk Dashboard, navigate to the [**Updates**](https://dashboard.clerk.com/~/updates) page and turn on the **Reset password session task** update ([password protection](https://clerk.com/docs/guides/secure/password-protection-and-rules.md#manually-set-a-password-as-compromised), [changelog](https://clerk.com/changelog/2025-12-19-force-password-reset.md)).

**No password, or no forced reset.** Page through `getSessionList()` and revoke each session. This helper lists without a status filter and keeps `active` and `pending` sessions, so sessions with unfinished tasks end too.

Revoking leaves sign-in open, and the scan is best-effort: a sign-in or Clerk's cleanup of old sessions mid-scan can make it miss one. Lock the user first, or ban them when every session must end, since `banUser()` revokes all of them server-side ([API spec](https://github.com/clerk/openapi-specs/blob/cdd59c4139088a7f733e7fdf2aa73eb74877d967/bapi/2026-05-12.yml#L2574)):

filename: lib/revoke-all-sessions.ts
```ts
import type { clerkClient } from '@clerk/nextjs/server'

type ClerkClient = Awaited<ReturnType<typeof clerkClient>>

export async function revokeAllSessions(client: ClerkClient, userId: string) {
  const ids: string[] = []
  let offset = 0

  while (true) {
    const { data, totalCount } = await client.sessions.getSessionList({
      userId,
      limit: 500,
      offset,
    })
    for (const s of data) {
      if (s.status === 'active' || s.status === 'pending') ids.push(s.id)
    }
    offset += data.length
    if (!data.length || offset >= totalCount) break
  }

  for (const id of ids) {
    await client.sessions.revokeSession(id)
  }

  return ids.length
}
```

The helper revokes one session at a time to keep the request rate low. The Backend API [rate limits](https://clerk.com/glossary.md#rate-limiting) are 1,000 requests per 10 seconds on production instances and 100 on development instances ([Clerk rate limits](https://clerk.com/docs/guides/how-clerk-works/system-limits.md)).

Backend API calls run with your [secret key](https://clerk.com/glossary.md#secret-key), so reverification is your route's job. Add this `DELETE` handler to the same route file. The role check runs before reverification, so non-admins get a 403 without a prompt. [Part 2](https://clerk.com/articles/how-to-secure-monitor-and-revoke-user-sessions-with-clerk-2.md#prompt-and-retry-on-the-client-with-usereverification) explains how the client handles the reverification 403:

filename: app/api/admin/users/[userId]/sessions/route.ts
```ts
import { auth, clerkClient, reverificationErrorResponse } from '@clerk/nextjs/server'
import { NextResponse, type NextRequest } from 'next/server'
import { revokeAllSessions } from '@/lib/revoke-all-sessions'

// Keep the Context type and GET handler from above

export async function DELETE(_req: NextRequest, { params }: Context) {
  const { isAuthenticated, userId: callerId, sessionId, sessionClaims, has } = await auth()
  if (!isAuthenticated) {
    return NextResponse.json({ error: 'Unauthenticated' }, { status: 401 })
  }
  if (sessionClaims?.metadata?.role !== 'admin') {
    return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
  }
  if (!has({ reverification: 'strict' })) {
    return reverificationErrorResponse('strict')
  }

  // Live session check: the token can be up to 60 seconds behind a revocation or role change
  const client = await clerkClient()
  const [session, caller] = await Promise.all([
    client.sessions.getSession(sessionId).catch(() => null),
    client.users.getUser(callerId).catch(() => null),
  ])
  if (session?.status !== 'active') {
    return NextResponse.json({ error: 'Session ended' }, { status: 401 })
  }
  if (caller?.publicMetadata.role !== 'admin') {
    return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
  }

  const { userId } = await params
  const revoked = await revokeAllSessions(client, userId)
  return NextResponse.json({ revoked })
}
```

### Express version of the revoke-all endpoint

Backend-only apps can run the same revoke-all [endpoint](https://clerk.com/glossary.md#endpoint) on Express with `@clerk/express` ([Express quickstart](https://clerk.com/docs/expressjs/getting-started/quickstart.md)). Install the packages:

```bash
npm install express @clerk/express @clerk/shared
npm install -D tsx @types/express
```

Register [`clerkMiddleware()`](https://clerk.com/docs/expressjs/reference/clerk-middleware.md) before any other middleware, then read the caller with [`getAuth(req)`](https://clerk.com/docs/expressjs/reference/get-auth.md). The handler runs the same checks as the Next.js `DELETE` handler. `@clerk/express` doesn't export `reverificationError`, so the handler imports it from `@clerk/shared/authorization-errors` ([reverification guide](https://clerk.com/docs/guides/secure/reverification.md)):

filename: server.ts
```ts
import { clerkClient, clerkMiddleware, getAuth } from '@clerk/express'
import { reverificationError } from '@clerk/shared/authorization-errors'
import express from 'express'
import { revokeAllSessions } from './lib/revoke-all-sessions.js'

const app = express()
app.use(clerkMiddleware())

app.delete('/admin/users/:userId/sessions', async (req, res) => {
  const { isAuthenticated, userId: callerId, sessionId, sessionClaims, has } = getAuth(req)
  if (!isAuthenticated) {
    res.status(401).json({ error: 'Unauthenticated' })
    return
  }
  if (sessionClaims?.metadata?.role !== 'admin') {
    res.status(403).json({ error: 'Forbidden' })
    return
  }
  if (!has({ reverification: 'strict' })) {
    res.status(403).json(reverificationError('strict'))
    return
  }

  const [session, caller] = await Promise.all([
    clerkClient.sessions.getSession(sessionId).catch(() => null),
    clerkClient.users.getUser(callerId).catch(() => null),
  ])
  if (session?.status !== 'active') {
    res.status(401).json({ error: 'Session ended' })
    return
  }
  if (caller?.publicMetadata.role !== 'admin') {
    res.status(403).json({ error: 'Forbidden' })
    return
  }

  const revoked = await revokeAllSessions(clerkClient, req.params.userId)
  res.json({ revoked })
})

app.listen(3000)
```

To finish the setup:

1. Copy the `revokeAllSessions()` helper to `lib/revoke-all-sessions.ts` and replace its `clerkClient` import and `ClerkClient` type alias with `import type { ClerkClient } from '@clerk/express'`.
2. Add the [Basic RBAC](https://clerk.com/docs/guides/secure/basic-rbac.md) guide's `CustomJwtSessionClaims` declaration (`types/globals.d.ts`) so the role check type-checks.
3. Locally, run `npx tsx --env-file=.env server.ts` on Node 20.9 or later. In [production](https://clerk.com/docs/guides/development/deployment/production.md#api-keys-and-environment-variables), drop `--env-file` and set your production API keys as host environment variables ([quickstart `package.json`](https://github.com/clerk/clerk-express-quickstart/blob/f03183a0d3c720137c4c5e5015deac07cd84073d/package.json), [`@clerk/express`](https://www.npmjs.com/package/@clerk/express)). In ECMAScript module (ESM) projects, keep the helper import's `.js` extension.

### Offboarding: what ban, lock, delete, and SCIM deprovisioning do to sessions

To offboard a user, end their existing sessions and block new sign-ins:

| Action                                                                                                                                                                                                                                                          | Existing sessions         | New sign-ins                                                                                                                                                                                             | Audit signal                                                                                                                                                                                                                                                                          |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ban, [`users.banUser()`](https://clerk.com/docs/reference/backend/user/ban-user.md)                                                                                                                                                                             | Revoked                   | Blocked until unbanned                                                                                                                                                                                   | [`banned` flag](https://github.com/clerk/openapi-specs/blob/cdd59c4139088a7f733e7fdf2aa73eb74877d967/webhooks/2025-04-15.yml#L4151-L4168) in `user.updated` payloads, and the [`user.banned` log event](https://clerk.com/docs/guides/dashboard/logs/application-logs.md#user-events) |
| Lock, [`users.lockUser()`](https://clerk.com/docs/reference/backend/user/lock-user.md)                                                                                                                                                                          | Revoke them after locking | Blocked until the lock expires (1 hour by default, set with **Lockout duration** on the Protect → [**Sign-in security**](https://dashboard.clerk.com/~/protect/sign-in-security) page) or until unlocked | `locked` flag in `user.updated` payloads, and the `user.locked` log event                                                                                                                                                                                                             |
| Delete, [`users.deleteUser()`](https://clerk.com/docs/reference/backend/user/delete-user.md)                                                                                                                                                                    | Removed with the user     | Not possible (the user is gone)                                                                                                                                                                          | [`user.deleted` webhook](https://clerk.com/docs/guides/development/webhooks/syncing.md) and log event                                                                                                                                                                                 |
| System for Cross-domain Identity Management ([SCIM](https://clerk.com/docs/guides/configure/auth-strategies/enterprise-connections/directory-sync.md#how-directory-sync-works)) deprovisioning ([Directory Sync](https://clerk.com/glossary.md#directory-sync)) | Revoked                   | Blocked (user deactivated)                                                                                                                                                                               | `user.updated` webhook with `deprovisioned: true`                                                                                                                                                                                                                                     |

User bans are included in Clerk's Pro, Business, and Enterprise plans ([pricing](https://clerk.com/pricing)).

SCIM deprovisioning happens once the [identity provider](https://clerk.com/glossary.md#identity-provider) syncs the change, "which can take several minutes" ([Directory Sync](https://clerk.com/docs/guides/configure/auth-strategies/enterprise-connections/directory-sync.md#directory-sync-vs-jit-provisioning)). A user in several directories needs [deprovisioning](https://clerk.com/glossary.md#user-provisioning) in every enabled one ([multiple directories](https://clerk.com/docs/guides/configure/auth-strategies/enterprise-connections/directory-sync.md#users-managed-by-multiple-directories), [changelog](https://clerk.com/changelog/2026-09-24-multiple-enterprise-connections-per-organization.md)). EASIE deprovisioning (Google and Microsoft connections) revokes sessions after "a delay of up to 10 minutes" ([enterprise connections](https://clerk.com/docs/guides/configure/auth-strategies/enterprise-connections/overview.md#automatic-deprovisioning)).

Multi-factor authentication ([MFA](https://clerk.com/glossary.md#multi-factor-authentication-mfa)) resets and [blocklist](https://clerk.com/glossary.md#allowlist-denylist) changes leave sessions active ([MFA recovery](https://clerk.com/docs/guides/secure/mfa-recovery.md#what-a-reset-doesnt-do), [changelog](https://clerk.com/changelog/2025-08-08-allowlist-blocklist-on-sign-in.md)). For SCIM setup and [audit trails](https://clerk.com/glossary.md#event-audit-trail), see [HR-driven offboarding for B2B SaaS](https://clerk.com/articles/hr-driven-offboarding-for-b2b-saas-scim-webhooks-and-audit-trails.md).

## Manage sessions in the Clerk Dashboard

Support teams can revoke sessions and ban, lock, or delete a user without code from the user's [profile page](https://clerk.com/docs/guides/dashboard/user-profile.md#user-details). In the Clerk Dashboard, navigate to the [**Users**](https://dashboard.clerk.com/~/users) page, select the user, and go to the **Devices** section.

Each device's three-dot menu has **Revoke device**, and **Revoke all devices** sits at the bottom when 2 or more devices are listed. The **Actions** menu has **Ban user**, **Lock user**, **Unlock user**, and **Delete user**.

The same page has **Set password as compromised** in the **Password** section's three-dot menu, with an option to sign the user out of all active sessions ([password protection](https://clerk.com/docs/guides/secure/password-protection-and-rules.md#manually-set-a-password-as-compromised), [changelog](https://clerk.com/changelog/2025-12-19-force-password-reset.md)). **Impersonate user** is in the three-dot menu on the user's row on the **Users** page ([impersonation](https://clerk.com/docs/guides/users/impersonation.md)).

To lock accounts after failed sign-ins, in the Clerk Dashboard, navigate to the Protect → [**Sign-in security**](https://dashboard.clerk.com/~/protect/sign-in-security) page and turn on account lockout ([lockout settings](https://clerk.com/docs/guides/protect/user-lockout.md#settings)).

[Admin Logs](https://clerk.com/docs/guides/dashboard/logs/admin-logs.md) record admin actions such as session revocations, bans, and locks. They're available on the Business and Enterprise plans ([plans and retention](https://clerk.com/docs/guides/dashboard/logs/overview.md#plans-and-retention)).

## FAQ

## FAQ

### Can I limit how many devices a user is signed in on at once?

Enforce the cap in your app: on each `session.created` [webhook](https://clerk.com/articles/how-to-secure-monitor-and-revoke-user-sessions-with-clerk-2.md#verify-session-webhooks-in-a-nextjs-route-handler), list the user's active sessions with `getSessionList()` and revoke the oldest extras with `revokeSession()`. Webhooks can repeat, arrive late, or arrive out of order, so make the handler idempotent and treat the cap as best-effort. Multi-session mode (several accounts in one browser) is a separate setting.

### Does session management work the same in Expo and React Native?

Clerk's session APIs carry over. Backend code calls the same `getSession()`, `getSessionList()`, and `revokeSession()`, and the [Expo](https://clerk.com/glossary.md#expo) SDK exposes [`user.getSessions()`](https://clerk.com/docs/expo/reference/objects/user.md#getsessions) and [`session.revoke()`](https://clerk.com/docs/expo/reference/types/session-with-activities.md#revoke). For expiry handling, see [session expiry in React Native apps](https://clerk.com/articles/how-to-handle-session-expiry-in-a-react-native-app-with-clerk.md).

## Next steps: protect sensitive actions and monitor sessions

[Part 2](https://clerk.com/articles/how-to-secure-monitor-and-revoke-user-sessions-with-clerk-2.md) covers reverification and the live session check for sensitive actions, multi-device login tracking with session [webhooks](https://clerk.com/glossary.md#webhook) and Application Logs, and a comparison of Clerk, WorkOS, Auth0, and Supabase.

## In this series

1. **How to secure, monitor, and revoke user sessions with Clerk** (you are here)
2. [How to secure, monitor, and revoke user sessions with Clerk - Part 2](https://clerk.com/articles/how-to-secure-monitor-and-revoke-user-sessions-with-clerk-2.md)


## Series

- Part 2 of 2: https://clerk.com/articles/how-to-secure-monitor-and-revoke-user-sessions-with-clerk-2.md
