Skip to main content

Pre Processor Scripts

A preprocessor script is a code snippet that is executed before the request is sent. This is useful when you want to include a timestamp in the request header or send a random alphanumeric string in the URL parameters.


You can use the value returned to set the environment variable in order to include the current timestamp in the request header.

Set the value of the parameter timestamp as {{timestamp}}. When the request is sent, the preprocessor script will be executed, the value of the environment variable timestamp will be set and replaced with the current timestamp.


The corresponding environment must be selected when setting an environment variable. The preprocessor script is written in JavaScript and has exactly the same syntax as the postprocessor script. However, there is no pm.response object.

More Examples

  1. View examples of test/assertion here.
  2. View examples of using different variables, including environment variables, and global variables, local variables here.
  3. View examples of sending API requests with scripts.