# Add headers params to environment

**URL:** <https://community.postman.com/t/add-headers-params-to-environment/6796>\
**Category:** Help Hub\
**Tags:** environments, suggestions, setenvironmentvariab\
**Created:** [July 26, 2019, 2:21pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796 "2019-07-26T14:21:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![caudurieau](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/caudurieau/32/2418_2.png) [@caudurieau](https://community.postman.com/u/caudurieau)\
**Post date:** [July 26, 2019, 2:21pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/1 "2019-07-26T14:21:45Z")

</div>

Is that possible to add headers parameters for every calls make from an environment?

I explain.

If I select my custom environment, which has some custom parameters setted in header part. Then, when I make a call in cUrl, PHP, Shell…, Postman add automatically environment headers in calls.

---

<div class="post-metadata">

**Author:** ![postman-kyle](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@postman-kyle](https://community.postman.com/u/postman-kyle)\
**Post date:** [July 26, 2019, 4:37pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/2 "2019-07-26T16:37:30Z")

</div>

You can add headers like params and put in your variable values.

 ![35%20AM](https://us1.discourse-cdn.com/getpostman/original/3X/c/c/ccf0fd9adebe021b70367640f6b3906c79a56434.png)

---

<div class="post-metadata">

**Author:** ![caudurieau](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/caudurieau/32/2418_2.png) [@caudurieau](https://community.postman.com/u/caudurieau)\
**Post date:** [July 26, 2019, 4:40pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/3 "2019-07-26T16:40:10Z")

</div>

Yep, but I mean add it automatically instead of setting from us for each our API calls.  
This could be great, especially if you have a lot of API for one environment 🙂 .

---

<div class="post-metadata">

**Author:** ![aamir.ahmed](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@aamir.ahmed](https://community.postman.com/u/aamir.ahmed)\
**Post date:** [July 26, 2019, 4:47pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/4 "2019-07-26T16:47:58Z")

</div>

Hi @caudurieau,

You can save commonly used headers together in a header preset. Under the **Headers** tab, you can add a header preset to your request when you select “Manage Presets” from the **Presets** dropdown on the right. You can go ahead and apply those directly instead of manually adding it for each request. please view the following documentation for your reference:  
[https://learning.getpostman.com/docs/postman/sending\_api\_requests/requests/#header-presets](https://learning.getpostman.com/docs/postman/sending_api_requests/requests/#header-presets)

---

<div class="post-metadata">

**Author:** ![caudurieau](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/caudurieau/32/2418_2.png) [@caudurieau](https://community.postman.com/u/caudurieau)\
**Post date:** [July 26, 2019, 4:54pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/5 "2019-07-26T16:54:08Z")

</div>

That’s not exactly what I suggest but I didn’t know this functionality. Thanks 😉

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 26, 2019, 7:00pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/6 "2019-07-26T19:00:06Z")

</div>

Hey @caudurieau

Is this what you’re trying to do?

> [@Setting headers for entire collection/folder](https://community.postman.com/t/setting-headers-for-entire-collection-folder/708/14):
>
> As of 7.0.9 - You should be able to now do this in your Pre-request Scripts. You can use the following syntax: pm.request.headers.add({key: 'header\_name', value: 'header\_value' }) pm.request.headers.upsert({key: 'header\_name', value: 'header\_value' }) pm.request.headers.remove('header\_name') EDIT: Fork this collection to see how it works directly in Postman: [https://www.postman.com/postman/workspace/postman-answers/collection/9215231-ef055751-7385-45b4-a6f9-91bbd1c47fa5?ctx=documentation](https://www.postman.com/postman/workspace/postman-answers/collection/9215231-ef055751-7385-45b4-a6f9-91bbd1c47fa5?ctx=documentation)

Using the `pm.request.headers.add({key: 'header_name', value: 'header_value' })` function in the `Pre-Request Script` at the Collection or Folder level, you would be able to programmatically set a header in one place that would be applied to multiple requests.

---

<div class="post-metadata">

**Author:** ![kalitas](https://avatars.discourse-cdn.com/v4/letter/k/dfb087/32.png) [@kalitas](https://community.postman.com/u/kalitas)\
**Post date:** [April 1, 2020, 1:54pm UTC](https://community.postman.com/t/add-headers-params-to-environment/6796/7 "2020-04-01T13:54:18Z")

</div>

Hi @caudurieau audurieau I just encounter the same problem you had and write this solution (on pre request script):

```
var env = pm.environment.get("path");
if (env === "local" || "dev") {
    pm.request.headers.remove('Authorization')
    pm.request.headers.add({key: 'Authorization', value: pm.globals.get("devJWT") })
}
else {
    pm.request.headers.remove('Authorization')
    pm.request.headers.add({key: 'Authorization', value: pm.globals.get("prodJWT") })
}
```
