Skip to content

04 Folder Structuring

DodaTech 3 min read

title: "Folder Structuring in Collections" description: "Organize Postman collections with effective folder structures for logical grouping. Learn nesting, folder-level scripts, authorization inheritance, and naming conventions for maintainable collections." weight: 4 date: 2026-06-28 lastmod: 2026-06-28 tags: [api-development, postman] }

Folder structuring turns flat request lists into organized API documentation. Folders group related endpoints, inherit collection settings, and support folder-level scripts. Good structure makes collections navigable and maintainable.

What You'll Learn

  • Logical folder hierarchy design
  • Folder-level authorization and scripts
  • CRUD folder patterns
  • Naming conventions for folders
  • Sharing and reusing folder patterns

Why It Matters

A well-structured collection with 50 requests is easier to navigate than a flat list of 20. Folders communicate the API's resource structure. Folder-level scripts reduce duplication.

Real-World Use

Stripe's Postman collection organizes requests by API resource (Charges, Customers, Refunds). GitHub's collection mirrors the API structure (Repos, Issues, Users). Both use folder-level auth and scripts.

flowchart TD
    Collection[E-Commerce API] --> Auth[Auth]
    Collection --> Users[Users]
    Collection --> Products[Products]
    Collection --> Orders[Orders]
    Users --> List[GET /users]
    Users --> Create[POST /users]
    Users --> GetById[GET /users/:id]
    Users --> Update[PATCH /users/:id]
    Users --> Delete[DELETE /users/:id]
    Products --> List[GET /products]
    Products --> Create[POST /products]

Teacher Mindset

Structure folders like your API's URL hierarchy. Each resource gets a folder. Each HTTP method on that resource gets a request. Use folders for different API versions or domains.

Code Examples

// Example 1: Folder-level pre-request script
// Sets auth header for all requests in the folder
const token = pm.environment.get('auth_token');
if (token) {
    pm.request.headers.add({
        key: 'Authorization',
        value: `Bearer ${token}`
    });
}
// Example 2: Folder-level test script
// Validates common response patterns
pm.test('Status code is valid', () => {
    pm.expect(pm.response.code).to.be.oneOf([200, 201, 204, 400, 401, 403, 404, 500]);
});

pm.test('Response has valid JSON body', () => {
    if (pm.response.code !== 204) {
        pm.response.to.have.jsonBody();
    }
});

// Log response for debugging
console.log(`${pm.request.method} ${pm.request.url} -> ${pm.response.code} (${pm.response.responseTime}ms)`);
// Example 3: Collection with nested folders
// Structure:
// Products/
//   Categories/
//     GET categories
//     POST category
//   Reviews/
//     GET reviews
//     POST review
//   Inventory/
//     GET stock
//     PATCH stock

// Folder-level variables
pm.variables.set('product_id', '');
pm.variables.set('category_id', '');

Common Mistakes

  • Creating folders that do not match the API resource structure
  • Duplicating auth setup in every request instead of using folder-level auth
  • Using too many nesting levels (max 2-3 levels deep)
  • Not using folder-level scripts for shared validation logic
  • Mixing different API versions in the same folder structure

Practice

  1. Create folders for Users, Products, and Orders.
  2. Add CRUD requests to each folder.
  3. Set folder-level authorization for the Users folder.
  4. Add a folder-level test script that logs response time.
  5. Challenge: Create a nested folder structure (Products > Categories, Products > Reviews) with inherited scripts.

FAQ

How many levels deep should I nest folders?

2-3 levels maximum. Deep nesting makes collections hard to navigate.

Can I set different authorization per folder?

Yes. Each folder can have its own authorization settings that override the collection defaults.

Do folder scripts run before collection scripts?

Collection scripts run first, then folder scripts, then request scripts.

How do I move requests between folders?

Drag and drop in the Postman sidebar. Or edit the exported JSON directly.

Can I reuse a folder structure across collections?

Yes. Export the folder and import it into another collection. Or use collection templates.

Mini Project

Create a collection with folders for Auth, Users, Products, and Orders. Each folder should have CRUD requests. Set folder-level auth for all folders except Auth. Add folder-level test scripts that validate JSON responses and log timing.

What's Next

Next, you will learn about configuring requests with params, headers, and body.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro