Skip to content

Commit bf78486

Browse files
committed
move Sending data into Personalization
1 parent 2196da8 commit bf78486

File tree

2 files changed

+98
-105
lines changed

2 files changed

+98
-105
lines changed

authentication-personalization/personalization-setup.mdx

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,102 @@ description: "Let users log in for customized documentation experiences"
44
icon: "user-cog"
55
---
66

7-
Personalization lets you customize your documentation based on user information. This guide covers setup for each available handshake method.
7+
Customize your documentation based on user information, including prefilling API playground inputs and adding dynamic content.
8+
9+
## User data format
10+
11+
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.
12+
13+
```tsx
14+
type User = {
15+
expiresAt?: number;
16+
groups?: string[];
17+
content?: Record<string, any>;
18+
apiPlaygroundInputs?: {
19+
header?: Record<string, any>;
20+
query?: Record<string, any>;
21+
cookie?: Record<string, any>;
22+
server?: Record<string, string>;
23+
};
24+
};
25+
```
26+
27+
<ParamField
28+
path="expiresAt"
29+
type="number"
30+
>
31+
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.
32+
<Warning><b>For JWT handshakes:</b> 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).</Warning>
33+
</ParamField>
34+
<ParamField
35+
path="groups"
36+
type="string[]"
37+
>
38+
A list of groups that the user belongs to. Pages with a matching `groups` field in their metadata will be visible to this user.
39+
40+
**Example**: User with `groups: ["admin", "engineering"]` can access pages tagged with either the `admin` or `engineering` groups.
41+
</ParamField>
42+
<ParamField
43+
path="content"
44+
type="object"
45+
>
46+
Custom data accessible in your `MDX` content via the `user` variable. Use this for dynamic personalization throughout your documentation.
47+
48+
**Example**:
49+
```json
50+
{ "firstName": "Ronan", "company": "Acme Corp", "plan": "Enterprise" }
51+
```
52+
53+
**Usage in `MDX`**:
54+
```mdx
55+
Welcome back, {user.firstName}! Your {user.plan} plan includes...
56+
```
57+
With the example `user` data, this would render as: Welcome back, Ronan! Your Enterprise plan includes...
58+
</ParamField>
59+
<ParamField
60+
path="apiPlaygroundInputs"
61+
type="object"
62+
>
63+
User-specific values that will be prefilled in the API playground if supplied. Save users time when testing your APIs with their own data.
64+
65+
**Example**:
66+
```json
67+
{
68+
"header": { "X-API-Key": "user_api_key_123" },
69+
"server": { "subdomain": "foo" },
70+
"query": { "org_id": "12345" }
71+
}
72+
```
73+
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.
74+
75+
<Note>The `header`, `query`, and `cookie` fields will only prefill if they are part of your [OpenAPI security scheme](https://swagger.io/docs/specification/authentication/). 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.</Note>
76+
</ParamField>
77+
78+
### Example user data
879

9-
**Need help choosing?** See the [overview](/authentication-personalization/overview) to compare options.
80+
```json
81+
{
82+
"expiresAt": 1735689600,
83+
"groups": ["admin", "beta-users"],
84+
"content": {
85+
"firstName": "Jane",
86+
"lastName": "Smith",
87+
"company": "TechCorp",
88+
"plan": "Enterprise",
89+
"region": "us-west"
90+
},
91+
"apiPlaygroundInputs": {
92+
"header": {
93+
"Authorization": "Bearer abc123",
94+
"X-Org-ID": "techcorp"
95+
},
96+
"server": {
97+
"environment": "production",
98+
"region": "us-west"
99+
}
100+
}
101+
}
102+
```
10103

11104
## Configuring personalization
12105

@@ -33,7 +126,7 @@ Select the handshake method that you want to configure.
33126
<Step title="Integrate Mintlify personalization into your login flow.">
34127
Modify your existing login flow to include these steps after user login:
35128

36-
* Create a JWT containing the logged in user's info in the `User` format. See [Sending Data](/authentication-personalization/sending-data) for more information.
129+
* Create a JWT containing the logged in user's info in the `User` format. See the [User data format](#user-data-format) section above for more information.
37130
* Sign the JWT with the secret key, using the ES256 algorithm.
38131
* Create a redirect URL back to your docs, including the JWT as the hash.
39132
</Step>
@@ -95,7 +188,7 @@ To redirect users to specific sections after login, use this URL format: `https:
95188
<Step title="Create user info API endpoint.">
96189
Create an API endpoint that:
97190
* Accepts OAuth access tokens for authentication.
98-
* Returns user data in the `User` format. See [Sending Data](/authentication-personalization/sending-data) for more information.
191+
* Returns user data in the `User` format. See the [User data format](#user-data-format) section above for more information.
99192
* Defines the scopes for access.
100193
</Step>
101194
<Step title="Configure your OAuth personalization settings.">
@@ -157,7 +250,7 @@ Your documentation is hosted at `foo.com/docs` and you have an existing OAuth se
157250
<Step title="Create user info API endpoint.">
158251
Create an API endpoint that:
159252
* Uses your existing session authentication to identify users
160-
* Returns user data in the `User` format (see [Sending Data](/authentication-personalization/sending-data))
253+
* Returns user data in the `User` format (see the [User data format](#user-data-format) section above)
161254
* If the API domain and the docs domain **do not exactly match**:
162255
* Add the docs domain to your API's `Access-Control-Allow-Origin` header (must not be `*`).
163256
* Set your API's `Access-Control-Allow-Credentials` header to `true`.

authentication-personalization/sending-data.mdx

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)