Endpoint
Request Body
Provide either
userId or sessionHandles, but not both.Revoke all sessions for this user ID. Mutually exclusive with
sessionHandles.Array of session handles to revoke. Mutually exclusive with
userId.Example:When revoking by
userId, whether to revoke sessions across all tenants. Only applicable when userId is provided.true- Revoke sessions in all tenants (default)false- Revoke sessions only in the current tenant
When revoking by
userId, whether to revoke sessions for all linked accounts. Only applicable when userId is provided.true- Revoke sessions for all linked accounts (default)false- Revoke sessions only for the specified user ID
Response
Always returns
"OK" on success.Array of session handles that were successfully revoked.Example:
Example Requests
Revoke by Session Handles
Revoke All Sessions for User
Revoke User Sessions in Current Tenant Only
Example Response
Implementation Details
Source Code Reference
Implemented in:- API Handler: View source
- Session Logic: View source
Revocation Process
Revoke by Session Handles
- Extract Tenant IDs - Parse tenant ID from each session handle
- Group by Tenant - Organize session handles by tenant
- Revoke per Tenant - Delete sessions in each tenant’s storage
- Aggregate Results - Combine all revoked session handles
Revoke by User ID
- Resolve User Mapping - Convert external user ID to internal if mapping exists
- Determine Scope - Check
revokeAcrossAllTenantsandrevokeSessionsForLinkedAccounts - Find Sessions - Query all non-expired session handles for the user
- Include Linked Accounts - Optionally include sessions for linked accounts
- Revoke Sessions - Delete all found session handles
- Update Activity - Record user activity timestamp
Multi-Tenant Handling
Session handles encode tenant information:- Default tenant:
<uuid> - Named tenant:
<uuid>_<tenantId>
- Extracts tenant ID from each handle
- Loads appropriate tenant storage
- Deletes sessions in their respective tenants
Linked Accounts
WhenrevokeSessionsForLinkedAccounts: true, the system:
- Resolves the primary user for the given user ID
- Retrieves all linked login methods
- Revokes sessions for all linked user IDs
Use Cases
User Logout
Logout from All Devices
Administrative Session Management
Security Response
Security Considerations
Immediate Revocation
Revocation Scope
Linked Accounts: When using account linking, set
revokeSessionsForLinkedAccounts: true to ensure all associated sessions are revoked.Multi-Tenant: In multi-tenant setups,
revokeAcrossAllTenants: false only revokes sessions in the request’s tenant. Users may remain logged in on other tenants.User ID Mapping
The system automatically handles user ID mapping:- Accepts external user IDs
- Resolves to internal SuperTokens user IDs
- Revokes sessions associated with the internal ID
- Updates activity tracking correctly
Best Practices
- Always Revoke on Logout - Prevent session reuse by revoking sessions when users log out
- Revoke on Password Change - Invalidate all sessions when users change passwords
- Revoke on Security Events - Immediately revoke sessions on suspicious activity
- Use Linked Accounts Flag - When revoking by user ID, consider linked accounts
- Log Revocations - Audit log all session revocations for security monitoring
- Clear Client State - Clear client-side tokens after successful revocation
Error Handling
Invalid Parameters
The endpoint returns400 Bad Request if:
- Both
userIdandsessionHandlesare provided - Neither
userIdnorsessionHandlesare provided revokeAcrossAllTenantsis used withoutuserIdrevokeSessionsForLinkedAccountsis used withoutuserIdsessionHandlesis an empty array
Partial Revocation
When revoking multiple session handles:- Only valid, existing sessions are revoked
- Invalid or non-existent session handles are silently ignored
- Response includes only successfully revoked handles
Tenant Handling
If a tenant is deleted after fetching session handles but before revocation:- The system silently skips sessions from deleted tenants
- Other sessions are still revoked successfully
- No error is returned
Response Interpretation
Empty Revocation List
IfsessionHandlesRevoked is empty:
- By Session Handles: All provided handles were already revoked or invalid
- By User ID: User has no active sessions
Partial Revocation
If fewer handles are returned than requested:- Some session handles were already revoked
- Some session handles didn’t exist
- Some sessions were in deleted tenants
Performance Considerations
Revoke by User ID
Revoking by user ID is a multi-step operation:- Query all sessions for the user (potentially across multiple tenants)
- For linked accounts, query sessions for each linked user
- Delete all found sessions
Revoke by Session Handles
Revoking by session handles is more efficient:- Direct deletion of specified sessions
- No queries needed to find sessions
- Scales linearly with number of handles