You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/sdks/guides/configure-global-headers.mdx
+95-2Lines changed: 95 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,99 @@ title: Configure Global Headers
3
3
description: Guide to configuring global headers in your SDKs.
4
4
---
5
5
6
-
Learn how to configure global headers for all requests made by your SDKs.
6
+
Your API may leverage certain headers for every endpoint or most endpoints.
7
+
These are called **global headers**.
7
8
8
-
<Warning>Docs are coming soon for this page.<br/><br/>Please [book a demo](https://buildwithfern.com/book-demo) or [reach out to us](https://buildwithfern.com/book-demo) to get set up with this feature. </Warning>
9
+
## How it works for SDK users
10
+
11
+
Once you configure a global header (either automatically detected or manually
12
+
specified), Fern generates an SDK that accepts this as a constructor parameter.
13
+
Users can then provide the value once, and the generated SDK automatically
14
+
includes the header in all their API calls:
15
+
16
+
```python
17
+
import os
18
+
19
+
classClient:
20
+
21
+
def__init__(self, *, apiKey: str):
22
+
```
23
+
24
+
## Specifying global headers
25
+
26
+
Fern automatically identifies headers that are used in every request, or the
27
+
majority of requests, and marks them as global. You can manually configure additional
28
+
global headers in either `api.yml` (Fern Definition) or `openapi.yml`.
29
+
30
+
<AccordionGroup>
31
+
<Accordiontitle="Fern Definition">
32
+
33
+
To specify headers that are meant to be included on every request:
34
+
35
+
<CodeBlocktitle="api.yml">
36
+
```yaml {3}
37
+
name: api
38
+
headers:
39
+
X-App-Id: string
40
+
```
41
+
</CodeBlock>
42
+
43
+
### Global path parameters
44
+
You can also specify path parameters that are meant to be included on every request:
45
+
46
+
<CodeBlock title="api.yml">
47
+
```yaml
48
+
name: api
49
+
base-path: /{userId}/{orgId}
50
+
path-parameters:
51
+
userId: string
52
+
orgId: string
53
+
```
54
+
</CodeBlock>
55
+
56
+
#### Overriding the base path
57
+
58
+
If you have certain endpoints that do not live at the configured `base-path`, you can
59
+
override the `base-path` at the endpoint level.
60
+
61
+
```yml imdb.yml {5}
62
+
service:
63
+
endpoints:
64
+
getMovie:
65
+
method: POST
66
+
base-path: "override/{arg}"
67
+
path: "movies/{movieId}"
68
+
path-parameters:
69
+
arg: string
70
+
```
71
+
72
+
<Note>
73
+
You cannot yet specify query parameters that are meant to be included on every request.
74
+
If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930).
75
+
</Note>
76
+
77
+
</Accordion>
78
+
<Accordion title="OpenAPI">
79
+
80
+
Use the `x-fern-global-headers` extension to label additional headers as global
0 commit comments