Environments
Environments help you create variables that you can reuse in requests and scripts.
An environment allows you to group together a set of variable data. You can reference the variable data you define in an environment throughout PruTAN when sending requests or using scripts. Environments are also useful when you need to manage shared variables with a team. You can create environments and share them with your workspace members.
Click on the "Environments" icon on the sidebar to create environments.
Adding Environment Variables
You can create a new environment by clicking the environments icon in the submenu options and clicking the new button. Let's label the environment as E-Comm_Env.
Now, let's create an environment variable called baseUrl where baseUrl = https://app.prutan.com/prutan/core/router, pointing to /HB/d6f7f864-3556-45dc-bdb6-c31664b02898.
Similarly, you can create multiple environments and environment variables.
Accessing Environment Variables
If you have more than one environments, select the environment whose variables you want to access. You can access the variables in the request section by referencing the variable in the following format {{variable_name}}, in our case the variable will be {{baseUrl}} and the complete URL will be {{baseUrl}}/HB/d6f7f864-3556-45dc-bdb6-c31664b02898.
Types of Environments
- Global Environment – The global environment is workspace-specific and accessible to all members within that workspace. Variables defined in the global environment are always available for use without requiring manual selection, providing a consistent and shared configuration across the workspace.
- Personal Environment – The personal environment is private to the workspace and can be shared only with its members. It can be created for specialized or temporary use cases within the same workspace. A personal environment must be explicitly selected from the dropdown to be active, and when selected, its variables take precedence over the global environment variables for that execution.
PRUTAN Environment Preference Rules
When both Global and Selected environments define the same key:
Priority Order:
- Selected Environment (highest priority)
- Global Environment
Example:
Global: { baseUrl: "https://prod.prutan.com" }
Selected: { baseUrl: "https://dev.prutan.com" }
Result: Uses "https://dev.prutan.com" (selected overrides global)This ensures environment-specific overrides for testing different setups without modifying shared global configs.
Using Scripts
You can also create and fetch environment variables using scripts in the Rules tab.
// To create environment variable for currently selected environment else global environment
env.set('key', 'value');
// To get environment variable
env.get('key');Environments Import/Export
PruTAN also provides environment import/export functionality. If you want to share a created environment with members who are not part of the team or use this environment collection in another team, you can export the specific environment or all environments simultaneously as a JSON file. After that, the file can be imported into PruTAN environments.
Image 1: Export Single Environment Collection
Steps to export a single environment collection:
- Go to the Environment sidebar and hover on the environment you want to export.
- On hover, you will see three vertical dots; click on them.
- On click, a dropdown will show the export button.
- Click on it and the environment will be exported.
Image 2: Import & Export All Environments Simultaneously
A. Steps to export all environment collections:
- Go to the environment sidebar section.
- Click on the Import/Export button icon.
- A dialog box will open with the option to export.
- Click on the export button and all the environments will be exported.
B. Steps to import environment collections:
- Go to the environment sidebar section.
- Click on the Import/Export button icon.
- A dialog box will open with the option to import.
- Click on the import button, select an env JSON file exported from PruTAN, and import it.
Duplicating an Environment
Create a copy of an existing environment to modify or test different configurations without affecting the original:
- Click the "Environments" icon in the sidebar to view all existing environments.
- Hover over the environment you want to duplicate; a three-dot icon will appear. Click on the three-dot icon.
- From the dropdown menu, select "Duplicate". A new environment with the suffix "- Duplicate" will be created.