Bird
Raised Fist0
Postmantesting~15 mins

Monitor scheduling in Postman - Build an Automation Script

Choose your learning style10 modes available
Verify Postman Monitor Scheduling and Execution
Preconditions (3)
Step 1: Navigate to the Postman Monitors tab
Step 2: Click 'Create a monitor' button
Step 3: Select the existing collection to monitor
Step 4: Set the monitor schedule to run every day at 9:00 AM
Step 5: Save the monitor
Step 6: Verify the monitor appears in the list with correct schedule
Step 7: Wait for the scheduled time or trigger the monitor manually
Step 8: Check the monitor run results for success or failure
✅ Expected Result: The monitor is created with the specified schedule, runs at the scheduled time, and the run results show the collection executed successfully.
Automation Requirements - Postman Collection Runner with Newman and Postman API
Assertions Needed:
Monitor creation response status is 201
Monitor schedule matches the requested schedule
Monitor run status is 'completed' and successful
Run results contain expected request responses
Best Practices:
Use Postman API to create and manage monitors programmatically
Use Newman CLI to run collections and validate results
Use explicit assertions on API responses and monitor run data
Handle asynchronous monitor run status checks with retries
Automated Solution
Postman
import requests
import time
import json

# Constants
API_KEY = 'YOUR_POSTMAN_API_KEY'
WORKSPACE_ID = 'YOUR_WORKSPACE_ID'
COLLECTION_ID = 'YOUR_COLLECTION_ID'

headers = {
    'X-Api-Key': API_KEY,
    'Content-Type': 'application/json'
}

# Step 1: Create a monitor with schedule
monitor_data = {
    "name": "Daily Monitor Test",
    "collection": COLLECTION_ID,
    "environment": None,
    "schedule": {
        "interval": 1,
        "unit": "day",
        "time": "09:00"
    },
    "workspace": WORKSPACE_ID
}

create_monitor_response = requests.post(
    'https://api.getpostman.com/monitors',
    headers=headers,
    data=json.dumps({"monitor": monitor_data})
)

assert create_monitor_response.status_code == 201, f"Monitor creation failed: {create_monitor_response.text}"

monitor_id = create_monitor_response.json()['monitor']['id']

# Step 2: Verify monitor schedule
assert create_monitor_response.json()['monitor']['schedule']['interval'] == 1
assert create_monitor_response.json()['monitor']['schedule']['unit'] == 'day'
assert create_monitor_response.json()['monitor']['schedule']['time'] == '09:00'

# Step 3: Trigger a manual run
run_response = requests.post(
    f'https://api.getpostman.com/monitors/{monitor_id}/run',
    headers=headers
)
assert run_response.status_code == 201, f"Monitor run trigger failed: {run_response.text}"

run_id = run_response.json()['run']['id']

# Step 4: Poll for run completion
for _ in range(10):
    time.sleep(5)  # wait 5 seconds before checking
    status_response = requests.get(
        f'https://api.getpostman.com/monitors/{monitor_id}/runs/{run_id}',
        headers=headers
    )
    assert status_response.status_code == 200
    run_status = status_response.json()['run']['status']
    if run_status == 'completed':
        break
else:
    assert False, 'Monitor run did not complete in expected time'

# Step 5: Verify run results
run_data = status_response.json()['run']
assert run_data['status'] == 'completed'
assert run_data['summary']['failed'] == 0, f"Some requests failed: {run_data['summary']}"

print('Monitor scheduling and run test passed successfully.')

This script uses the Postman API to automate monitor scheduling and execution verification.

First, it creates a monitor with a daily schedule at 9:00 AM and asserts the creation response is successful (status 201).

Then, it verifies the schedule details in the response to ensure correctness.

Next, it triggers a manual run of the monitor and checks the run creation response.

It polls the run status every 5 seconds up to 10 times to wait for completion.

Finally, it asserts the run completed successfully with no failed requests.

This approach uses explicit assertions and retries to handle asynchronous monitor runs, following best practices for API test automation.

Common Mistakes - 4 Pitfalls
Hardcoding API keys directly in the script
Not checking the monitor creation response status before proceeding
Using fixed sleep times without polling for run completion
Ignoring failed requests in monitor run results
Bonus Challenge

Now add data-driven testing to create monitors with 3 different schedules (daily at 9:00, hourly at 15 minutes past, weekly on Monday at 10:00).

Show Hint

Practice

(1/5)
1. What is the main purpose of Monitor scheduling in Postman?
easy
A. To run API tests automatically at set times
B. To manually trigger API tests whenever needed
C. To write new API test scripts
D. To share API collections with team members

