Session Metadata is currently in Early Access for Enterprise customers only. By using this feature, you agree to the applicable Free Trial terms in Okta’s Master Subscription Agreement. To learn more about Auth0’s product release cycle, read Product Release Stages.
Auth0 Management API
You can manage session metadata CRUD (create, replace, update, delete) requests using the Management API:Calls to the
/api/v2/sessions/{id} endpoint require a Management API access token with the update:session scope.Retrieve existing session metadata
Make aGET request to the /api/v2/sessions/{id} endpoint:
Add or update existing session metadata
Make aPATCH request to the /api/v2/sessions/{id} endpoint:
Delete session metadata
Make aPATCH request to the /api/v2/sessions/{id} endpoint:
Auth0 Post-Login Actions
You can manage session metadata CRUD operations using theapi.session objects with a post-login Action. This allows you to manage session metadata based on user or context-specific logic.
Retrieve existing session metadata
Use theevent.session.metadata?.deviceName object to read the deviceName metadata:
The
event.session.metadata object includes metadata set in:
*Previous Actions within the same flow
*Prior transactions if the session was reusedAdd or update existing metadata
Use theapi.session.setMetadata() method to update the session metadata:
event.session object in subsequent Actions.
Delete session metadata
Use the followingapi.session objects to delete session metadata:
-
api.session.deleteMetadata("key")deletes the specified session metadata -
api.session.evictMetadata()deletes all session metadata
- Event object: Learn about the refresh token Event object and properties.
- API object: Learn about the refresh token API object and methods.
OIDC Back-Channel Logout
You can configure thelogout_token to include session metadata using the Auth0 Dashboard or the Management API.
Auth0 Dashboard
To configure OIDC Back-Channel Logout token with session metadata:- Navigate to Dashboard > Applications and select your application.
- Select the Settings tab.
- Under OpenID Connect Back-Channel Logout > Back-Channel Logout URL, add the application logout URI that will receive the logout_tokens.
-
Set Back-Channel Logout Initiators to either:
- Selected initiators only or
- All supported initiators
- Toggle on Include Session Metadata.
- Select Save Changes.
logout_token will include all stored session metadata.
Auth0 Management API
You can use the/api/v2/clients/{id} endpoint to update your application to include session metadata in the logout_token.
Make a PATCH request to the /api/v2/sessions/{id} endpoint:
Error handling
You can review Session metadata log events by navigating to Dashboard > Monitoring > Logs or retrieve logs using the Management API logs endpoint.- If an error occurs while adding or updating Session metadata with Actions, the authentication transaction fails and an error is returned to the callback URL.
f event code is logged with its correspoding error:
- If a failure occurs when managing Session metadata using the Auth0 Management API, the API responds with an
HTTP status: 400error and its corresponding message: