# How do I remove a header via a script in headers tab?

**URL:** <https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326>\
**Category:** Help Hub\
**Tags:** variables, header, pre-request-script\
**Created:** [February 5, 2024, 5:52pm UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326 "2024-02-05T17:52:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunar-module-archit1](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lunar-module-archit1](https://community.postman.com/u/lunar-module-archit1)\
**Post date:** [February 5, 2024, 5:52pm UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/1 "2024-02-05T17:52:37Z")

</div>

Hey everyone, I have a header in every request in the headers tab, and now its useless, I cannot remove it manually because there are too many requests to count, how do I remove it via a pre-request script?

example header I wanna remove (not mine):

 ![332846c6acd0d8d11dc3aa8ec8d8220558afaa41](https://us1.discourse-cdn.com/getpostman/original/3X/4/d/4d42eee5337f91f8b47e2a5a390b45df79d38db3.png)

---

<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:** [February 5, 2024, 7:44pm UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/2 "2024-02-05T19:44:33Z")

</div>

Hey @lunar-module-archit1 👋

Welcome to the Postman community :postman:

Is this something you could use in a pre-request script:

```auto
pm.request.headers.remove(headerName:String):function

```

> **[Manage API data and workflows using Postman JavaScript objects | Postman...](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-with-request-data)**
>
> Manage API data and workflows using Postman JavaScript objects: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![lunar-module-archit1](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lunar-module-archit1](https://community.postman.com/u/lunar-module-archit1)\
**Post date:** [February 5, 2024, 8:38pm UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/3 "2024-02-05T20:38:07Z")

</div>

Well this removes the param from the request being sent, not the Headers tab, I wanna remove the param once and for all. Any additional guidance would be greatly appreciated.

---

<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:** [February 6, 2024, 9:39am UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/4 "2024-02-06T09:39:21Z")

</div>

These are automatically generated request headers and cannot be deleted completely. The can be disabled or overridden with a new value.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/7/874d08998372893832bbdac8066c0cabe5a44b3f.png)

> **[Create and send API requests in Postman | Postman Learning Center](https://learning.postman.com/docs/sending-requests/requests/#autogenerated-headers)**
>
> Create and send API requests in Postman: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![lunar-module-archit1](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lunar-module-archit1](https://community.postman.com/u/lunar-module-archit1)\
**Post date:** [February 6, 2024, 10:36am UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/5 "2024-02-06T10:36:47Z")

</div>

I’m sorry I used a bad example, I my self added a new key and a new value, that are not generated automatically to every route during development, and now after an update I don’t want it anymore…

sorry again, I should’ve been more clear

---

<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:** [February 6, 2024, 11:25am UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/6 "2024-02-06T11:25:03Z")

</div>

> [@danny-dainton](#):
>
> `pm.request.headers.remove(headerName:String)`

You should be able to use this at the Collection level to prevent your manually added header from being sent in the requests.

Apart from manually deleting them in either the UI or exporting the file out to a text editor and doing it that way - There’s not a lot of options.

Using the [Postman API](https://www.postman.com/postman/workspace/postman-public-workspace/collection/12959542-c8142d51-e97c-46b6-bd77-52bb66712c9a?action=share&source=copy-link&creator=1794236) might work but I don’t have a working solution to give you for this right now.

---

<div class="post-metadata">

**Author:** ![lunar-module-archit1](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lunar-module-archit1](https://community.postman.com/u/lunar-module-archit1)\
**Post date:** [February 7, 2024, 7:46am UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/7 "2024-02-07T07:46:20Z")

</div>

Thanks for the tip, I exported it and used replace all. and it works, I really think they should implement a function for this use case… just a suggestion you know

---

<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:** [February 7, 2024, 9:11am UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/8 "2024-02-07T09:11:40Z")

</div>

For feature requests, you can use the `💡icon` link in the site header, to submit those directly to the team. ❤

It leads to this form where you can input the details:

> **[Build software better, together](https://github.com/postmanlabs/postman-app-support/issues/new?assignees=&labels=feature&projects=&template=feature_request.yml&title=%3Ctitle%3E)**
>
> GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.

Given the nature of the forum and the topics that we receive here, it’s difficult to pick up and track all bugs/feature requests so your best option is to raise those directly on our issue tracker.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [March 8, 2024, 9:12am UTC](https://community.postman.com/t/how-do-i-remove-a-header-via-a-script-in-headers-tab/57326/9 "2024-03-08T09:12:30Z")

</div>

Closed on March 8, 2024, 9:12am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
