Introduction
When I first opened Requestly Interceptor’s API Client, I expected the usual — a request builder, a few tabs, maybe a scripting panel. What I didn’t expect was how powerful and convenient their Variables and Environments system would be. If you’ve ever switched between dev, staging, and production APIs and found yourself constantly rewriting URLs, headers, or tokens, this feature will feel like a lifesaver. While working on a recent contribution to Requestly Interceptor, I got the chance to dive deep into Variables and Environments — and it turned out to be far more powerful than I expected. So in this article, I’m breaking down everything I learned in a simple, practical way. Think of this as your shortcut to mastering variables, with practical steps and screenshots that you can apply immediately in your own setup.Prerequisites
Before you begin, make sure you have:- Requestly Interceptor app installed (desktop or browser extension)
- Basic understanding of APIs and HTTP requests
- Access to multiple API environments (dev, staging, prod) - or you can use the free APIs mentioned in this guide
- Familiarity with API testing concepts
The Problem: Managing Multiple Environments
Most teams today maintain multiple environments:- Development
- Staging
- QA / Sandbox
- Production
- Base URLs
- Auth tokens
- Keys / secrets
- Custom headers
- Feature flags
Step-by-Step Guide
Step 1: Exploring Global Variables
Global variables are available everywhere — across all requests and environments. They are ideal for constants or secrets that don’t change frequently. I used them for things like API keys, common headers, or service base URLs.How to Create Global Variables
- Open the Environments panel in the sidebar
- Click Global Variables
- Add key/value pairs like
api_key,base_url, orcontent_type

{{variable}} in a request immediately shows the resolved value.
Example Global Variables:
Step 2: Creating Dev, Staging & Prod Environments
For my testing, I used three different APIs that all support the/users endpoint:
- Development —
https://jsonplaceholder.typicode.com - Staging —
https://dummyjson.com - Production —
https://jsonplaceholder.org
Setting Up Environments
- Open the Environments panel
- Click + Create Environment
- Name your environment (e.g., “Development”, “Staging”, “Production”)
- Add variables specific to each environment


Switching Between Environments
Now I can fetch users from all three environments simply by switching the active environment — no URL editing needed.- Look for the environment dropdown (usually in the top-right)
- Select your desired environment (Dev, Staging, or Prod)
- All
{{base_url}}references automatically update

Step 3: Understanding Runtime Variables
By now, you’ve seen how Global and Environment variables help you standardize values across multiple requests. But what if you need something more temporary? Maybe you’re:- Testing a login API and want to store a token for the next few calls
- Working across multiple workspaces and need a shared temporary value
- Debugging and want to store a session ID or a short-lived value
- Temporary access tokens
- Session IDs
- Dynamic values generated during test runs
- One-time use values
How to Create Runtime Variables
- Open Runtime Variables from the left sidebar
- Click + Add More
- Add your variable fields (key and value)


Step 4: Collection & SubCollection Variables
Until now, we’ve looked at Global, Environment, and Runtime variables. These cover most cases — but what if you want variables that belong only to a specific group of requests? For example:- A group of API calls related to Auth
- A group of APIs for a specific microservice
- A test set for payments, notifications, etc.
Setting Up Collection Variables
- Open the collection from the left sidebar
- Click on Collections
- Choose the collection you want
- Switch to the Variables tab
- Add your collection-specific variables

Understanding Variable Precedence in Requestly Interceptor
Requestly Interceptor resolves variables based on the most specific scope first. If the same variable name exists in multiple places, this is the priority:- Environment variables override everything
- If not found, Requestly Interceptor checks SubCollection, then Collection
- Global variables act as the final fallback
base_url defined in all scopes:
- Global:
https://api.example.com - Collection:
https://api-v2.example.com - Environment (Production):
https://prod.example.com
https://prod.example.com
Examples
Using Variables in API Requests
Once you’ve defined variables in Requestly Interceptor — whether global, environment, collection, or subcollection — you can reference them anywhere inside your API requests. This includes:- URLs
- Headers
- Query parameters
- Request bodies
- Pre-request scripts
- Post-response scripts

Example 1: Using Variables in URLs
Example 2: Using Variables in Headers
Example 3: Using Variables in Request Body

Example 4: Dynamic Variables in Scripts
Real-World Workflow Example
Here’s a complete workflow using all variable types:- Global Variables: Store API key and common headers
- Environment Variables: Define different
base_urlfor dev/staging/prod - Collection Variables: Set endpoint paths for Auth collection
- Runtime Variables: Store login token from response
- Make Authenticated Requests: Use stored token in headers
Conclusion
After working with Requestly Interceptor’s Variables & Environments, it’s clear how much they simplify everyday API work. No more editing URLs or tokens by hand, no more messy requests, and no more switching values manually across environments. Key Takeaways:- Global Variables: Use for constants shared across all requests
- Environment Variables: Essential for managing multiple deployment environments
- Runtime Variables: Perfect for temporary, session-based values
- Collection Variables: Organize variables by feature or service
- Variable Precedence: Environment → SubCollection → Collection → Global
Additional Resources
- Try Requestly Interceptor App
- Requestly Interceptor Documentation — Environment and Variables
- JSONPlaceholder Fake REST API
- DummyJSON API
- Join Requestly Interceptor Discord Community
Have questions about variables or want to share your setup? Join the Requestly Interceptor community or reach out at [email protected]

