Skip to main content

Variable Syntax

Basic Syntax

Wrap the variable name in double curly braces:

{{variableName}}

Variables are case-sensitive: {{baseUrl}} and {{BaseUrl}} are different variables.

Where Variables Work

LocationSupported
URL
Query parameter keys
Query parameter values
Header keys
Header values
Raw body
Bearer token
Basic auth username/password
API Key value
OAuth 2.0 token URL, client ID/secret
Pre-request scripts (via rm.variables.get())

Examples

URL with base URL and path variable:

{{baseUrl}}/users/{{userId}}

Header with token:

Authorization: Bearer {{accessToken}}

JSON body:

{
"email": "{{testEmail}}",
"password": "{{testPassword}}"
}

Unresolved Variables

If a variable is used but not defined in any scope, it is sent as-is:

{{undefinedVar}}  →  sent literally as  {{undefinedVar}}

Setting Variables from Scripts

You can set variables dynamically in pre-request scripts:

// Set an environment variable
rm.environment.set('accessToken', 'abc123')

// Set a collection variable
rm.collectionVariables.set('userId', '42')

// Set a global variable
rm.globals.set('sharedKey', 'value')

See the rm.* API Reference for full details.