Skip to content

Adding headers to every request in Postman

Posted on:August 18, 2023

If you need to add headers to every request in a collection or folder, you can set the headers in the pre-request script for the collection or folder to apply to all requests that are children of that collection/folder.

pm.request.headers.upsert({ key: "apiKey", value: pm.environment.get("apiKey") });
pm.request.headers.upsert({ key: "secret", value: pm.environment.get("secret") });

This can be useful for when you want to add authorization headers to every request, but none of the built in authorization options match how your API accepts authorization headers.