> This page is for SDK, version Legacy.
> For other versions, use one of these documentation indexes:
> - Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
> - Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

# Configure global headers

> Learn how to configure global headers in Fern SDKs. Set up API headers once as constructor parameters for automatic inclusion in all requests.

> **You're viewing the legacy SDK docs**
>
> These pages cover SDK generation configured with `generators.yml`. New projects use `sdk-config.yml`, so see [the Current version of this page](/learn/sdks/deep-dives/global-headers) for up-to-date guidance. To move an existing project, follow the [SDK Config migration guide](/learn/sdks/legacy/generators/migration-guides/sdk-config), which walks through `fern sdk migrate`, and review the [`sdk-config.yml` reference](/learn/sdks/reference/sdk-config).

If your API requires certain headers on every request (or most requests), you can configure them as **global headers**. Fern will generate an SDK that accepts these headers once in the client constructor and automatically includes them in all API calls.

## Generated SDK behavior

Once you configure a global header, Fern generates an SDK that accepts the header value as a constructor parameter:

```python
import os

class Client:

  def __init__(self, *, apiKey: str):
```

SDK users provide the value once, and the generated SDK automatically includes the header in all requests.

## Setting up global headers

Fern automatically identifies headers used in every request, or the majority of requests, and marks them as global. You can manually configure additional global headers in your API definition:

**`openapi.yml`**

```yaml title="openapi.yml"
x-fern-global-headers:
  - header: custom_api_key
    name: api_key
  - header: userpool_id
    optional: true
```

You can also pin a [default value](/learn/api-definitions/openapi/extensions/default-values) on a global header so the SDK sends it automatically when the caller doesn't provide one.

For full configuration details, see [Global headers in OpenAPI](/learn/api-definitions/openapi/extensions/global-headers).