Skip to content

Variables

Variables let you use dynamic values throughout your .rext files. They are enclosed in double curly braces: {{variableName}}.

GET {{baseUrl}}/users
Authorization: Bearer {{token}}

Variables can be used in:

  • URLsGET {{baseUrl}}/users
  • HeadersAuthorization: Bearer {{token}}
  • Body{ "email": "{{email}}" }
  • Query parameters@query search = {{searchTerm}}

When Rext encounters a {{variableName}}, it resolves the value from these scopes, in order:

  1. Session — Variables captured during the current session
  2. Collection — Variables scoped to the current collection
  3. Environment — Variables from the active environment file (rext.env.json)
  4. Global — Variables available across all files and sessions

Variables can be set in two ways:

Define variables in rext.env.json:

{
"Development": {
"baseUrl": "http://localhost:3000",
"apiKey": "dev-key-123"
},
"Production": {
"baseUrl": "https://api.production.com",
"apiKey": "prod-key-456"
}
}

See Environment Files for details.

Extract values from responses using @capture:

@name Login
POST {{baseUrl}}/auth/login
@capture token = body.access_token

See Variable Capture for details.