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.
Book a demoLog inStart for free
  • CLI reference
    • Get started with Fern CLI
    • Global options
    • Commands
    • Changelog
Checking status...
SOC2Soc 2 Type II
© 2026 Fern • Birch Solutions, Inc., a Postman company

Documentation

SDKsDocsAsk FernCLI Reference

API Definitions

OpenAPIAsyncAPIOpenRPCgRPC

Resources

BlogSupportPricing

Company

Brand KitPrivacy PolicyTerms of Service
LogoLogo
Book a demoLog inStart for free
On this page
  • Documentation commands
  • SDK generation commands
  • Detailed command documentation
  • openapi
  • docs
  • mintlify
  • readme
  • api
  • group
  • preview
  • api
  • version
  • fernignore
  • local
  • force
  • no-replay
  • api
  • warnings
  • Usage in a GitHub Action
  • instance
  • preview
  • id
  • force
  • limit
  • page
  • port
  • url
  • output
  • output
  • device-code
  • email
  • api
  • exclude-models
  • list
  • generator
  • group
  • include-major
  • directory
  • no-check-markers
  • dry-run
  • yes
  • api
  • output
  • name
  • org
  • json
  • org
CLI reference

Commands

Learn about the Fern CLI commands.
||View as Markdown|
Was this page helpful?
Edit this page
Previous

Global options

Next

Changelog

CommandDescription
fern initCreate new Fern project from OpenAPI spec or scratch
fern checkValidate API definition & configuration
fern upgradeUpdate Fern CLI & generators to latest versions
fern loginLogin to Fern CLI via GitHub, Google, Postman, or enterprise SSO
fern logoutLog out of the Fern CLI
fern exportExport an OpenAPI spec for your API
fern api updateManually update your OpenAPI spec
fern api enrichMerge x-fern-examples from an overrides file into native OpenAPI examples

Documentation commands

CommandDescription
fern docs devRun local documentation preview server
fern docs diff BetaGenerate visual diffs between preview and production docs
fern generate --docsBuild & publish documentation updates
fern docs preview listList all preview deployments
fern docs preview deleteDelete a preview deployment
fern docs md checkValidate MDX syntax in documentation files
fern docs theme exportExport theme-eligible fields from docs.yml into a standalone directory
fern docs theme uploadUpload a theme to Fern’s registry
fern docs link checkCheck for broken links on a live documentation site
fern docs theme listList all themes for your organization

SDK generation commands

CommandDescription
fern generateBuild & publish SDK updates
fern write-overridesCreate OpenAPI customizations
fern generator upgradeUpdate SDK generators to latest versions
fern replay resolveResolve patch conflicts left by Fern Replay
fern replay forgetRemove tracked customization patches from .fern/replay.lock

Detailed command documentation

fern init

Use fern init to initialize a new Fern workspace in the current folder. By default, you’ll see the IMDb API example.

terminal
$fern init [--docs] [--openapi <path/url>]

When initializing with OpenAPI, your project structure will look like this:

fern
fern.config.json
generators.yml# generators you're using
openapi
openapi.json# your OpenAPI specification

openapi

Use --openapi to initialize a project from an OpenAPI specification:

$# Initialize from local file
$fern init --openapi ./path/to/openapi.yml
$
$# Initialize from URL
$fern init --openapi https://link.buildwithfern.com/petstore-openapi

docs

By adding --docs, you’ll also get a sample documentation website for your API with an API Reference section.

$fern init --docs

The file added will contain:

docs.yaml
1instances:
2 - url: https://your-organization.docs.buildwithfern.com
3title: Your Organization | Documentation
4navigation:
5 - api: API Reference
6colors:
7accent-primary: '#ffffff'
8background: '#000000'

To publish the API docs, run fern generate --docs.

mintlify

By adding --mintlify PATH_TO_MINT_CONFIG, the CLI will automatically convert your Mintlify docs folder into a Fern docs site, based on the mint.json file.

$fern init --mintlify PATH_TO_MINT_CONFIG

The CLI will create a fern/ folder with the following structure:

fern
fern.config.json# root-level configuration
docs.yml# docs configuration
...# any other files / pages needed in your docs

readme

The fern init command supports importing Readme generated docs sites. This requires having a local chromium browser instance installed. You can ensure this is installed by installing the fern cli from source, following the instructions here.

By adding --readme URL_TO_README_DOCS_SITE, the CLI will automatically convert the Readme generated docs site into a Fern docs site.

$fern init --readme URL_TO_README_DOCS_SITE

The CLI will create a fern/ folder with the following structure:

fern
fern.config.json# root-level configuration
docs.yml# docs configuration
...# any other files / pages needed in your docs

