Session type represents the core session data stored for an authenticated user, including access and refresh tokens.
Type definition
Properties
The JWT access token used to authenticate API requests. This token contains encoded claims about the user’s session, including their ID, organization, and permissions.
The refresh token used to obtain a new access token when the current one expires. This token is long-lived and securely stored.
The authenticated user object from WorkOS, containing profile information such as:
id- Unique user identifieremail- User’s email addressfirstName- User’s first namelastName- User’s last name- Additional user attributes
Information about the admin user who is impersonating this user, if applicable. Only present during active impersonation sessions.
Impersonator
When an admin is impersonating a user, theimpersonator field contains:
The email address of the admin user performing the impersonation.
The reason provided for the impersonation session, or
null if no reason was given.Usage
TheSession type is used internally by AuthKit to manage user sessions. You typically work with the UserInfo type instead, which extends Session with additional decoded claims.
Saving a session manually
For advanced authentication flows, you can manually save a session usingsaveSession:
Related types
- UserInfo - Extended session information with decoded claims
- HandleAuthOptions - Configuration for the auth callback handler