{"id":26578763,"url":"https://github.com/luminati-io/postman-user-agent-header","last_synced_at":"2025-08-19T09:09:39.876Z","repository":{"id":283784014,"uuid":"949375595","full_name":"luminati-io/postman-user-agent-header","owner":"luminati-io","description":"Set, change, and rotate the User-Agent header in Postman to bypass anti-bot detection and improve HTTP request success.","archived":false,"fork":false,"pushed_at":"2025-03-16T11:58:33.000Z","size":823,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-22T07:02:02.733Z","etag":null,"topics":["postman","postman-proxy","proxy","user-agent"],"latest_commit_sha":null,"homepage":"https://brightdata.com/blog/web-data/postman-user-agent","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luminati-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-16T10:14:44.000Z","updated_at":"2025-03-16T12:09:22.000Z","dependencies_parsed_at":"2025-03-22T07:02:07.549Z","dependency_job_id":null,"html_url":"https://github.com/luminati-io/postman-user-agent-header","commit_stats":null,"previous_names":["luminati-io/postman-user-agent-header"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fpostman-user-agent-header","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fpostman-user-agent-header/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fpostman-user-agent-header/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fpostman-user-agent-header/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luminati-io","download_url":"https://codeload.github.com/luminati-io/postman-user-agent-header/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245056907,"owners_count":20553856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postman","postman-proxy","proxy","user-agent"],"created_at":"2025-03-23T05:16:29.036Z","updated_at":"2025-03-23T05:16:29.515Z","avatar_url":"https://github.com/luminati-io.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Setting and Changing the Postman User-Agent Header\n\n[![Promo](https://github.com/luminati-io/LinkedIn-Scraper/raw/main/Proxies%20and%20scrapers%20GitHub%20bonus%20banner.png)](https://brightdata.com/) \n\nThis guide explains how to set, change, and rotate the User-Agent header in Postman to avoid anti-bot detection and improve your HTTP requests:\n\n- [What Is the Postman Default User Agent?](#what-is-the-postman-default-user-agent)\n- [Change the Postman User Agent](#change-the-postman-user-agent)\n  - [Set the User Agent on a Single Request](#set-the-user-agent-on-a-single-request)\n  - [Set the User Agent on an Entire Collection](#set-the-user-agent-on-an-entire-collection)\n  - [Unset the User Agent](#unset-the-user-agent)\n- [Implement User Agent Rotation in Postman](#implement-user-agent-rotation-in-postman)\n  - [Retrieve a List of User Agents](#retrieve-a-list-of-user-agents)\n  - [Randomly Pick a User Agent](#randomly-pick-a-user-agent)\n  - [Define the User-Agent Header](#define-the-user-agent-header)\n  - [Put It All Together](#put-it-all-together)\n\n## Why You Need to Set a Custom User Agent\n\nThe [`User-Agent`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) header identifies the client making an HTTP request. It typically includes details about the client’s machine and the application used for the request. Web browsers, [HTTP clients](https://brightdata.com/blog/web-data/best-python-http-clients), and other software set this header automatically.\n\nHere’s an example of a `User-Agent` string used by Chrome when requesting a web page:\n\n```\nMozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\n```\n\nA browser's `User-Agent` header consists of several key components:\n\n- **`Mozilla/5.0`** – Originally signaled Mozilla compatibility; now included for broader support.  \n- **`Macintosh; Intel Mac OS X 10_15_7`** – Indicates the operating system (`Mac OS X 10.15.7`) and platform (Intel Mac).  \n- **`AppleWebKit/537.36`** – Specifies the rendering engine used by Chrome.  \n- **`(KHTML, like Gecko)`** – Ensures compatibility with KHTML and Gecko layout engines.  \n- **`Chrome/127.0.0.0`** – Represents the browser name and version.  \n- **`Safari/537.36`** – Suggests compatibility with Safari.  \n\nServers use the `User-Agent` header to identify whether a request comes from a browser or another source.  \n\nA common mistake among web scraping bots is using default or non-browser `User-Agent` strings, which anti-bot protections easily detect and block.\n\n## What Is the Postman Default User Agent?\n\n[Postman](https://www.postman.com/) is a widely used desktop HTTP client. Like most HTTP clients, it automatically sets a default `User-Agent` header in each request.\n\nYou can observe this behavior by inspecting the auto-generated headers in Postman.\n\n![observe this behavior by examining the auto-generated Postman headers](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/observe-this-behavior-by-examining-the-auto-generated-Postman-headers-1024x396.png)\n\nAs you can see, the Postman default user agent follows this format:\n\n```\nPostmanRuntime/x.y.z\n```\n\nThe `PostmanRuntime/x.y.z` string indicates a request made by Postman, where `x.y.z` represents the version number.\n\nTo confirm this, send a GET request to [`httpbin.io/user-agent`](https://httpbin.io/user-agent). This endpoint returns the `User-Agent` header of the incoming request, allowing you to verify the user agent used by any HTTP client.\n\n![identify the user agent used](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/identify-the-user-agent-used-1024x593.png)\n\nNotice how the user agent returned by the API matches the one set by Postman by default. In detail, the Postman user agent is:\n\n```\nPostmanRuntime/7.41.0\n```\n\nPostman’s `User-Agent` differs from browser headers, making requests more likely to be blocked by anti-bot systems. These systems detect bot-like patterns, including unusual user agents. Changing the default `User-Agent` helps avoid detection.\n\n## How to Change the Postman User Agent\n\n### Set the User Agent on a Single Request\n\nPostman allows you to change the user agent on a single HTTP request by manually specifying a `User-Agent` header.\n\n\u003e **Note**:\n\u003e \n\u003e The Postman auto-generated headers cannot be directly modified.\n\nGo to the “Headers” tab and add a new `User-Agent` header:\n\n![adding a new user-agent header](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/adding-a-new-user-agent-header-1024x333.gif)\n\nPostman replaces its default `User-Agent` with your custom header. Since [HTTP headers are case-insensitive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers), you can use `User-Agent`, `user-agent`, or any variation.\n\nVerify the change by sending a GET request to `httpbin.io/user-agent`.\n\n![executing a GET request](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/executing-a-GET-request-1024x578.png)\n\n### Set the User Agent on an Entire Collection\n\nA [Postman collection](https://www.postman.com/collection/) is a group of API requests with shared configurations. Postman allows defining [custom scripts](https://learning.postman.com/docs/tests-and-scripts/write-scripts/intro-to-scripts/) that run before or after each request in a collection.\n\nTo apply a custom `User-Agent` to all requests, log in to your Postman account or [create one](https://www.postman.com/postman-account/).  \n\nAssume you have an \"HTTPBin\" collection with organized HTTPBin endpoints:\n\n![HTTPBin endpoints organized in folders](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/HTTPBin-endpoints-organized-in-folders-1024x554.png)\n\nExecute the request for the `/user-agent` endpoint, and you will get the default Postman user agent:\n\n![the default Postman user agent](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/the-default-Postman-user-agent-1024x555.png)\n\nA [pre-request script](https://learning.postman.com/docs/tests-and-scripts/write-scripts/pre-request-scripts/) is a JavaScript function that runs before each request in a Postman collection. You can use it to set a custom `User-Agent` header.\n\nTo create a pre-request script:  \n1. Open your collection.  \n2. Navigate to the **Scripts** tab.  \n3. Select the **Pre-request** option.  \n\n![select the “Pre-request” option](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/select-the-Pre-request-option-1024x557.gif)\n\nIn the editor, paste the following code:\n\n```js\npm.request.headers.add({\n\nkey: \"User-Agent\",\n\nvalue: \"\u003cyour-user-agent\u003e\"\n\n});\n```\n\nReplace the `\u003cyour-user-agent\u003e` string with the value of the user agent you want to use, as below:\n\n```js\npm.request.headers.add({\n\nkey: \"User-Agent\",\n\nvalue: \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\"\n\n});\n```\n\n[`pm.request.headers.add()`](https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/) is a special function from the Postman API to add a specific header to the request.\n\nClick the “Save” button to apply the changes.\n\nExecute the request for the `/user-agent` endpoint again:\n\n![executing the request again ](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/executing-the-request-again-1024x559.png)\n\nThis time, the returned user agent will be the one set in the script and not the default Postman one.\n\n### Unset the User Agent\n\nThe `User-Agent` auto-generated header is optional, and you can actually uncheck it. When unchecked, Postman will no longer send a `User-Agent` header.\n\nVerify that by sending a request to the [`httpbin.io/headers`](https://httpbin.io/headers) endpoint, which returns all the headers of the incoming request:\n\n![return of all the headers of the incoming request](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/return-of-all-the-headers-of-the-incoming-request-1024x640.png)\n\nNote that the headers object returned by the endpoint does not include the `User-Agent` key.\n\n\u003e **Note**:\n\u003e\n\u003e Unsetting the `User-Agent` header is not recommended, as nearly web requests typically include that header.\n\n## Implement User Agent Rotation in Postman\n\nSimply replacing Postman’s `User-Agent` with a browser string may not bypass anti-bot systems, especially when making repeated requests from the same IP.\n\nTo avoid detection, use _user agent rotation_, assigning a different `User-Agent` to each request. This reduces the likelihood of being flagged as a bot.\n\nLet's learn how to implement user agent rotation in Postman.\n\n### Retrieve a List of User Agents\n\nVisit a site like [WhatIsMyBrowser.com](https://www.whatismybrowser.com/guides/the-latest-user-agent/) and populate a list of valid user agents:\n\n```js\nconst userAgents = [\n\n\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.2651.86\",\n\n\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.2651.86\",\n\n\"Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.103 Mobile Safari/537.36 EdgA/127.0.2651.82\",\n\n\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\",\n\n\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\",\n\n\"Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/127.0.6533.107 Mobile/15E148 Safari/604.1\",\n\n\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0\",\n\n\"Mozilla/5.0 (Macintosh; Intel Mac OS X 14.6; rv:129.0) Gecko/20100101 Firefox/129.0\",\n\n// other user agents...\n\n];\n```\n\n\u003e **Tip**:\n\u003e \n\u003e The more real-world user agents this array contains, the better to increase the rotation chances.\n\n### Randomly Pick a User Agent\n\nUse the JavaScript [`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) API to randomly select a user agent from the list:\n\n```js\nconst userAgent = serAgents[Math.floor(Math.random() * userAgents.length)];\n```\n\nThis is what happens in this line of code:\n\n1.  [`Math.random()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) generates a random number between 0 and 1.\n2.  The generated number is then multiplied by the length of the `userAgents` array.\n3.  [`Math.floor()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) rounds down the resulting number to the largest integer less than or equal to the source number. The resulting number corresponds to an index that goes from 0 to `userAgents.length - 1`.\n4.  The index is used to access a random item from the array of user agents.\n5.  The randomly selected user agent is assigned to a variable.\n\n### Define the User-Agent Header\n\nUse the `pm.request.headers.add()` to define a `User-Agent` header with the random `userAgent` value:\n\n```js\npm.request.headers.add({\n\nkey: \"User-Agent\",\n\nvalue: userAgent\n\n});\n```\n\nThe HTTP request of the collection will now have a rotating `User-Agent` header.\n\n### Put It All Together\n\nHere is the final Postman pre-request script for user agent rotation:\n\n```js\n// a list of valid user agents\n\nconst userAgents = [\n\n\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.2651.86\",\n\n\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.2651.86\",\n\n\"Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.103 Mobile Safari/537.36 EdgA/127.0.2651.82\",\n\n\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\",\n\n\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\",\n\n\"Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/127.0.6533.107 Mobile/15E148 Safari/604.1\",\n\n\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0\",\n\n\"Mozilla/5.0 (Macintosh; Intel Mac OS X 14.6; rv:129.0) Gecko/20100101 Firefox/129.0\",\n\n// other user agents...\n\n];\n\n// randomly extract a user agent from the list\n\nconst userAgent = userAgents[Math.floor(Math.random() * userAgents.length)];\n\n// set the random user agent header\n\npm.request.headers.add({\n\nkey: \"User-Agent\",\n\nvalue: userAgent\n\n});\n```\n\nAdd the script to your collection and test it by sending requests to `httpbin.io/user-agent`. Run multiple requests to observe the rotating user agents in action.\n\n![executing requests and seeing the rotation of user agents](https://github.com/luminati-io/postman-user-agent-header/blob/main/images/executing-requests-and-seeing-the-rotation-of-user-agents-1024x557.gif)\n\nThe returned user agent keeps changing.\n\n## Conclusion\n\nOverriding the `User-Agent` header and implementing user agent rotation helps elude basic anti-bot mechanisms. However, more advanced systems will still be able to block your requests. To prevent IP bans, you could [use a proxy in Postman](https://brightdata.com/integration/postman).\n\nSign up today to start your free trial.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminati-io%2Fpostman-user-agent-header","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluminati-io%2Fpostman-user-agent-header","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminati-io%2Fpostman-user-agent-header/lists"}