Skip to content

Postman Collections — Complete Guide

DodaTech Updated 2026-06-28 3 min read

In this tutorial, you will learn about Postman Collections. We cover key concepts, practical examples, and best practices to help you master this topic.

Postman collections group related API requests for organized testing. Collections support nested folders, collection-level variables, shared authorization, and inherited scripts. They form the foundation for automated API testing.

What You'll Learn

  • Creating and structuring collections
  • Adding folders for logical grouping
  • Collection-level variables and authorization
  • Inherited pre-request and test scripts
  • Exporting and sharing collections

Why It Matters

Well-organized collections are reusable test suites. Teams share collections for consistent API testing. Collections can be run in CI/CD with Newman for automated Regression Testing.

Real-World Use

Twilio provides a comprehensive Postman collection with folders for each API resource. Salesforce organizes their API by object types in folders. GitHub's collection has folders for repos, issues, and users.

flowchart TD
    Collection[API Collection] --> Auth[Collection Auth]
    Collection --> Variables[Collection Variables]
    Collection --> Scripts[Collection Scripts]
    Collection --> Folder1[Folder: Users]
    Collection --> Folder2[Folder: Products]
    Collection --> Folder3[Folder: Orders]
    Folder1 --> Req1[GET Users]
    Folder1 --> Req2[POST User]
    Folder1 --> Req3[DELETE User]

Teacher Mindset

Structure collections like a filesystem. Use folders for resources (Users, Products, Orders). Set authorization at the collection level so all requests inherit it. Use collection variables for shared base URL and API key.

Code Examples

// Example 1: Collection-level pre-request script
// Set timestamp for all requests
const timestamp = new Date().toISOString();
pm.variables.set('timestamp', timestamp);

// Generate unique IDs
pm.variables.set('request_id', require('uuid').v4());
// Example 2: Collection-level test script
// Log response time for all requests
pm.test('Response time is acceptable', () => {
    pm.expect(pm.response.responseTime).to.be.below(2000);
});

// Check for error structure
const body = pm.response.json();
if (body.errors) {
    console.warn('Response contains errors:', body.errors);
}
// Example 3: Folder-level tests
// In the "Users" folder test script
pm.test('User response has required fields', () => {
    const user = pm.response.json();
    pm.expect(user).to.have.all.keys('id', 'name', 'email', 'createdAt');
});

Common Mistakes

  • Storing sensitive data (API keys) directly in collections instead of using environments
  • Not using folders for resource organization
  • Duplicating authorization setup across requests instead of using collection-level auth
  • Forgetting to inherit collection scripts at the request level
  • Exporting collections without removing sensitive variables

Practice

  1. Create a collection with three folders: Users, Products, Orders.
  2. Add collection-level variables for base URL and API key.
  3. Set collection-level authorization to Bearer Token.
  4. Add a pre-request script that sets a timestamp variable.
  5. Challenge: Create a folder-level test that runs for all requests in the Users folder.

FAQ

How do I share a collection?

Export as JSON and share the file, or use Postman's built-in sharing for team workspaces.

Can I nest folders in a collection?

Postman supports one level of nesting. Use sub-folders within folders for deeper organization.

What is the difference between collection and environment variables?

Collection variables belong to the collection. Environment variables are context-specific (dev, staging, prod).

Can I override collection variables in individual requests?

Yes. Individual request settings override collection-level settings.

How do I add descriptions to requests?

Use the Description tab in the request builder. Write Markdown documentation for each endpoint.

Mini Project

Create a Postman collection for an e-commerce API. Structure it with folders for Auth, Products, Cart, and Orders. Set collection-level auth and base URL. Add pre-request scripts for timestamps and folder-level tests for response validation.

What's Next

Next, you will learn about Postman scripts for pre-request and test automation.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro