Personalization features
Customize content with these personalization capabilities.API key prefilling
Automatically populate API playground fields with user-specific values by returning matching field names in your user data. The field names in your user data must exactly match the names in the API playground for automatic prefilling to work.Dynamic MDX content
Display dynamic content based on user information like name, plan, or organization using theuser
variable.
Page visibility
Restrict which pages are visible to your users by addinggroups
fields to your pages’ frontmatter. By default, every page is visible to every user.
Users will only see pages for groups
that they are in.
User data format
When implementing personalization, your system returns user data in a specific format that enables content customization. This data can be sent as either a raw JSON object or within a signed JWT, depending on your handshake method. The shape of the data is the same for both.Session expiration time in seconds since epoch. If the user loads a page after this time, their stored data is automatically deleted and they must reauthenticate.
For JWT handshakes: This differs from the JWT’s
exp
claim, which determines when a JWT is considered invalid. Set the JWT exp
claim to a short duration (10 seconds or less) for security. Use expiresAt
for the actual session length (hours to weeks).List of groups the user belongs to. Pages with matching
groups
in their frontmatter are visible to this user.Example: User with groups: ["admin", "engineering"]
can access pages tagged with either the admin
or engineering
groups.Custom data accessible in your Usage in With the example
MDX
content via the user
variable. Use this for dynamic personalization throughout your documentation.Basic example:MDX
:user
data, this would render as: Welcome back, Ronan! Your Enterprise plan includes…Advanced conditional rendering:The information in
user
is only available for logged-in users. For logged-out users, the value of user
will be {}
. To prevent the page from crashing for logged-out users, always use optional chaining on your user
fields. For example, {user.org?.plan}
.User-specific values that prefill API playground fields. Saves users time by auto-populating their data when testing APIs.Example:If a user makes requests at a specific subdomain, you can send
{ server: { subdomain: 'foo' } }
as an apiPlaygroundInputs
field. This value will be prefilled on any API page with the subdomain
value.The
header
, query
, and cookie
fields will only prefill if they are part of your OpenAPI security scheme. If a field is in either the Authorization
or Server
sections, it will prefill. Creating a standard header parameter named Authorization
will not enable this feature.Example user data
Configuring personalization
Select the handshake method that you want to configure.Prerequisites
- A login system that can generate and sign JWTs
- A backend service that can create redirect URLs
Implementation
1
Generate a private key.
- In your dashboard, go to Authentication.
- Select Personalization.
- Select JWT.
- Enter the URL of your existing login flow and select Save changes.
- Select Generate new key.
- Store your key securely where it can be accessed by your backend.
2
Integrate Mintlify personalization into your login flow.
Modify your existing login flow to include these steps after user login:
- Create a JWT containing the logged-in user’s info in the
User
format. See the User data format section above for more information. - Sign the JWT with the secret key, using the ES256 algorithm.
- Create a redirect URL back to your docs, including the JWT as the hash.
Example
Your documentation is hosted atdocs.foo.com
. You want your docs to be separate from your dashboard (or you don’t have a dashboard) and enable personalization.Generate a JWT secret. Then create a login endpoint at https://foo.com/docs-login
that initiates a login flow to your documentation.After verifying user credentials:- Generate a JWT with user data in Mintlify’s format.
- Sign the JWT and redirect to
https://docs.foo.com#{SIGNED_JWT}
.
Preserving page anchors
To redirect users to specific sections after login, use this URL format:https://docs.foo.com/page#jwt={SIGNED_JWT}&anchor={ANCHOR}
.Example:- Original URL:
https://docs.foo.com/quickstart#step-one
- Redirect URL:
https://docs.foo.com/quickstart#jwt={SIGNED_JWT}&anchor=step-one