Environments
Fern Definition isn’t recommended for new customers and Fern isn’t accepting feature requests for this format. It remains supported for existing users.
You can specify the environments where your server is deployed.
Single URL environments
Multiple URLs per environment
You can specify multiple URLs per environment. This is helpful if you have a microservice architecture, and you want a single SDK to interact with multiple servers.
If you choose to use this feature, you must specify a url for each service you define:
Default environment
You can also provide a default environment:
Base URL from an environment variable
Set base-url-env to the name of an environment variable that the generated SDK reads for its base URL, the same way auth credentials can default from environment variables. This lets each deployment (staging, production, self-hosted) point the SDK at a different host without passing a base URL in code.
The generated client resolves the base URL in this order: an explicit base URL passed to the client, an explicit environment passed to the client, the value of the environment variable, then the default environment. base-url-env requires at least one entry under environments; fern check warns (valid-base-url-env) otherwise.
Only the TypeScript SDK generator supports this setting.
URL templating
For APIs deployed across multiple regions or environments, you can define URL templates with variable placeholders that SDK users customize at runtime. To set this up:
- Define your static base URLs under
urls— these appear in the generated environments enum. - Add
url-templateswith{variable}placeholders (e.g.,https://api.{region}.example.com/v1) for each service. Fern exposes these as configurable parameters in the SDK. - Provide
default-urlsas concrete fallbacks so SDK users get a working client out of the box without supplying variables. - List the available
variablesfor each service, each with anid, adefaultvalue, and an optionalvalueslist to constrain allowed options.
Base path
If you would like all of your endpoints to be prefixed with a path, use base-path.
In the example below, every endpoint is prefixed with a /v1:
Audiences
If you have listed environments that you want to filter, you can leverage audiences.