documentation/features/environments.mdx
An environment allows you to group together a set of variable data. You can reference the variable data you define in an environment throughout Hoppscotch 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.
Hoppscotch environment provides support for two types of variables
A Regular environment variable allows users to reference the variable throughout Hoppscotch, and anyone can see the value associated with the variable. In a shared workspace, regular environment variable-value pairs will be synced to the server, making them available to all workspace members. However, you have the option to choose whether to sync a personal or global environment.
A secret environment variable enables users to specify secrets and reference the values as variables. The values of secret variables in any workspace will never be synced to the server or shared with any workspace members. It is expected that the user will populate the value of the variable at runtime. All secret variable values in Hoppscotch will be masked using asterisks (***).
<Tip>Secret variables values will not be exported when an environment is exported.</Tip>
An environment variable can have two types of values:
| Environment Variable | Secret Variable | |
|---|---|---|
| Workspace Owner | create / delete variable, edit value and use | create / delete secret variable, add values and use |
| Workspace Editor | create / delete variable, edit value and use | create / delete secret variable, add value and use |
| Workspace Viewer | use | add value and use |
Click on the ”Environments” icon on the sidebar to create environments.
A variable created in an environment can be used by typing the variable name enclosed in double angle brackets <<variable>>
You can also create and delete environment variables using scripts by using the pw object..
pw.env.set("variable", "value"); // Creates an environment variable
pw.env.unset("variable"); // Deletes the environment variable
Create a copy of an existing environment to modify or test different configurations without affecting the original:
- Duplicate will be created.<Note> Secret variable values will not be copied to the duplicated environment. </Note>
<CardGroup cols={1}> <Card title="Creating environment variables from client" iconType="light" icon="circle-arrow-right" href="/documentation/getting-started/rest/environment-variables"> Learn how you can create environment variables from the client. </Card> <Card title="Creating environment variables using scripts" iconType="light" icon="circle-arrow-right" href="/documentation/getting-started/rest/pre-request-scripts#setting-environment-variables"> Learn how you can create environment variables using pre-request scripts. </Card> <Card title="Read more pre-request script examples" iconType="light" icon="circle-arrow-right" href="/documentation/getting-started/rest/pre-request-scripts#examples"> Learn more pre-request script examples. </Card> </CardGroup>