Variables and Environment

Variables in Requestly’s API Client let you store and reuse dynamic values—like API keys, base URLs, and user IDs—across your API requests. They help you avoid hardcoding, make your collections more modular, and simplify switching between different environments like development, staging, and production.

A variable is a named placeholder you define once and reference anywhere in your API collections using the {{variable_name}} syntax.

When you run a request, Requestly replaces each {{variable}} with its actual value based on its scope.

Example: https://{{base_url}}/users/{{user_id}}

If you've defined base_url = api.example.com and user_id = 123, the request resolves to - https://api.example.com/users/123

+TIP: Hover over any {{variable}} in your request to preview its resolved value instantly.

Explore Variable Types and Features

Global Variables

Use values that apply across all requests and collections.

Environment Variables

Define values based on your working environment (e.g., dev, staging, prod).

Collection & SubCollection Variables

Scope variables to specific collections or groups of requests.

Variable Precedence

Understand how Requestly resolves variable conflicts when the same name exists in multiple scopes.

Using Variables in API Requests

Learn where and how to use variables in your API request URLs, headers, bodies, and scripts.

Updated on