List and end sessions
Show the active sessions of a person, and end one of them or all of them.
What it shows
- An administrator lists the active sessions of a person. Each session is one browser in which the person is signed in.
- The administrator ends the oldest session. The person is signed out in that browser only.
- The administrator signs the person out everywhere. LumoAuth ends every session of the person.
- The second action also revokes the access tokens and the refresh tokens of the person. The first one does not.
Before you start
- An API key with the scopes
admin:sessions:readandadmin:sessions:write. The person who created the key must hold the permissionsusers.viewandusers.edit. - A test user who is signed in in two browsers, for example in a normal window and in a private window. Do not use your own account: the program signs the person out.
jq, and for the CLI tab thelumoCLI.
| Variable | Value |
|---|---|
LUMOAUTH_URL | The address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region. |
LUMOAUTH_ORG_ID | Your organization, for example acme-corp. |
LUMOAUTH_API_KEY | An API key with the scopes admin:sessions:read and admin:sessions:write. |
USER_ID | The ID of the person (a UUID). lumo users list --search maya -o json prints it. |
Code
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization.
- lumo CLI
- curl
accounts/sessions/cli/sessions.sh
#!/bin/sh
# List the sessions of a person, end the oldest one, then sign the person out
# everywhere, with the lumo CLI.
#
# sh accounts/sessions/cli/sessions.sh
#
# The script needs the lumo CLI and jq.
set -eu
# The CLI reads its own three variables. With them it needs no `lumo login`.
export LUMO_BASE_URL="$LUMOAUTH_URL" LUMO_ORG="$LUMOAUTH_ORG_ID" LUMO_API_KEY="$LUMOAUTH_API_KEY"
# 1. The active sessions of the person, the newest first.
show() {
lumo sessions list --user "$USER_ID" -o json |
jq -r '"sessions: \(.data | length)", (.data[] | " \(.id) \(.createdAt) \(.ipAddress)")'
}
show
# 2. End one session: here the oldest one. The person is signed out in that
# browser. The tokens of the applications stay valid.
SESSION_ID=$(lumo sessions list --user "$USER_ID" -o json | jq -r '.data[-1].id // empty')
if [ -n "$SESSION_ID" ]; then
lumo sessions revoke "$SESSION_ID" --quiet > /dev/null
echo "ended session $SESSION_ID"
show
fi
# 3. Sign the person out everywhere. This ends every session, and it also
# revokes the access tokens and the refresh tokens of the person.
lumo sessions revoke-all --user "$USER_ID" --quiet > /dev/null
echo "signed out everywhere"
show
sh accounts/sessions/cli/sessions.sh
accounts/sessions/http/sessions.sh
#!/bin/sh
# List the sessions of a person, end the oldest one, then sign the person out
# everywhere, with curl.
#
# sh accounts/sessions/http/sessions.sh
#
# The script needs curl and jq.
set -eu
API="$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1"
# One call to the Admin API: a method, a path, and the answer on standard output.
admin() {
curl --silent --show-error --fail-with-body --request "$1" "$API$2" \
--header "X-API-Key: $LUMOAUTH_API_KEY"
}
# 1. The active sessions of the person, the newest first.
show() {
admin GET "/admin/users/$USER_ID/sessions" |
jq -r '"sessions: \(.data | length)", (.data[] | " \(.id) \(.createdAt) \(.ipAddress)")'
}
show
# 2. End one session: here the oldest one. The person is signed out in that
# browser. The tokens of the applications stay valid.
SESSION_ID=$(admin GET "/admin/users/$USER_ID/sessions" | jq -r '.data[-1].id // empty')
if [ -n "$SESSION_ID" ]; then
admin DELETE "/admin/sessions/$SESSION_ID" > /dev/null
echo "ended session $SESSION_ID"
show
fi
# 3. Sign the person out everywhere. This ends every session, and it also
# revokes the access tokens and the refresh tokens of the person.
admin POST "/admin/users/$USER_ID/sessions/revoke" > /dev/null
echo "signed out everywhere"
show
sh accounts/sessions/http/sessions.sh
Check the result
Output
sessions: 2
1033 2026-11-28T01:21:16+00:00 203.0.113.45
1032 2026-11-28T01:21:15+00:00 203.0.113.45
ended session 1032
sessions: 1
1033 2026-11-28T01:21:16+00:00 203.0.113.45
signed out everywhere
sessions: 0
- After the second step, reload a LumoAuth page in the browser of the ended session, for example the account page. The browser shows the sign-in page.
- After the last step, an application of the person cannot use its refresh token: the token endpoint answers
invalid_grant. After the second step alone, the refresh token still works. - The audit log of the portal has one entry
session.revokedand one entrysession.revoked_all. - An application with a back-channel logout address receives a logout token in both cases. See Sign out of every application.
Limits
- The list holds active sessions only. It has no filter for ended sessions.
- A session ID is a number, not a UUID.
- An API that verifies an access token only by its signature accepts the token until it expires. Use token introspection where the revocation must count at once.
- People end their own sessions on the hosted page Your devices. See Link to the account pages.