Understand how user sessions, access tokens, and refresh tokens work in AuthKit.
When a user signs in to an application, AuthKit creates a user session. Along with the User object, the authentication response includes an access token and a refresh token. The application uses these tokens to verify that the user’s session is still active.
Each user session can be viewed from within the WorkOS dashboard:

Navigate to Users and select a user. Then, switch to the Sessions tab and click on a user session for more details.
A session begins when a user successfully authenticates. The authentication response includes two tokens:
The lifecycle follows this pattern:

Session behavior is governed by three settings in the WorkOS dashboard: maximum session length, access token duration, and inactivity timeout. These are covered in Configuring Sessions.
The access token JWT includes the following claims:
sub: the WorkOS user IDsid: the session ID (used for signing out)iss: https://api.workos.com/ (or your custom auth domain if configured)org_id: the organization selected at sign-in time (if applicable)role: the role of the selected organization membership (only applicable if an organization is selected)permissions: the permissions assigned to the role (if applicable)exp: the standard expires_at claim (the token should not be trusted after this time)iat: the standard issued_at claimThe signing JWKS for validating access tokens can be found at http://api.workos.com/sso/jwks/<clientId>.
Refresh tokens may be rotated after use. When a refresh token is exchanged for a new access token, the response may include a new refresh token. Always replace the old refresh token with the newly returned one to avoid authentication failures.
For implementation details on storing and using tokens, see Integrating Sessions.