Variables are placeholders used to store dynamic values that may change based on the environment or request context, such as API keys, user tokens, or base URLs. Using variables allows you to create reusable API requests by referencing variable names instead of hard-coding specific values.
An environment is a distinct context or container that holds a set of variables, allowing you to configure and manage specific settings for different scenarios where an API might be deployed—such as Development, Testing, Staging, or Production. Each environment contains its own set of variables, like base URLs, API keys, or tokens, which vary depending on the deployment context.
Example:
Lets say there are 2 environments PROD and BETA and both have a base_url
variable with values https://api.example.com
and https://api.dev.example.com
respectively. You can use a variable placeholder like {{base_url}}
in your requests. The API client will pull the correct value from the active environment.
Example Usage:
In this example:
-
If the BETA environment is active,
{{base_url}}
might resolve tohttps://api.dev.example.com
. -
If the PROD environment is active, it will resolve to
https://api.example.com
.
Creating and using environments
Environments allow you to set up different sets of variables for various workflows in Requestly. For example, you might use one set of values for requests sent to a test server and another for requests sent to a production server.
Learn how to create and switch environments, then you can add and edit variables in each environment.