Templates for environments with common variables?

Is it possible to define a template for environments which defines what variables the environments has to contain? E.g. I might expect every environment I use to have a variable called “base_url”. Is there a way to enforce that every environment defines a base_url variable, or do you just have to manage it manually?

Hi @AndrWeis

You could create an environment and then export it (as your template).

Each time you start a new environment, just import the environment.JSON file that will have your default variables… and change the environment name as appropriate.

Alternatively, you could set up all your variables using a pre-req script and the pm.environment.set(); option.

But in my opinion, exporting a template to re-use would be more efficient.

OK, thanks. It’s not ideal. It seems to me that Postman has variables and environments upside down. You want to define a set of variables first, and then provide different values in different environments. In Postman, it’s the other way around.

1 Like

If you want the same value across multiple environments, you could declare global variables instead of environment-level variables.