For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Slack communityLog inBook a demo
  • Getting Started
    • Overview
    • Quickstart
    • Customer Showcase
  • Writing Content
    • Markdown
    • Visual Editor
    • Reusable Markdown
    • Custom React Components
      • Generate API Reference
      • SDK Snippets
      • HTTP Snippets
        • Overview
        • Auto-populate API Keys
      • Endpoint Errors
      • Audiences
      • Customize API Reference Layout
      • Write Markdown in API Reference
      • Generate Webhook Reference
      • Multiple Server URLs
      • Generate WebSocket Reference
      • Generate OpenRPC Reference
    • Changelog
LogoLogo
Slack communityLog inBook a demo
On this page
  • How it works
  • Setting up auto-populated API keys
API ReferencesAPI Explorer

Auto-populate API keys

Make integrating with your API frictionless by adding your login flow to the API Explorer.
Was this page helpful?
Previous

Endpoint errors configuration

Next
Built with

This feature is available on the Pro plan. Contact us to learn more.

Fern can integrate with your authentication flow, allowing users to login and have their API key automatically populated with the click of a button.

With this feature, you can create new users of your API directly from within your documentation.

How it works

To enable this feature, you need to configure authentication so that Fern can securely retrieve API keys for your users. The process works as follows:

  1. When a user clicks the “Login” button in the API Explorer, they are redirected to your authentication page.
  2. After successful authentication, your system must set a cookie called fern_token in the user’s browser.
  3. This token should be a JWT encrypted with a secret key that we provide. The JWT should contain the user’s API key.

The JWT should have a structure similar to:

1{
2 "fern": {
3 "playground": {
4 "initial_state": {
5 "auth": {
6 "bearer_token": "eyJhbGciOiJIUzI1c"
7 }
8 }
9 }
10 }
11}

Setting up auto-populated API keys

  • Reach out to Fern to get your secret key
  • Send Fern the URL of your authentication page (this is where users will be redirected to after clicking the “Login” button in the API Explorer)
  • Add logic to your service to set the fern_token cookie when a user logs in
For an example of how to set up the fern_token cookie, see our demo implementation here.