Variables and Environments

Managing environments

Switch between sets of variables for development, staging and production.

Overview

An environment is a named set of variables, such as Development, Staging or Production. Define the same variable names in each environment with different values, then switch environments to point every request in the workspace at a different server or account.

Each workspace has its own environments, and one of them at a time can be active. The active environment's variables override the collection's, the workspace's and the global ones, but not a folder's. For the full order, see Using variables.

Create an environment

The quickest way is from the request editor:

  1. In the bar at the bottom of the request editor, click the Environments button.
  2. Choose Add Environment….
  3. Enter a name and click Add.

Relay makes the new environment active and opens it in the Workspaces window, where you add its variables.

You can also create one in the Workspaces window:

  1. In the sidebar, click the workspace menu and choose Edit Workspaces….
  2. Select the workspace and click Variables.
  3. Click the New Environment button (+) at the bottom of the window.
  4. Enter a name and click Save.

A workspace's first environment is named Development to start with, and it becomes active if no environment is.

Edit an environment's variables

  1. In the Workspaces window, select the workspace and click Variables.
  2. Choose the environment from the menu at the bottom of the window.
  3. Click Add Variable and enter a name and value. Repeat for each variable.

Choose Default from the same menu to edit the workspace's own variables. They apply whichever environment is active, and an environment's variable of the same name overrides them. Keep values that are the same everywhere in Default, and only the values that differ in each environment.

Switch environments

Choose the environment to make active in any of these places:

  • The Environment section of the workspace menu at the top of the sidebar.
  • Request > Environment.
  • The Environments button in the bar at the bottom of the request editor.

Choose No Environment to use no environment's variables.

The active environment belongs to the workspace, so every window showing that workspace uses it. Switching it isn't something you can undo, and it isn't saved in a workspace's folder, so teammates who share the workspace each choose their own.

Rename, reorder and delete environments

In the Workspaces window, choose the environment from the menu at the bottom of the Variables tab, then click the Environment Options button (…) beside it and choose one of these:

  • Rename…: Enter a new name and click Save.
  • Duplicate: Create a copy with the same variables, named with "(Copy)" at the end.
  • Move Up or Move Down: Change the environment's place in menus.
  • Delete…: Delete the environment and its variables, after you confirm.

To bring back an environment you deleted, choose Edit > Undo in the Workspaces window.

To manage environments from the main window, choose Manage Environments… from Request > Environment or from the Environments button.

Import a Postman environment

If you have environments in Postman, export them and import them into a workspace. Relay keeps their variables, and Postman's secret variables become secret variables in Relay. For more information, see Importing Postman collections and environments.

See Also