# Templates for environments with common variables?

**URL:** <https://community.postman.com/t/templates-for-environments-with-common-variables/37772>\
**Category:** Help Hub\
**Tags:** variables, environments\
**Created:** [August 2, 2022, 5:17am UTC](https://community.postman.com/t/templates-for-environments-with-common-variables/37772 "2022-08-02T05:17:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrWeis](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@AndrWeis](https://community.postman.com/u/AndrWeis)\
**Post date:** [August 2, 2022, 5:17am UTC](https://community.postman.com/t/templates-for-environments-with-common-variables/37772/1 "2022-08-02T05:17:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [August 2, 2022, 9:33am UTC](https://community.postman.com/t/templates-for-environments-with-common-variables/37772/2 "2022-08-02T09:33:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [August 2, 2022, 9:36am UTC](https://community.postman.com/t/templates-for-environments-with-common-variables/37772/3 "2022-08-02T09:36:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AndrWeis](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@AndrWeis](https://community.postman.com/u/AndrWeis)\
**Post date:** [August 2, 2022, 11:19pm UTC](https://community.postman.com/t/templates-for-environments-with-common-variables/37772/4 "2022-08-02T23:19:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [August 3, 2022, 8:50am UTC](https://community.postman.com/t/templates-for-environments-with-common-variables/37772/5 "2022-08-03T08:50:43Z")

</div>

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