Add script runner blocks to your notebook

View as Markdown

Write JavaScript code 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. In addition, you can import external libraries and visualize your data.

You can also reference a script runner block’s output elsewhere in your notebook.

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, enter 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

Reference your script runner block by name. For example, if you name your script runner block “randomNumber”, you can reference its output with the syntax {{randomNumber}} in text, an input block, a request block, or an AI request block.

Or you can reference it with the syntax $randomNumber in another script runner block.

Furthermore, you can use dot notation to reference data within the output. For example, in request block, you can reference the user’s first email with the syntax {{randomNumber.emails.0}}. Or in another script runner block, you can reference the same value with the syntax $randomNumber.emails[0].

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 text, an input block, a request block, or an AI request block, use the syntax {{scriptRunnerBlockName}} or {{scriptRunnerBlockName.path.to.data}}.
    • To reference your script runner block in another script runner block, use the syntax $scriptRunnerBlockName or $scriptRunnerBlockName.path.to.data.