Customize Method Names

You can fine-tune your SDK method and group names to create intuitive, user-friendly code that matches your API’s purpose.

For example, instead of client.postUsers you can configure your SDK to read client.users.create().

How it works for SDK users

Here’s how developers using your generated SDK would call the customized method name client.users.create() in their applications:

1const response = await client.users.create();

Here’s how users would call nested groups:

1const response = await client.admin.users.create();
Casing is automatically configured

Fern automatically handles choosing the appropriate casing for each SDK language: snake_case in python, camelCase in TypeScript and PascalCase in Go, etc. Because of this, you define the endpoint structure once and get properly formatted methods across all generated SDKs.

Configure method names

For the Fern Definition, method names are directly mapped from your endpoint and service base-path.

For OpenAPI, use the x-fern-sdk-group-name and x-fern-sdk-method-name extensions to explicitly define your method name and grouping.

In the example below, Fern will generate a method called client.users.create():

users.yml
1services:
2 http:
3 UsersService:
4 base-path: /users # This defines the group/namespace for the methods
5 endpoints:
6 create: # This defines the specific method name within the group
7 method: POST
8 path: ""

In the example below, Fern will generate a method called client.users.create() for the POST /users endpoint.

openapi.yaml
1paths:
2 /users:
3 post:
4 x-fern-sdk-group-name: users
5 x-fern-sdk-method-name: create
Fern automatically parses `operationId`

By default, Fern uses your operation ID to generate method names. Format your operation IDs like {tag_name}_{operation_name} (e.g., users_get) and Fern will automatically generate users.get(). If your operation ID doesn’t start with a tag, Fern uses it directly as the method name.

Top level methods

If you omit the x-fern-sdk-group-name extension, then the generated SDK method will live at the root of the client rather than nested under a resource group. In the example below, Fern will generate a method called client.send():

openapi.yaml
1paths:
2 /send:
3 post:
4 x-fern-sdk-method-name: send

Multiple levels of nesting

See how merge.dev uses nested groups here.

If you add more than one x-fern-sdk-group-name extension, then the generated SDK will nest group names. The order of the group names is preserved in the generated SDK method.

In the example below, Fern will generate a method called client.users.notifications.send():

openapi.yaml
1paths:
2 /users/notifications:
3 post:
4 x-fern-sdk-group-name:
5 - users
6 - notifications
7 x-fern-sdk-method-name: send