Skip to main content
To configure anonymous sessions, you can use the Auth0 Dashboard or the Auth0 Management API.

Prerequisites

To use anonymous sessions:

Configure anonymous sessions in your Auth0 tenant

Using the Dashboard

  1. Go to Tenant Settings > Advanced, and scroll down to the session settings.
  2. Enter a value for the Anonymous Session Lifetime, in minutes.
  3. Enable or disable the Anonymous Session Cookie switch to control whether anonymous session requests return the auth0_anon cookie.

Using the Management API

To set the anonymous session lifetime and cookie behavior, make a PATCH request to the /api/v2/tenants/settings endpoint:
  • lifetime_in_minutes sets how long a session is valid for.
  • activate_cookie sets whether to issue the auth0_anon cookie in anonymous flows. Set this to false if you plan to use the cookieless transfer-ticket mechanism instead.

Enable anonymous sessions in your application

Using the Dashboard

  1. Go to Applications > Applications, and select the application you want to configure.
  2. Scroll down to the anonymous session settings.
  3. Enable the switch to allow this application to issue anonymous sessions.

Using the Management API

To enable anonymous sessions in your Auth0 application, make a PATCH request to the /api/v2/clients/{id} endpoint:

Enable anonymous access in your API

Using the Dashboard

  1. Go to Applications > APIs, and select the API you want to configure.
  2. Scroll to the Access token expiration section and set the Anonymous Access Token Lifetime, in seconds. The minimum is 1 day and the maximum is 30 days.
  3. Scroll to Application Access Policy, and set the Anonymous Access policy to Per-app authorization to enable anonymous sessions using this audience for their access tokens.

Using the Management API

To enable anonymous sessions in your API, make a PATCH request to the /api/v2/resource-servers/{id} endpoint:
  • token_lifetime_for_anonymous_access_tokens sets the expiration time, in seconds, of access tokens this API issues in an anonymous session context.
  • subject_type_authorization.anonymous_user sets whether individual applications can use this API in anonymous sessions (based on policies) or whether this API disallows issuing anonymous access tokens at all.

Create an API Access policy for anonymous users

Using the Dashboard

  1. Go to Applications > APIs, and select the API you want to configure.
  2. Navigate to the Application Access tab.
  3. For each application you want this API to issue access tokens to in an anonymous context, select Edit.
  4. In the drawer that appears, navigate to the Anonymous Access tab, and select the permissions you want to grant anonymous users requesting this audience when using this application.
  5. Select Save.

Using the Management API

Once anonymous sessions are enabled in your API, make a POST request to the /api/v2/client-grants endpoint:

Configure custom claims

You can configure custom claims to map anonymous session metadata directly into the access tokens issued for a specific audience. This is useful because there is no post-login Action execution in an anonymous-session context, so api.accessToken.setCustomClaim() isn’t available to enrich anonymous access tokens the way it is for authenticated ones. For more information, read Configure Custom Claims for Anonymous Sessions.

Create an anonymous session

Once anonymous sessions are configured in your tenant, application, and API, you can create an anonymous session by making a POST request to the /anonymous/token endpoint:
The response includes a session_token and an access_token:

Next steps