Add script runner blocks to your notebook

You can write JavaScript code and reference its output elsewhere in your notebook to create an interactive experience. For example, you can add a script runner block that generates a random number and use that number in a request block that accepts one. You can also import external libraries.

Add a script runner block

To add a script runner block, do the following:

  1. Open your notebook or create a new one.
  2. Place your cursor where you want to add the script runner block. Then, type a forward slash (”/”). Postman displays a block menu.
  3. Choose Run icon Script Runner.
  4. Name your script runner block.
  5. Write your code.
  6. Click Run icon Run.

Postman runs the code and returns the result. To see the logs, open the Logs tab.

Reference your script runner block

You can reference your script runner block by name. For example, if you name your script runner block “randomNumber”, you can reference its output in a request block with the syntax {{randomNumber}}. Or you can reference it in another script runner block with the syntax $randomNumber.

To reference your script runner block, do the following:

  1. Open your notebook or create a new one.

  2. Get your script runner block’s name.

  3. Reference your script runner block:

    • To reference your script runner block in an input or request block, use the syntax {{scriptRunnerName}}.
    • To reference your script runner block in another script runner block, use the syntax $scriptRunnerName.

Last modified: 2025/11/04