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. Built-in ($) — Dynamic variables generated at runtime
  2. Session — Variables captured during the current session
  3. Collection — Variables scoped to the current collection
  4. Environment — Variables from the active environment file (rext.env.json)
  5. Global — Variables available across all files and sessions

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.

VariableDescriptionExample
{{$timestamp}}Unix epoch (seconds)1740583516
{{$timestampMs}}Unix epoch (milliseconds)1740583516000
{{$isoTimestamp}}ISO 8601 UTC2026-02-26T15:35:16.000Z
{{$localTimestamp}}Local date/time2026-02-26 11:35:16
VariableDescriptionExample
{{$date}}Local date YYYY-MM-DD2026-02-26
{{$date:DD/MM/YYYY}}Custom format26/02/2026
{{$date:HH:mm:ss}}Time only11:35:16
{{$date:DD-MMM-YYYY}}Abbreviated month26-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).

VariableDescriptionExample
{{$uuid}}UUID v4 (random)a1b2c3d4-e5f6-4a7b-...
{{$guid}}Alias for $uuida1b2c3d4-e5f6-4a7b-...
{{$uuidV1}}UUID v1 (timestamp)6fa459ea-ee8a-1a3e-...
VariableDescriptionExample
{{$randomInt}}Integer 0–1000742
{{$randomInt:1:100}}Integer in range37
{{$randomFloat}}Float 0–1 (2 decimals)0.73
{{$randomFloat:1:100:4}}Float with precision42.8193
{{$randomString}}Alphanumeric (16 chars)aB3xK9mP2qR7wT1s
{{$randomString:32}}Custom lengthaB3xK9mP...
{{$randomHex:8}}Hexadecimal stringa3f2b1c0
{{$randomEmail}}Random emailuser-a3f2b@rext.dev
{{$randomBoolean}}true or falsetrue
VariableDescriptionExample
{{$enum:a,b,c}}Random from listb
{{$enum:pending,active,closed}}API enumsactive
{{$enum:"hello, world","bye",ok}}Quoted values (with commas)hello, world
VariableDescriptionExample
{{$env}}Active environment nameProduction
POST {{baseUrl}}/api/orders
Content-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}}"
}

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.