#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Postman

Postman Collections & Environment File

Collections

A Collection is a folder-like grouping of related requests, letting testers organize an entire API's endpoints (or a full test suite) in one place, complete with sub-folders and shared settings.

Environment Files

An Environment is a named set of variables (like base URL, API key, or auth token) that can be swapped in and out — allowing the same collection of requests to run against Dev, QA, or Production without editing each request individually.

Why This Combination Matters

Together, Collections and Environments let a tester maintain one reusable, organized suite of requests that can target any environment simply by switching the active Environment.

Variable Scopes and Which One Wins

Postman resolves a variable such as {{baseUrl}} by looking through several scopes. When the same name exists in more than one, the narrowest scope wins:

ScopeLives inGood for
LocalA single request run, set by a scriptTemporary values during one execution
DataA CSV or JSON file used by the runnerData-driven iterations
EnvironmentThe active environmentBase URLs, credentials and tokens per server
CollectionThe collection itselfValues shared by every request, whatever the server
GlobalThe whole workspaceRarely needed; easy to misuse

Environment variables also have an initial value, which is shared when the environment is exported or synced, and a current value, which stays on your machine. Put secrets only in the current value or use the secret variable type.

Worked Example: Dev and QA From One Collection

Create two environments, Dev and QA, each with baseUrl, username and password. Requests in the collection never contain a hardcoded server:

POST {{baseUrl}}/auth/login
Body: { "username": "{{username}}", "password": "{{password}}" }

GET  {{baseUrl}}/orders
Header: Authorization: Bearer {{token}}

The login request saves the token in its Tests (post-response) script so every later request can use it:

pm.test("Login succeeds", () => {
    pm.response.to.have.status(200);
});

const body = pm.response.json();
pm.environment.set("token", body.token);

The orders request then checks its own response:

pm.test("Orders list is an array", () => {
    pm.expect(pm.response.json().orders).to.be.an("array");
});
pm.test("Responds within two seconds", () => {
    pm.expect(pm.response.responseTime).to.be.below(2000);
});

Switching the environment dropdown from Dev to QA reruns the whole flow against the other server with no edits.

Running the Collection Outside the App

Export the collection and environment as JSON files, then run them from the command line with Newman, which is also how CI pipelines execute them:

npm install -g newman
newman run orders.postman_collection.json -e qa.postman_environment.json
newman run orders.postman_collection.json -e qa.postman_environment.json -d users.csv -r cli,junit

The -d option feeds a data file for multiple iterations, and the junit reporter produces XML that build servers can display.

Organising Collections Well

  • Use folders per feature or resource, such as Auth, Orders and Payments, and run folders in a logical order.
  • Keep shared scripts at collection or folder level instead of copying them into every request.
  • Give requests readable names like "Create order - missing address" so runner results make sense.
  • Store exported files in version control, but never with real passwords or tokens in initial values.
  • Avoid global variables for anything environment-specific; they leak between unrelated collections.
  • Clear or reset tokens at the start of a run so stale values do not hide login failures.

A small sanity check before sharing a collection: select a fresh environment, run it from top to bottom, and confirm nothing depends on a value only your machine holds.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course