Postman is much more than just a tool for sending single API requests; it’s a powerful environment for testing, documenting, and executing complex API workflows. When you need to perform the same operation hundreds of times—like creating a batch of users, testing various data inputs, or migrating configuration—you need bulk actions.
The secret to bulk operations in Postman lies in combining Collections, the Collection Runner, Variables, and external Data Files.
1. The Core Tool: The Collection Runner
The Collection Runner is Postman's built-in feature for executing an entire Collection (or a specific Folder within a Collection) multiple times in a predefined sequence. It's the central hub for all bulk operations.
Key Features for Bulk Actions:
- Iteration Count: Tells the Runner how many times to execute the entire collection/folder.
- Data Files: Allows you to upload external CSV or JSON files to feed different data into each iteration.
- Environment Selection: Ensures consistent bulk operations across development, staging, or production environments.
- Test Logging: Logs the results (pass/fail) for every request across every iteration.
2. Technique 1: Data-Driven Testing (Bulk Input)
This is the most common form of bulk action, used to test an API endpoint against a large set of varied inputs (e.g., testing valid/invalid usernames, bulk user creation, or mass data updates).
Step-by-Step Implementation:
A. Prepare the Data File 📊
Create a CSV or JSON file containing all your input data. The column headers in your file will become the variable names Postman uses.
Example CSV (user_data.csv
):
id,username,email,expected_status
1,alice_dev,alice@test.com,201
2,bob_tester,bob@test.com,201
3,,invalid_user.com,400
B. Parameterize the Request 🔗
In your Postman request (e.g., a POST /users
request), replace the static values in the URL, headers, or body with dynamic variables using the {{variable_name}}
syntax.
Part of Request | Before | After (Parameterized) |
---|---|---|
Request Body | "username": "static_user" |
"username": "{{username}}" |
Tests/Assertions | pm.expect(pm.response.code).to.eql(201); |
pm.expect(pm.response.code).to.eql(pm.iterationData.get("expected_status")); |
Postman will automatically map the column headers from your CSV/JSON file to these variables during the run.
C. Run the Collection
- Click the "Run" button next to your Collection.
- In the Collection Runner window, click "Select File" under the Data section and upload your
user_data.csv
(or JSON). - Postman will automatically update the Iterations count to match the number of rows (data sets) in your file (3 in the example above).
- Click "Run [Collection Name]" to start the bulk operation.
The Runner will execute the request three separate times, substituting the variables with the data from each row.
3. Technique 2: Chained Workflows (Sequential Bulk Operations)
Sometimes you need a series of requests to run in bulk (e.g., Login $\rightarrow$ Create Order $\rightarrow$ Get Order Details). The Collection Runner automatically runs requests sequentially, and you can pass data between them using variables.
How it Works:
-
Request 1 (e.g., Login): Use a Post-response Script to capture a value (like an authentication token) from the response and save it as an Environment Variable.
// Post-response Script for Login request const responseJson = pm.response.json(); pm.environment.set("auth_token", responseJson.token);
-
Request 2 (e.g., Create Resource): Use that variable in the next request's header.
Header Key Header Value Authorization
Bearer {{auth_token}}
When you run the Collection Runner, it executes Request 1, sets the token, and then Request 2 uses that token, all within the same bulk iteration.
4. Technique 3: Conditional Looping and Flow Control
For advanced bulk actions like pagination or dynamic flows, you can use the postman.setNextRequest()
function in your request scripts.
Use Case: Pagination (Processing all pages of results)
If an API returns data in paginated format (e.g., only 100 records per call), you can't process the whole list in one go. You must loop until there are no more pages.
Request:
GET /data?page={{page_number}}
-
Pre-request Script: Initialize or increment the page number.
// Initialize page_number in environment or pre-request script if (pm.environment.get("page_number") === undefined) { pm.environment.set("page_number", 1); }
-
Post-response Script (The Loop Logic):
const response = pm.response.json(); const currentPage = pm.environment.get("page_number"); // Check if there's a next page or total results count if (response.has_more_pages === true) { // Increment the page number for the next iteration pm.environment.set("page_number", currentPage + 1); // Tell the runner to execute this SAME request again postman.setNextRequest(pm.info.requestName); } else { // End the loop by setting the next request to null (or the next item in the collection) postman.setNextRequest(null); }
By setting
postman.setNextRequest()
, you override the default sequential flow and force the runner to perform a bulk, data-gathering loop.
5. Taking Bulk Actions to CI/CD: Newman
For true automation, Postman provides Newman, its command-line collection runner. Newman allows you to run your bulk operations outside the Postman desktop app, making it perfect for CI/CD pipelines, automated testing, or background tasks.
Newman for Bulk Actions:
- Execution: Run collections and bulk data sets directly from a terminal or build server.
-
Data Injection: Supports the same data file inputs (
-d
or--data
) as the desktop Collection Runner. - Command Example:
# Run a collection 5 times using a specific environment and data file
newman run my_bulk_collection.json \
-e production_env.json \
-d bulk_create_data.csv \
-n 5 \
--reporters cli,htmlextra
Newman is the professional standard for scaling Postman bulk actions into a fully automated process.
Top comments (0)