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:
- Built-in ($) — Dynamic variables generated at runtime
- 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
Built-in Dynamic Variables
Section titled “Built-in Dynamic Variables”Built-in variables start with $ and generate a new value each time a request is executed. Each occurrence produces a unique value — two {{$uuid}} in the same request generate two different UUIDs.
Timestamps
Section titled “Timestamps”| Variable | Description | Example |
|---|---|---|
{{$timestamp}} | Unix epoch (seconds) | 1740583516 |
{{$timestampMs}} | Unix epoch (milliseconds) | 1740583516000 |
{{$isoTimestamp}} | ISO 8601 UTC | 2026-02-26T15:35:16.000Z |
{{$localTimestamp}} | Local date/time | 2026-02-26 11:35:16 |
Date Formatting
Section titled “Date Formatting”| Variable | Description | Example |
|---|---|---|
{{$date}} | Local date YYYY-MM-DD | 2026-02-26 |
{{$date:DD/MM/YYYY}} | Custom format | 26/02/2026 |
{{$date:HH:mm:ss}} | Time only | 11:35:16 |
{{$date:DD-MMM-YYYY}} | Abbreviated month | 26-Feb-2026 |
{{$date:+7:YYYY-MM-DD}} | Offset (+/- days) | 2026-03-05 |
Supported tokens: YYYY, MM, DD, HH, mm, ss, SSS, MMM (abbreviated), MMMM (full month name).
| Variable | Description | Example |
|---|---|---|
{{$uuid}} | UUID v4 (random) | a1b2c3d4-e5f6-4a7b-... |
{{$guid}} | Alias for $uuid | a1b2c3d4-e5f6-4a7b-... |
{{$uuidV1}} | UUID v1 (timestamp) | 6fa459ea-ee8a-1a3e-... |
Random Generators
Section titled “Random Generators”| Variable | Description | Example |
|---|---|---|
{{$randomInt}} | Integer 0–1000 | 742 |
{{$randomInt:1:100}} | Integer in range | 37 |
{{$randomFloat}} | Float 0–1 (2 decimals) | 0.73 |
{{$randomFloat:1:100:4}} | Float with precision | 42.8193 |
{{$randomString}} | Alphanumeric (16 chars) | aB3xK9mP2qR7wT1s |
{{$randomString:32}} | Custom length | aB3xK9mP... |
{{$randomHex:8}} | Hexadecimal string | a3f2b1c0 |
{{$randomEmail}} | Random email | user-a3f2b@rext.dev |
{{$randomBoolean}} | true or false | true |
Enum (Pick from List)
Section titled “Enum (Pick from List)”| Variable | Description | Example |
|---|---|---|
{{$enum:a,b,c}} | Random from list | b |
{{$enum:pending,active,closed}} | API enums | active |
{{$enum:"hello, world","bye",ok}} | Quoted values (with commas) | hello, world |
Metadata
Section titled “Metadata”| Variable | Description | Example |
|---|---|---|
{{$env}} | Active environment name | Production |
Complete Example
Section titled “Complete Example”POST {{baseUrl}}/api/ordersContent-Type: application/json
{ "id": "{{$uuid}}", "timestamp": {{$timestamp}}, "deliveryDate": "{{$date:+30:YYYY-MM-DD}}", "priority": {{$randomInt:1:5}}, "status": "{{$enum:pending,processing,shipped}}", "environment": "{{$env}}", "contactEmail": "{{$randomEmail}}"}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