Configure global headers

View as Markdown

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:

1import os
2
3class Client:
4
5 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
1x-fern-global-headers:
2 - header: custom_api_key
3 name: api_key
4 - header: userpool_id
5 optional: true

For full configuration details, see the docs for your API definition format: