> This page is for API Definitions.

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For task-scoped instructions for coding agents working in a Fern project, see https://buildwithfern.com/learn/home/fern-instructions.md.

# Packages in Fern Definition

> Fern Definition enables the reuse of API type and error names across packages, and can configure the structure of your API documentation.

> **Warning**
>
> Fern Definition isn't recommended for new customers and Fern isn't accepting feature requests for this format. It remains supported for existing users.

## What is a package?

Every folder in your API definition is a package.

The generated SDK will match the hierarchy of your API definition.

#### Generated SDK

```ts
const client = new Client();

// calling endpoint defined in projects.yml
client.projects.get();

// calling endpoint defined in roles/admin.yml
client.roles.admin.get();
```

## Package configuration

Each package can have a special definition file called `__package__.yml`. Like any
other definition file, it can contain [imports](/learn/api-definitions/ferndef/imports),
[types](/learn/api-definitions/ferndef/types), [endpoints](/learn/api-definitions/ferndef/endpoints/overview),
and [errors](/learn/api-definitions/ferndef/errors).

Endpoints in `__package__.yml` will appear at the root of the package.
For example, the following generated SDK:

#### Generated SDK

```ts
const client = new Client();

client.getProjects();
```

would have a `fern/` folder:

that contains the following`__package__.yml`:

#### \_\_package\_\_.yml

```yaml
service:
  base-path: ""
  auth: false
  endpoints:
    getProjects:
      method: GET
      path: ""
      response: list<Project>
```

## Namespacing

Each package has its own namespace. This means you can reuse type names and
error names across packages.

This is useful when versioning your APIs. For example, when you want to
increment your API version, you can copy the existing API
to a new package and start making changes. If the new API version reuses
certain types or errors, that's okay because the two APIs live in different
packages.

## Navigation

`__package__.yml` also allows you to configure the navigation order
of your services. This is relevant when you want to control the display
of your documentation.

For example, let's say you have the following `fern/` folder:

Your API will be sorted alphabetically: projects, roles, then users. If you
want to control the navigation, you can add a `__package__.yml` file
and configure the order:

#### \_\_package\_\_.yml

```yaml
navigation: 
  - users.yml
  - roles.yml
  - projects.yml
```