With version v0.10+ Postman has the ability to execute pre-request scripts.
Pre-request scripts are snippets of code associated with a collection request that are executed before the request is sent. This is perfect for use-cases like including the timestamp in the request headers or sending a random alphanumeric string in the URL parameters.
For example, to include a timestamp in the request headers you can set an environment variable with the value returned from a function:
You can then use the timestampHeader variable in the header key-value editor. When the request is sent, your pre-request script will be executed, and the value of timestampHeader will be sent in place of .
Note: An environment will have to be active for env variables to be set.
The syntax of pre-requests scripts is exactly like that of test scripts except that the response object is not present for obvious reasons.
To check what is available in the pre-request script sandbox, take a look at the Sandbox documentation.