04 Folder Structuring
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
- Create folders for Users, Products, and Orders.
- Add CRUD requests to each folder.
- Set folder-level authorization for the Users folder.
- Add a folder-level test script that logs response time.
- Challenge: Create a nested folder structure (Products > Categories, Products > Reviews) with inherited scripts.
FAQ
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