Variables and Environments
Variables and Environments
Reuse values across requests and switch between environments.
Overview
A variable is a named value you write into a request as {{name}}. Relay replaces each token when it sends the request, so a base URL, an API key or an ID can be defined once and used everywhere.
Variables can be defined at several levels: globally, on a workspace, on a collection, on a folder, or in an environment. An environment is a named set of variables, such as Development or Production, and switching environments changes every request that uses its variables.
Relay also generates dynamic variables, such as {{$guid}} and {{$randomEmail}}, that produce a new value each time a request is sent.
Topics
Variables
- Using variables: Insert values into requests with
{{name}}tokens and see where each value comes from. - Managing environments: Switch between sets of variables for development, staging and production.
Secrets and generated values
- Keeping secrets on your Mac: Keep tokens and passwords out of shared workspace files.
- Generating dynamic values: Fill requests with fresh IDs, timestamps and sample data each time they're sent.
See Also
- Reading and writing variables in scripts: Read variables and set new values from pre-request and post-response scripts.
- Dynamic variables: Dynamic variables that generate a new value each time a request is sent.