#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Introduction to Pre-request Scripts

What Is a Pre-request Script?

A pre-request script is a snippet of JavaScript that runs immediately before a request is sent. It's commonly used to set variables, generate timestamps, or compute values needed by the request.

Where to Add One

Every request, folder, and collection has a Pre-request Script tab. Scripts at the collection or folder level run for every request inside them, which is useful for shared setup logic.

Common Use Cases

Use CaseExample
Dynamic timestampsSet a variable to the current date/time
Generating tokensCompute a signature before sending
Randomized test dataGenerate a random email or ID

Pre-request scripts rely on the built-in pm object, which is covered in more detail next.

To write meaningful pre-request scripts and tests, you'll need to understand the pm object and how JavaScript works inside Postman.

Ready to master Postman API Testing Course?

Join Uncodemy's hands-on training and build real-world API testing skills with expert mentors.

Explore Course