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
  • Overview
    • Introduction
    • How it works
    • Quickstart
    • Customer showcase
  • Working with SDKs
    • Project structure
    • Adding custom code
    • Migrating to Replay
    • Capabilities
  • Generators
      • SDK user features
      • Customize your README
      • Customize method names
      • Filter endpoints by audience
      • Server URL templating
      • Webhook signature verification
  • Reference
    • generators.yml
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
  • Generated SDK behavior
  • Setting up server URL templating
SDK design

Server URL templating

||View as Markdown|
Was this page helpful?
Edit this page
Previous

Filter your endpoints (audiences)

Next

Webhook signature verification

Server URL templating lets you define base URLs with variable placeholders (e.g., {region}, {environment}) that SDK users can customize at runtime. This is useful for APIs deployed across multiple regions, environments, or custom domains.

URL templating is currently supported for Python and Java SDK generation only.

Generated SDK behavior

Fern generates an environments module that exposes the default URLs for each named server. SDK users can select a pre-defined environment or pass custom URL strings.

Python
Java

The generated SDK exposes an Environment class:

environment.py
1class MyApiEnvironment:
2 REGIONAL_API_SERVER = {
3 "base": "https://api.example.com/v1",
4 "auth": "https://auth.example.com",
5 }

SDK users can override the base URL when constructing the client:

1from my_api import MyApiClient
2
3# Use the default environment
4# → https://api.example.com/v1
5client = MyApiClient()
6
7# Target a specific region and environment via URL variables
8# → https://api.eu-west-1.staging.example.com/v1
9client = MyApiClient(
10 region="eu-west-1",
11 environment="staging",
12)
13
14# Or provide a custom base URL
15# → https://api.us-west-2.staging.example.com/v1
16client = MyApiClient(
17 base_url="https://api.us-west-2.staging.example.com/v1",
18)

Setting up server URL templating

Define URL template variables in your API definition and provide a static fallback URL for SDK users who don’t customize variables:

openapi.yml
1servers:
2 - url: https://api.{region}.{environment}.example.com/v1
3 x-fern-server-name: Default
4 x-fern-default-url: https://api.example.com/v1
5 variables:
6 region:
7 default: us-east-1
8 enum: [us-east-1, us-west-2, eu-west-1]
9 environment:
10 default: prod
11 enum: [prod, staging, dev]

For full configuration details, see Server names and URL templating in OpenAPI.