Dynamic Variables
Generate random data automatically in your requests
Overview
Dynamic variables allow you to generate random, unique data on-the-fly without writing scripts. Perfect for load testing, creating test data, and avoiding hardcoded values.
Available Dynamic Variables
Request Man provides 9 built-in dynamic variables. Simply use them anywhere in your requests:
| Variable | Description | Example Output |
|---|---|---|
{{$guid}} |
UUID v4 (GUID) | a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6 |
{{$timestamp}} |
Unix timestamp (seconds) | 1732627200 |
{{$isoTimestamp}} |
ISO 8601 timestamp | 2025-11-26T12:34:56.789Z |
{{$randomInt}} |
Random integer (0-1000) | 527 |
{{$randomUUID}} |
Another UUID v4 | f7e8d9c0-1a2b-4c5d-8e9f-0a1b2c3d4e5f |
{{$randomAlphaNumeric}} |
Random alphanumeric (10 chars) | aB3dEf9GhI |
{{$randomBoolean}} |
Random boolean | true or false |
{{$randomIP}} |
Random IPv4 address | 192.168.1.100 |
{{$randomEmail}} |
Random email address | user_abc123@example.com |
How to Use Dynamic Variables
In URL
GET https://api.example.com/users/{{$guid}}
GET https://api.example.com/data?timestamp={{$timestamp}}
In Headers
X-Request-ID: {{$guid}}
X-Timestamp: {{$timestamp}}
X-Trace-ID: {{$randomUUID}}
In JSON Body
{
"id": "{{$guid}}",
"timestamp": {{$timestamp}},
"email": "{{$randomEmail}}",
"age": {{$randomInt}},
"active": {{$randomBoolean}},
"ip_address": "{{$randomIP}}",
"session_id": "{{$randomAlphaNumeric}}"
}
{{$timestamp}}, {{$randomInt}}, or {{$randomBoolean}} in JSON - they output raw numbers/booleans!
In Query Parameters
page={{$randomInt}}
id={{$guid}}
timestamp={{$timestamp}}
Practical Examples
Example 1: User Registration Testing
Create unique users without manually changing email addresses:
POST https://api.example.com/users
Content-Type: application/json
{
"id": "{{$guid}}",
"email": "{{$randomEmail}}",
"username": "user_{{$randomAlphaNumeric}}",
"created_at": {{$timestamp}},
"is_active": {{$randomBoolean}},
"ip_address": "{{$randomIP}}"
}
Example 2: Order Creation (Load Testing)
Generate unique orders for load testing:
POST https://api.example.com/orders
Content-Type: application/json
{
"order_id": "{{$guid}}",
"transaction_id": "{{$randomUUID}}",
"customer_id": {{$randomInt}},
"amount": {{$randomInt}},
"timestamp": {{$timestamp}},
"created_at": "{{$isoTimestamp}}",
"confirmed": {{$randomBoolean}}
}
Example 3: API Request Tracking
Add unique identifiers to track requests:
GET https://api.example.com/data
X-Request-ID: {{$guid}}
X-Timestamp: {{$timestamp}}
X-Trace-ID: {{$randomUUID}}
X-Client-IP: {{$randomIP}}
Example 4: A/B Testing with Random Flags
Randomly enable/disable features:
POST https://api.example.com/feature-flags
Content-Type: application/json
{
"user_id": "{{$guid}}",
"new_ui_enabled": {{$randomBoolean}},
"beta_features": {{$randomBoolean}},
"experimental_mode": {{$randomBoolean}},
"timestamp": {{$timestamp}}
}
Uniqueness & Freshness
Fresh Generation Every Time
Dynamic variables generate new values for each request:
First Request
{"id": "aaaa-bbbb-cccc-dddd", "email": "user_abc@example.com"}
Second Request (Same Configuration)
{"id": "1111-2222-3333-4444", "email": "user_xyz@example.com"}
Third Request
{"id": "9999-8888-7777-6666", "email": "user_def@example.com"}
Multiple Variables in Same Request
Each occurrence generates a unique value:
{
"order_id": "{{$guid}}", // aaaa-bbbb-cccc-dddd
"transaction_id": "{{$guid}}", // 1111-2222-3333-4444
"session_id": "{{$guid}}" // 9999-8888-7777-6666
}
All three GUIDs will be different!
Load Testing with Dynamic Variables
Collection Runner Integration
Use dynamic variables with Collection Runner for powerful load testing:
Create Request with Dynamic Variables
POST https://api.example.com/orders
{
"order_id": "{{$guid}}",
"user_id": {{$randomInt}},
"timestamp": {{$timestamp}}
}
Add to Collection
Save the request to a collection.
Run with Iterations
In Collection Runner, set iterations to 1000.
Result
1000 unique orders created with different IDs, user IDs, and timestamps!
Combining with Other Variables
Mix dynamic variables with environment and collection variables:
Example: Multi-Environment Testing
POST {{baseUrl}}/api/users
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"id": "{{$guid}}",
"email": "{{$randomEmail}}",
"timestamp": {{$timestamp}},
"environment": "{{env_name}}"
}
| Variable Type | Variable | Value |
|---|---|---|
| Environment | {{baseUrl}} |
https://api.example.com |
| Environment | {{authToken}} |
Bearer_abc123... |
| Environment | {{env_name}} |
production |
| Dynamic | {{$guid}} |
a1b2... (fresh each time) |
| Dynamic | {{$randomEmail}} |
user_xyz@... (fresh each time) |
| Dynamic | {{$timestamp}} |
1732627200 (fresh each time) |
Testing Generated Values
Use test scripts to validate dynamic variable output:
UUID Format Validation
// Test that GUID is valid UUID format
rm.test("GUID is valid UUID", function () {
const jsonData = rm.response.json();
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
rm.expect(jsonData.id).to.match(uuidRegex);
});
Timestamp Validation
// Test that timestamp is recent (within last 5 seconds)
rm.test("Timestamp is recent", function () {
const jsonData = rm.response.json();
const now = Math.floor(Date.now() / 1000);
rm.expect(jsonData.timestamp).to.be.closeTo(now, 5);
});
Email Format Validation
// Test that email is valid format
rm.test("Email is valid", function () {
const jsonData = rm.response.json();
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
rm.expect(jsonData.email).to.match(emailRegex);
});
Boolean Type Validation
// Test that boolean is actual boolean type
rm.test("Active is boolean", function () {
const jsonData = rm.response.json();
rm.expect(jsonData.active).to.be.a('boolean');
});
Dynamic Variables vs. Scripts
| Feature | Dynamic Variables | Pre-request Scripts |
|---|---|---|
| Ease of Use | ✅ Very Easy - Just type {{$guid}} |
⚠️ Requires JavaScript knowledge |
| Speed | ✅ Instant | ⚠️ Script execution overhead |
| Customization | ❌ Limited - fixed formats | ✅ Fully customizable |
| Common Use Cases | ✅ Perfect for standard data | ✅ Perfect for complex logic |
| Learning Curve | ✅ None | ⚠️ Need to learn syntax |
When to Use Dynamic Variables
- Quick testing with random data
- Load testing with unique IDs
- Creating test users/orders/records
- Adding timestamps to requests
- Generating request tracking IDs
When to Use Scripts Instead
- Custom data format requirements
- Complex calculations or transformations
- Conditional logic
- Calling external APIs for data
- Cryptographic operations
Tips & Best Practices
1. Remove Quotes for Numbers
Use {{$timestamp}} not "{{$timestamp}}" in JSON for proper number type.
2. Use for Load Testing
Combine with Collection Runner iterations for powerful load tests with unique data.
3. Track with GUIDs
Use {{$guid}} in headers like X-Request-ID for request tracing.
4. Test Validation
Add test scripts to verify dynamic variable formats are correct.
5. Mix with Environment Vars
Combine dynamic variables with environment variables for flexible testing.
6. Check Console
View generated values in console to debug and verify output.