For more information on getting started, check out our Quickstart Guide

fern export

Use fern export to generate an OpenAPI spec for your API. This is useful when you’ve defined your API in a format other than OpenAPI (such as the Fern Definition) and need to export it for integration with other tools or services.

terminal
$fern export [--api <api>] path/to/openapi.yml
$fern export [--api <api>] path/to/openapi.json

api

Use --api to specify which API to export when you have multiple APIs defined in your fern/apis/ folder.

terminal
$fern export --api public-api path/to/openapi.yml
$fern export --api public-api path/to/openapi.json
fern generate

Use fern generate to run the Fern compiler and create SDKs for your API.

terminal
$fern generate [--group <group>] [--api <api>] [--version <version>] [--preview] [--fernignore <path>] [--local] [--force] [--no-replay]

group

Use --group <group> to specify which generator group to run. You can use either a group name or an alias name. Aliases are defined in your generators.yml and map to multiple groups, allowing you to run several groups in parallel with a single command.

$# Run a specific group
$fern generate --group python-sdk
$
$# Run all groups defined in the "all" alias
$fern generate --group all
$
$# Run all groups defined in the "frontend" alias
$fern generate --group frontend
$
$# Run a specific group locally (self-hosted)
$fern generate --group python-sdk --local

You can also set an alias as your default-group in generators.yml, so running fern generate without any arguments will run all groups in that alias.

The --group flag can be combined with other flags like --local for self-hosted SDK generation, --preview for local testing, or --version to specify the SDK version.

preview

Use --preview to test SDK changes locally before publishing. This is especially useful during development:

  • Generates SDK into a local .preview/ folder
  • No changes are published to package managers or GitHub
$# Preview all SDKs
$fern generate --preview
$
$# Preview specific SDK group
$fern generate --group python-sdk --preview

api

Use --api <api> to specify the API for SDK generation. This is useful when your project contains multiple API definitions. The API name should match the directory name in your fern/apis/ folder.

$fern generate --api public-api

version

Use --version to specify the SDK version number, typically following semantic versioning (semver) format (MAJOR.MINOR.PATCH). This is particularly useful in CI/CD pipelines when publishing SDK releases.

$# Generate all SDKs with version 2.11.0
$fern generate --version 2.11.0
$
$# Generate Python SDK for the payments API with version 1.2.3
$fern generate --api payments-api --group python-sdk --version 1.2.3

fernignore

Use --fernignore to specify a custom .fernignore file path for SDK generation. This allows you to temporarily test different ignore configurations without modifying the committed .fernignore in your repository.

Fern will use the specified file instead of the one on the main branch and commit the new .fernignore to your repository as part of the generation process.

$fern generate --fernignore ./custom-fernignore

local

Use --local to run SDK generation on your own machine instead of using Fern’s cloud infrastructure. This is useful for organizations with strict security or compliance requirements. See self-hosted SDKs for setup instructions.

$# Generate all SDKs locally
$fern generate --local
$
$# Generate specific SDK group locally
$fern generate --group python-sdk --local

A Docker daemon must be running on your machine, as SDK generation runs inside a Docker container.

By default, the CLI pulls generator images from Docker Hub. To pull from a custom container registry, use the image field in your generators.yml instead of name. See custom container registry for details.

force

Use --force to skip confirmation prompts during generation. This is useful in CI/CD environments where interactive prompts would block the pipeline.

$# Generate without confirmation prompts
$fern generate --group python-sdk --force

no-replay

Use --no-replay to skip Fern Replay’s patch detection and application phase for a single generation. The generation still produces the new SDK code, but tracked customization patches aren’t applied on top. Useful for a clean regeneration — for example, to debug whether a conflict is caused by a specific patch.

$fern generate --no-replay --local

--no-replay works only for local generation (--local).

fern check

The --broken-links and --strict-broken-links flags are deprecated. Use the broken-links validation rule in docs.yml instead.

Use fern check to validate your API definition and Fern configuration, including fern.config.json, generators.yml, and docs.yml. It checks for broken links, invalid API examples, configuration errors, and more. When all checks pass, the command produces no output.

Most fern check rules — including broken-links — validate against the navigation tree built from your local config and do not crawl your live deployed site or follow external URLs. The exception is the missing-redirects rule, which compares your local navigation against the previously published state and therefore requires fern login or FERN_TOKEN.

terminal
$fern check [--api <api>] [--warnings]

You can configure the severity of the validation rules run by fern check in your docs.yml file using the check.rules property.

docs.yml
1check:
2 rules:
3 broken-links: error
4 example-validation: warn
5 missing-redirects: error