Solution

  1. Step 1: Understand what monitor scheduling does

    Monitor scheduling runs API tests automatically without manual intervention.
  2. Step 2: Compare options with this purpose

    Only To run API tests automatically at set times describes automatic running at set times, matching monitor scheduling.
  3. Final Answer:

    To run API tests automatically at set times -> Option A
  4. Quick Check:

    Monitor scheduling = automatic test runs [OK]
Hint: Remember: scheduling means automatic timing [OK]
Common Mistakes:
  • Confusing manual triggering with scheduling
  • Thinking scheduling creates tests
  • Mixing sharing collections with scheduling
2. Which of the following is the correct way to set a monitor schedule in Postman?
easy
A. Schedule monitors only via Postman desktop app settings
B. Write a script in the Tests tab to schedule the monitor
C. Use the Runner tab to schedule monitor runs
D. Go to Monitors tab, select collection, then set frequency and time

Solution

  1. Step 1: Identify where scheduling is set in Postman

    Scheduling is done in the Monitors tab by selecting a collection and setting frequency/time.
  2. Step 2: Check other options for correctness

    The other options are incorrect because scheduling is not done via desktop app settings, scripts, or the Runner tab.
  3. Final Answer:

    Go to Monitors tab, select collection, then set frequency and time -> Option D
  4. Quick Check:

    Monitors tab = schedule location [OK]
Hint: Set schedules only in Monitors tab [OK]
Common Mistakes:
  • Trying to schedule in Runner tab
  • Writing scripts to schedule
  • Looking for schedule in desktop app settings
3. Consider this monitor schedule set to run every day at 9:00 AM UTC. If today is Monday 8:00 AM UTC and you create the monitor now, when will the first run happen?
medium
A. Immediately after creation
B. Tuesday at 9:00 AM UTC (next day)
C. Monday at 9:00 AM UTC (in 1 hour)
D. Monday at 8:00 AM UTC (now)

Solution

  1. Step 1: Understand the schedule timing

    The monitor runs daily at 9:00 AM UTC. Current time is Monday 8:00 AM UTC.
  2. Step 2: Calculate next run time

    Since 9:00 AM is 1 hour ahead, the first run will be Monday at 9:00 AM UTC.
  3. Final Answer:

    Monday at 9:00 AM UTC (in 1 hour) -> Option C
  4. Quick Check:

    Next run = next scheduled time after now [OK]
Hint: Next run is next scheduled time after current time [OK]
Common Mistakes:
  • Assuming immediate run on creation
  • Choosing next day instead of same day if time not passed
  • Confusing current time with scheduled time
4. You set a monitor to run every 2 hours but notice it only runs once a day. What is the most likely cause?
medium
A. The schedule frequency was set incorrectly to daily instead of every 2 hours
B. The API collection has no tests, so monitor skips runs
C. Postman monitors cannot run more than once a day
D. You need to restart Postman app to apply schedule changes

Solution

  1. Step 1: Analyze the monitor schedule setting

    If monitor runs only once a day despite setting every 2 hours, likely the frequency was set wrong.
  2. Step 2: Evaluate other options

    API collection without tests still runs; Postman supports multiple runs per day; restarting app not needed.
  3. Final Answer:

    The schedule frequency was set incorrectly to daily instead of every 2 hours -> Option A
  4. Quick Check:

    Check schedule frequency matches intended run rate [OK]
Hint: Verify schedule frequency matches your expectation [OK]
Common Mistakes:
  • Assuming no tests stops runs
  • Thinking Postman limits runs per day
  • Restarting app fixes schedule issues
5. You want to monitor an API that updates every weekday at 6 PM UTC. Which schedule setup in Postman Monitor will best fit this requirement?
hard
A. Set monitor to run every hour and add a test to skip weekends
B. Set monitor to run daily at 6 PM UTC and disable weekends
C. Set monitor to run weekly on Friday at 6 PM UTC
D. Set monitor to run daily at 6 PM UTC without any weekend restrictions

Solution

  1. Step 1: Identify the required schedule

    The API updates every weekday at 6 PM UTC, so monitor should run only Monday to Friday at that time.
  2. Step 2: Match options to requirement

    Set monitor to run daily at 6 PM UTC and disable weekends sets daily at 6 PM and disables weekends, matching exactly. Set monitor to run every hour and add a test to skip weekends runs too often and relies on tests to skip. Set monitor to run weekly on Friday at 6 PM UTC runs only once a week. Set monitor to run daily at 6 PM UTC without any weekend restrictions runs on weekends too.
  3. Final Answer:

    Set monitor to run daily at 6 PM UTC and disable weekends -> Option B
  4. Quick Check:

    Schedule matches update days and time [OK]
Hint: Disable weekends to run only on weekdays [OK]
Common Mistakes:
  • Running monitor on weekends unnecessarily
  • Using tests to skip runs instead of schedule
  • Setting weekly instead of daily schedule
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard