Variables
Variables
Section titled “Variables”Variables let you use dynamic values throughout your .rext files. They are enclosed in double curly braces: {{variableName}}.
Syntax
Section titled “Syntax”GET {{baseUrl}}/usersAuthorization: Bearer {{token}}Variables can be used in:
- URLs —
GET {{baseUrl}}/users - Headers —
Authorization: Bearer {{token}} - Body —
{ "email": "{{email}}" } - Query parameters —
@query search = {{searchTerm}}
Variable Resolution Order
Section titled “Variable Resolution Order”When Rext encounters a {{variableName}}, it resolves the value from these scopes, in order:
- Session — Variables captured during the current session
- Collection — Variables scoped to the current collection
- Environment — Variables from the active environment file (
rext.env.json) - Global — Variables available across all files and sessions
Setting Variables
Section titled “Setting Variables”Variables can be set in two ways:
1. Environment Files
Section titled “1. Environment Files”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.
2. Variable Capture
Section titled “2. Variable Capture”Extract values from responses using @capture:
@name LoginPOST {{baseUrl}}/auth/login
@capture token = body.access_tokenSee Variable Capture for details.
Next Steps
Section titled “Next Steps”- Set up Environment Files
- Learn about Variable Capture