List all sessions
Query parameters
Number of items per page (min: 1, max: 1000).
Token for the next page of results. Returned in the
Link header of previous responses.Filter sessions by state:
true: Return only active sessionsfalse: Return only inactive sessions- Omitted: Return all sessions
Expand related resources in the response:
identity: Include full identity objectdevices: Include device history
Response
Returns an array of session objects:Session UUID.
Whether the session is currently active.
Timestamp when the session was authenticated (RFC3339 format).
Timestamp when the session expires.
Timestamp when the session was issued.
The identity associated with this session (if
expand=identity is set).AAL level:
aal0, aal1, aal2, or aal3. Higher numbers indicate stronger authentication.Array of authentication methods used in this session.
Device history for this session (if
expand=devices is set).Error responses
- 400: Invalid query parameters
Get a session
Path parameters
The session’s UUID.
Query parameters
Expand related resources:
identity: Include the full identity objectdevices: Include device history for this session
Response
Returns a session object with the same structure as the list endpoint.Error responses
- 400: Invalid request parameters
- 404: Session not found (may also indicate session doesn’t exist or has expired)
Deactivate a session
Path parameters
The session’s UUID.
Response
Returns 204 No Content on success.Error responses
- 400: Invalid session ID format
- 401: Unauthorized (invalid or missing access token)
Usage notes
Deactivating a session:- Sets the session’s
activefield tofalse - Invalidates any session tokens
- Forces the user to re-authenticate
- Does not delete the session record (use for audit purposes)
Extend a session
session.earliest_possible_extend configuration setting.
Path parameters
The session’s UUID.
Response
Returns 204 No Content on success. Some older Ory Network projects may return a 200 OK response with the updated session object in the body. This behavior is deprecated and should not be relied upon.Error responses
- 400: Invalid session ID or session cannot be extended yet
- 404: Session not found or session was already extended recently
Usage notes
This endpoint:- Extends the session’s
expires_attimestamp - Respects the
session.earliest_possible_extendconfiguration - Returns 404 for consecutive requests to extend the same session
- Does not modify the
authenticated_atorissued_attimestamps
Configuration
To configure session extension behavior, see thesession.lifespan and session.earliest_possible_extend settings in your Kratos configuration:
- Sessions last 24 hours from creation
- Sessions can only be extended once they’re at least 1 hour old
Retrieving the session ID
To get a session ID for extension:- Use the
/sessions/whoamiendpoint with a session token - Use the Ory SDK’s
toSession()method - Query sessions via
/admin/sessionsor/admin/identities/{id}/sessions
Session lifecycle
Understanding session states:Active session
active: trueexpires_atis in the future- Valid session token exists
- User is authenticated
Expired session
active: false(automatically set when expired)expires_atis in the past- Session token is invalid
- User must re-authenticate
Deactivated session
active: false(manually set via API)- May not be expired yet
- Session token is invalidated
- User must re-authenticate
Best practices
Monitoring sessions
- Regularly query sessions with
active=trueto monitor active users - Use
expand=devicesto track login locations and devices - Monitor
authenticator_assurance_levelfor security compliance
Security considerations
- Deactivate sessions when suspicious activity is detected
- Don’t extend sessions indefinitely - require periodic re-authentication
- Track
authentication_methodsto ensure MFA compliance
Performance
- Use pagination for large session lists
- Only expand resources when needed
- Cache session data with appropriate TTLs