To check links on a published site, use fern docs link check or the link checker in the Fern Dashboard instead.

api

Use --api <api> to specify which API you’d like to check.

$fern check --api public-api

warnings

Use --warnings to log warnings in addition to errors.

$fern check --warnings

Usage in a GitHub Action

.github/workflows/fern-check.yml
1name: Fern Validation Check
2
3on:
4 pull_request:
5 push:
6 branches:
7 - main
8
9jobs:
10 validate-fern-api:
11 name: Validate using Fern's linter
12 runs-on: ubuntu-latest
13 steps:
14 - name: Checkout repository
15 uses: actions/checkout@v4
16
17 - name: Install Fern CLI
18 run: npm install -g fern-api
19
20 - name: Validate API with Fern
21 run: fern check
fern generate --docs

Use fern generate --docs to create a documentation site for your API.

terminal
$fern generate --docs [instance <instance-url>] [--preview] [--id <name>] [--force]

instance

Use --instance to specify which instance URL in your docs.yml to generate documentation for.

$fern generate --docs --instance your-organization.docs.buildwithfern.com

preview

Use --preview to preview updates to your documentation before publishing changes to your production site.

$fern generate --docs --preview

id

Use --id with --preview to create a stable, named preview link. The preview URL follows the format {org}-preview-{id}.docs.buildwithfern.com, so rerunning with the same --id updates the existing preview in place rather than creating a new one.

$fern generate --docs --preview --id my-feature
$# -> https://your-org-preview-my-feature.docs.buildwithfern.com

This is useful in CI workflows where you want one preview URL per pull request. See Preview changes for details.

force

When reusing an --id that already exists, Fern prompts you to confirm the overwrite. Use --force to skip the confirmation. This is detected automatically in GitHub Actions, but is needed for other CI environments like Azure Pipelines.

$fern generate --docs --preview --id my-feature --force
fern docs preview list

Use fern docs preview list to list all preview deployments for your organization.

terminal
$fern docs preview list [--limit <number>] [--page <number>]

limit

Use --limit to specify the number of preview deployments to display per page.

$fern docs preview list --limit 20

page

Use --page to specify which page of results to display.

$fern docs preview list --page 2
fern docs preview delete

Use fern docs preview delete to delete a preview deployment generated with fern generate --docs --preview. The <url> argument is the full preview URL to delete.

terminal
$fern docs preview delete <url>
fern docs dev

Use fern docs dev to run a local development server to preview your docs.

terminal
$fern docs dev [--port <port-number>]
Windows: enable long path support

On Windows, fern docs dev requires long path support to be enabled.

To enable long path support, run the following command in an elevated PowerShell prompt, then restart your terminal:

1New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 -PropertyType DWORD -Force

If you can’t enable long path support, use Windows Subsystem for Linux (WSL) to run fern docs dev in a Linux environment instead.

port

Use --port <port-number> to specify the port the docs preview will be run on.

$fern docs dev --port 57908
fern docs link check

Use fern docs link check to scan a live documentation site for broken links. The command crawls the published site, checks every link, and reports broken (404) and blocked (403) URLs along with their source pages.

terminal
$fern docs link check [--url <url>] [--output <format>]

Unlike the broken-links rule in fern check, which validates only internal links in your local YAML navigation tree, fern docs link check checks all links — internal and external — on your live deployed site.

By default, the command auto-detects your docs URL from the instances in docs.yml. When all links are valid, the command exits with a success message.

The command first scrapes every page on the site, then checks each link it finds. When broken links are found, the output includes a summary and a grouped list of broken URLs with status codes and source file paths.

◆ Checking links on your-org.docs.buildwithfern.com...
Scraping pages [████████████████████] 100% | 42/42
Checking links [████████████████████] 100% | 240/240
Finished in 2 minutes, 23 seconds
Summary
Pages scanned 42
Links checked 240
✓ Working 228
✗ Broken 8 (external)
⚠ Blocked 4
─────────────────────────────────────
External Broken Links (8)
✗ https://example.com/removed-page → 404
fern/pages/quickstart.mdx
fern/pages/overview.mdx
✗ https://example.com/old-endpoint → 404
fern/pages/integrations.mdx

url

Use --url to specify which docs site to check. This is useful when you have multiple instances or want to check a preview deployment.

$fern docs link check --url https://your-org.docs.buildwithfern.com

output

Use --output to control the output format. Supported values are text (default), json, and csv.

$# JSON output for programmatic use
$fern docs link check --output json
$
$# CSV output for spreadsheets or reporting
$fern docs link check --output csv
fern docs md check

