Use audiences to filter your API
Learn how to use x-fern-audiences to filter OpenAPI endpoints, schemas, and properties for different API consumers like public and beta users.
Pro and Enterprise feature
This feature is available only for the Pro and Enterprise plans. To get started, reach out to support@buildwithfern.com.
Fern provides two ways to filter which API elements appear in your SDKs and API Reference docs:
-
audiences(tag-based filtering): Tag specific endpoints, schemas, or properties with audience labels, then filter SDKs and Docs to those tags. Best for creating variants based on user types (public vs. beta, free vs. enterprise) or feature maturity, regardless of URL structure. -
settings.filter(path-based filtering): Filter entire URL paths or patterns. Best when your API organization naturally divides by URL (like/v1/*vs./v2/*, or/admin/*vs./user/*). See thesettings.filterreference for configuration details.
Many teams use both approaches: path-based filtering for major divisions, audience tags for fine-grained control within those divisions.
Path based filtering
Use settings.filter in your generators.yml to limit which endpoints are included in the generated SDK or API Reference based on their paths:
Tag based filtering (audiences)
Apply audience tags in your OpenAPI spec, then configure your SDKs or API Reference to filter to those audiences.
Tag elements in your spec
Tag servers
Add the x-fern-server-name and x-fern-audiences extension to the relevant server.
In the example below, the Production server is only available to public consumers:
Tag endpoints
Add the x-fern-audiences extension to the relevant endpoint.
In the example below, the POST /users/sendEmail endpoint is only available to public consumers:
Tag schemas
Add the x-fern-audiences extension to the relevant schema.
In this example, the Email type is available to both public and beta customers.
Tag properties
Add the x-fern-audiences extension to the relevant property.
In this example, the to property is available to beta customers only.
Filter SDKs or Docs
Specify which audiences to include in your SDKs or API Reference docs. If no audiences are specified, all tagged elements will be included in your SDK regardless of their audience tags.
SDKs
Docs
The following example configures the SDK to filter to the public audience: