Skip to content

Commit ae6a958

Browse files
committed
Update sending-data.mdx
1 parent 24ce1d9 commit ae6a958

File tree

1 file changed

+64
-9
lines changed

1 file changed

+64
-9
lines changed

authentication-personalization/sending-data.mdx

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
title: "Sending Data"
3-
description: "The shape of user data you can use to personalize your docs"
3+
description: "User data format for personalizing your documentation"
44
icon: "send"
55
---
66

7-
Depending on your Handshake method, your API will respond with either a raw JSON object or a signed JWT. The shape of the data is the same for both:
7+
When implementing authentication or 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.
8+
9+
## User data format
810

911
```tsx
1012
type User = {
@@ -24,28 +26,81 @@ type User = {
2426
path="expiresAt"
2527
type="number"
2628
>
27-
The time at which this information should expire, in **seconds since epoch**. If the user loads the page and the current time is after this value, the stored data will be deleted.
28-
<Warning><b>For JWT Handshakes:</b> This is *not* the same as the `exp` claim of the JWT. The `exp` claim determines when a JWT should no longer be considered valid, and should be set as low as possible. In this case, it can probably be set to 10 seconds or lower. The `expiresAt` field determines when retrieved data should be considered stale, and can be anywhere from one day to several weeks.</Warning>
29+
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.
30+
<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>
2931
</ParamField>
3032
<ParamField
3133
path="groups"
3234
type="string[]"
3335
>
34-
A list of groups that the user belongs to. This will determine which pages should be shown to this user. If any of these groups is listed in the `groups` field of a page’s metadata, that page will be shown.
36+
A list of groups that the user belongs to. Pages with a matching `groups` field in their metadata will be visible to this user.
37+
38+
**Example**: User with `groups: ["admin", "engineering"]` can access pages tagged with either the `admin` or `engineering` groups.
3539
</ParamField>
3640
<ParamField
3741
path="content"
3842
type="object"
3943
>
40-
A bag of values that can be accessed from within MDX content using the `user` variable. For example, if you have supplied `{ firstName: 'Ronan' }` as your content field, you can use the following in your MDX: `Good morning, {user.firstName}!`
44+
Custom data accessible in your `MDX` content via the `user` variable. Use this for dynamic personalization throughout your documentation.
45+
46+
**Example**:
47+
```JSON
48+
{ "firstName": "Ronan", "company": "Acme Corp", "plan": "Enterprise" }
49+
```
50+
51+
**Usage in `MDX`**:
52+
```MDX
53+
Welcome back, {user.firstName}! Your {user.plan} plan includes...
54+
```
55+
With the example `user` data, this would render as: Welcome back, Ronan! Your Enterprise plan includes...
4156
</ParamField>
4257
<ParamField
4358
path="apiPlaygroundInputs"
4459
type="object"
4560
>
46-
User-specific values that will be prefilled in the API playground if supplied. For example, if each of my customers makes requests at a specific subdomain, I can send `{ server: { subdomain: 'foo' } }` as my `apiPlaygroundInputs` field, and this value will be prefilled on any API page with this `subdomain` value.
61+
User-specific values that will be prefilled in the API playground if supplied. Save users time when testing your APIs with their own data.
62+
63+
**Example**:
64+
```json
65+
{
66+
"header": { "X-API-Key": "user_api_key_123" },
67+
"server": { "subdomain": "foo" },
68+
"query": { "org_id": "12345" }
69+
}
70+
```
71+
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.
4772

48-
<Note>The`header`, `query`, and `cookie` fields will only be prefilled if they are part of your [security scheme](https://swagger.io/docs/specification/authentication/). Creating a standard header parameter named `Authorization` is not sufficient to enable this feature. To know if a field will be prefilled, navigate to your existing docs and check if the field is in either the `Authorization` or `Server` section.</Note>
73+
<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>
4974
</ParamField>
5075

51-
76+
## Example user data
77+
78+
```json
79+
{
80+
"expiresAt": 1735689600,
81+
"groups": ["admin", "beta-users"],
82+
"content": {
83+
"firstName": "Jane",
84+
"lastName": "Smith",
85+
"company": "TechCorp",
86+
"plan": "Enterprise",
87+
"region": "us-west"
88+
},
89+
"apiPlaygroundInputs": {
90+
"header": {
91+
"Authorization": "Bearer abc123",
92+
"X-Org-ID": "techcorp"
93+
},
94+
"server": {
95+
"environment": "production",
96+
"region": "us-west"
97+
}
98+
}
99+
}
100+
```
101+
102+
This enables:
103+
104+
* **Access control**: User sees `admin` and `beta-user` pages.
105+
* **Personalization**: Content personalization based on `user` data like `firstName`, `company`, and `plan`.
106+
* **API testing**: Pre-filled authentication and org-specific values.

0 commit comments

Comments
 (0)