Use fern docs md check to validate MDX syntax across all documentation pages referenced in your navigation configuration, including docs.yml, versioned configuration files, and product-specific YAML files.

terminal
$fern docs md check

The command parses each MDX file and reports syntax errors with file paths and line:column numbers. The command accounts for frontmatter offsets, so reported line numbers correspond to the actual lines in your file.

fern/pages/quickstart.mdx:12:5
Unexpected closing tag, expected corresponding closing tag for `<CodeBlock>`
fern/pages/guide.mdx:45:1
Expected a closing tag for `<Note>` before the end of `paragraph`

When all files are valid, you’ll see a success message:

✓ All 42 MDX files are valid
fern docs diff
Beta

Use fern docs diff to generate visual diffs between your preview deployment and production docs. This command is intended for use in GitHub Actions. It captures screenshots of both versions and creates side-by-side comparison images.

terminal
$fern docs diff <preview-url> <files..> [--output <output-dir>]

Pass the preview URL from fern generate --docs --preview and one or more MDX file paths. Diff images are saved to .fern/diff by default.

$fern docs diff acme-preview-abc123.docs.buildwithfern.com fern/pages/intro.mdx fern/pages/quickstart.mdx

output

Use --output to specify a custom directory for diff images.

$fern docs diff acme-preview-abc123.docs.buildwithfern.com fern/pages/intro.mdx --output ./my-diffs
fern upgrade

Use fern upgrade to upgrade your compiler version in fern.config.json to the latest version. It will also upgrade generators in generators.yml to their minimum-compatible versions.

terminal
$fern upgrade
fern login

Use fern login to login to the Fern CLI via GitHub or Google. Logging in allows you join GitHub organizations, gain permissions, and contribute to projects.

terminal
$fern login
$fern login --device-code
$fern login --email <email>

By default, fern login opens a browser for GitHub, Google, or Postman authentication. Two alternative flows are available:

device-code

Use --device-code to login via device code authorization in environments where a browser cannot open automatically (e.g., SSH sessions or containers).

$fern login --device-code

email

Use --email to login via enterprise SSO. Pass the email address associated with your organization’s SSO provider.

$fern login --email user@example.com

To enable CI/CD, use fern token.

fern logout

Use fern logout to log out of the Fern CLI. This will clear your authentication credentials and revoke access to your GitHub organizations and permissions.

terminal
$fern logout

After logging out, you’ll need to run fern login again to access protected features.

fern token

Use fern token to generate a token for authenticating the Fern CLI in CI/CD environments. The token is specific to your organization defined in fern.config.json and doesn’t expire.

terminal
$fern token

See Publishing your docs for instructions on using this token in automated publishing workflows.

fern write-overrides

Use fern write-overrides to generate a basic OpenAPI overrides file. An overrides file allows for reversible revisions to the API specification, including adding request and response examples for code snippets in Fern Docs.

terminal
$fern write-overrides [--api <api>] [--exclude-models]

When run, this command creates a new file within fern/openapi/ called openapi-overrides.yml.

fern
fern.config.json
generators.yml
openapi
openapi-overrides.yaml# your overrides file
openapi.json

api

Use --api to specify the API to run the command on if multiple are defined.

$fern write-overrides --api public-api

exclude-models

Use --exclude-models to stub the models while generating the initial overrides (in addition to the endpoints).

$fern write-overrides --exclude-models
fern generator upgrade

Use fern generator upgrade to update all generators in your generators.yml to their latest versions.

This is different from fern upgrade which updates the Fern CLI version. Use both commands to keep your entire Fern toolchain up to date.

terminal
$fern generator upgrade [--list] [--generator <generator-name>] [--group <group>] [--include-major]

This command will:

  • Check for updates to all generators specified in your generators.yml
  • Update the generator versions to their latest compatible releases
  • Maintain compatibility with your current Fern compiler version

Here’s what you might see when updates are available:

┌───────────────────────────────────────────────────────────────────────────────────┐
│ │
│ Upgrades available │
│ │
│ │
│ C# SDK (API: openapi, Group: csharp-sdk) 1.9.11 → 1.9.15 │
│ Java SDK (API: openapi, Group: java-sdk) 2.2.0 → 2.11.3 │
│ Python SDK (API: openapi, Group: python-sdk) 4.3.10 → 4.3.11 │
│ │
│ Run fern generator upgrade to upgrade your generators. │
│ Run fern generator upgrade --list to see the full list of generator upgrades │
│ available. │
│ │
└───────────────────────────────────────────────────────────────────────────────────┘

list

Use --list to see the full list of generator upgrades available.

$fern generator upgrade --list

generator

Use --generator to specify a particular generator type to upgrade.

