Skip to content

Commit c8e2aed

Browse files
docs: add JWT authentication flow for protected endpoints
Co-Authored-By: [email protected] <[email protected]>
1 parent 8c7052f commit c8e2aed

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

fern/products/ask-fern/pages/getting-started/api-get-started.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,31 @@ The Fern AI API allows you to manage your Ask Fern configuration using Fern's pu
1414
## Authentication
1515

1616
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 \
41+
-H 'Accept: text/plain' \
42+
-H 'x-fern-host: docs.example.com' \
43+
-H "FERN_TOKEN: ${JWT}"
44+
```

0 commit comments

Comments
 (0)