Learn how to use variables and environments in Requestly to manage dynamic values like API keys, base URLs, and tokens across your API requests.
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.
Global VariablesUse values that apply across all requests and collections.Environment VariablesDefine values based on your working environment (e.g., dev, staging, prod).Runtime VariablesTemporary values that last only for the current session, ideal for tokens or session IDs. They aren’t synced and can auto-clear after use.Collection & SubCollection VariablesScope variables to specific collections or groups of requests.Variable PrecedenceUnderstand how Requestly resolves variable conflicts when the same name exists in multiple scopes.Using Variables in API RequestsLearn where and how to use variables in your API request URLs, headers, bodies, and scripts.Set a Response Value as a VariableCapture a value out of a response body into a variable by right-clicking the selection, with no script to write.