$fern generator upgrade --generator fernapi/fern-typescript-sdk
$fern generator upgrade --generator fernapi/fern-python-sdk

group

Use --group to upgrade generators within a specific group in your generators.yml. If not specified, all generators of the specified type will be upgraded.

$fern generator upgrade --group public

include-major

$fern generator upgrade --include-major

Use --include-major to include major version upgrades. Major versions are skipped by default to prevent breaking changes.

fern replay resolve

Use fern replay resolve to work through patch conflicts that Fern Replay couldn’t merge cleanly during fern generate. The command runs in two phases: the first run applies unresolved patches to your working tree with standard merge markers (<<<<<<< / ======= / >>>>>>>) for you to edit; the second run verifies no markers remain and commits the resolved patches.

terminal
$fern replay resolve [directory] [--no-check-markers]

directory

Path to the SDK directory containing .fern/replay.lock. Defaults to the current directory.

no-check-markers

Skip the conflict-marker check before committing. Use with caution — committing files that still contain merge markers will break the next regeneration.

fern replay forget

Use fern replay forget to remove tracked customization patches from .fern/replay.lock. Useful when the generator now supports a customization natively, or when you want to stop replaying a specific edit on future regenerations.

terminal
$fern replay forget <patch-id-or-pattern>... [--all] [--dry-run] [--yes]

The command accepts three modes:

  • By patch ID. Pass one or more patch IDs to remove specific patches.

    $fern replay forget patch-abc123 patch-def456
  • By search pattern. Pass a pattern to find matching patches. The command shows the matches with diff stats and prompts for confirmation before removing.

    $fern replay forget "src/utils"
  • All patches. Pass --all to remove every tracked patch.

    $fern replay forget --all

dry-run

Show what would be removed without actually removing.

$fern replay forget "src/utils" --dry-run

yes

Skip confirmation prompts. Required in non-interactive or CI environments.

$fern replay forget "src/utils" --yes
fern api update

Pulls the latest OpenAPI spec from the specified origin in generators.yml and updates the local spec. Alternatively, you can automate this process by setting up a GitHub Action.

terminal
$fern api update [--api <api>]

api

Use --api to specify the API to update if there are multiple specs with a defined origin in generators.yml. If you don’t specify an API, all OpenAPI specs with an origin will be updated.

terminal
$fern api update --api public-api
fern api enrich

Use fern api enrich to convert AI-generated examples or manually authored x-fern-examples into portable OpenAPI examples that any OpenAPI-compatible tool can consume.

terminal
$fern api enrich <openapi> -f <overrides-file> -o <output-file>

The command merges examples from an overrides file into native OpenAPI example fields and strips the x-fern-examples keys from the output. When an endpoint has multiple examples, each is stored as a named entry under the plural examples field.

The command requires two flags:

  • -f (or --file) — the overrides file containing x-fern-examples (e.g., ai_examples_override.yml).
  • -o (or --output) — the path for the enriched output file. Supports .yml and .json extensions.
$# Output as YAML
$fern api enrich openapi.yml -f overrides.yml -o enriched-openapi.yml
$
$# Output as JSON
$fern api enrich openapi.yml -f overrides.yml -o enriched-openapi.json

Each x-fern-examples field is mapped to its standard OpenAPI location:

  • path-parameters → parameters[].example (where in: path)
  • query-parameters → parameters[].example (where in: query)
  • headers → parameters[].example (where in: header)
  • request → requestBody.content.*.example
  • response.body → responses.<status>.content.*.example
fern docs theme export

Use fern docs theme export to extract the theme-eligible fields from your docs.yml into a standalone directory. The exported theme.yml and its assets can then be uploaded with fern docs theme upload.

terminal
$fern docs theme export [--output <directory>]

By default, files are written to ./fern/theme/.

output

Use --output to specify a custom directory for the exported theme.

$fern docs theme export --output ./my-theme
fern docs theme upload

Use fern docs theme upload to upload a theme to Fern’s registry. The command reads theme.yml from ./fern/theme/ and uploads it along with any referenced file assets.

terminal
$fern docs theme upload [--name <name>] [--org <org>]

name

Use --name to set the theme name. Defaults to default.

$fern docs theme upload --name my-theme

org

Use --org to override the organization ID from fern.config.json.

$fern docs theme upload --org my-org
fern docs theme list

Use fern docs theme list to list all themes uploaded for your organization.

terminal
$fern docs theme list [--json] [--org <org>]

By default, outputs one theme name per line.

json

Use --json to output the full list as a JSON array, including updatedAt timestamps.

$fern docs theme list --json

org

Use --org to override the organization ID from fern.config.json.

$fern docs theme list --org my-org