> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. # Global headers > Configure headers used across all endpoints using `x-fern-global-headers` extension At times, your API will leverage certain headers for every endpoint, or the majority of them, we call these "global headers". For convenience, generated Fern SDKs expose "global headers" to easily be updated on API calls. Take for example an API key, if we declare the API key as a global header, a user will be able to plug theirs in easily: ```python import os class Client: def __init__(self, *, apiKey: str): ``` Fern automatically pulls out headers that are used in every request, or the majority of requests, and marks them as global. ## In your OpenAPI spec To label additional headers as global, or to alias the names of global headers, use the `x-fern-global-headers` extension: **`openapi.yml`** ```yaml title="openapi.yml" x-fern-global-headers: - header: custom_api_key name: api_key - header: userpool_id optional: true ``` When you define global headers using `x-fern-global-headers`, you must [include them in your `x-fern-examples`](/learn/api-definitions/openapi/extensions/request-response-examples). ### Default values Set a client-side default value on a global header using [`x-fern-default`](/learn/api-definitions/openapi/extensions/default-values). The generated SDK makes the header optional and sends the default when the caller omits it: **`openapi.yml`** ```yaml {4} title="openapi.yml" x-fern-global-headers: - header: X-API-Version name: version x-fern-default: "2024-02-08" ``` ## In `generators.yml` Alternatively, you can add headers to the [`api` block in your `generators.yml` file](/learn/sdks/reference/generators-yml#headers): **`generators.yml`** ```yaml title="generators.yml" api: specs: - openapi: ./path/to/openapi headers: custom_api_key: name: api_key type: string userpool_id: name: userpool_id type: optional ``` ## Generated SDK behavior Both configurations yield the following client code: ```python import os class Client: def __init__(self, *, apiKey: str, userpoolId: typing.Optional[str]) ``` > Configure headers used across all endpoints using `x-fern-global-headers` extension