You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/ask-fern/pages/getting-started/api-get-started.mdx
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,3 +14,31 @@ The Fern AI API allows you to manage your Ask Fern configuration using Fern's pu
14
14
## Authentication
15
15
16
16
Fern API requests require a bearer token for authentication. Use the CLI command [`fern token`](/learn/cli-api/cli-reference/commands#fern-token) to generate a bearer token. Tokens do not expire.
17
+
18
+
### JWT authentication flow
19
+
20
+
For accessing protected documentation endpoints, you can exchange a Fern API key for a JWT token:
21
+
22
+
1. Generate and export your Fern API key:
23
+
24
+
```bash
25
+
fern generate token
26
+
export FERN_API_KEY=<your-token>
27
+
```
28
+
29
+
2. Request a JWT from the authentication endpoint:
30
+
31
+
```bash
32
+
export JWT=$(curl -X GET https://docs.example.com/api/fern-docs/get-jwt \
33
+
-H "FERN_API_KEY:${FERN_API_KEY}" \
34
+
-H 'x-fern-host: docs.example.com')
35
+
```
36
+
37
+
3. Use the JWT to access protected endpoints:
38
+
39
+
```bash
40
+
curl -X GET https://docs.example.com/api/endpoint \
0 commit comments