Variables Reference
Complete reference for all variable features in Nidra.
Variable Syntax
Variables use double curly brace syntax:
{{variableName}}
Variable Scopes
Listed by precedence (highest to lowest):
| Scope | Description | Use Case |
|---|---|---|
| Request | Local to single request | Request-specific overrides |
| Conduit | During conduit execution | Extracted/temporary values |
| Collection | Scoped to collection | Collection-wide settings |
| Environment | Environment-specific | URLs, credentials by env |
| Global | Application-wide | App defaults |
Dynamic Variables
Built-in variables that generate values:
| Variable | Description | Example Output |
|---|---|---|
{{$timestamp}} | Current Unix timestamp | 1678098234 |
{{$isoTimestamp}} | ISO 8601 timestamp | 2024-03-06T10:30:34.000Z |
{{$randomInt}} | Random integer (0-1000) | 742 |
{{$randomUUID}} | Random UUID v4 | a3bb189e-8bf9-3888-9912-ace4e6543002 |
{{$randomEmail}} | Random email address | user742@example.com |
{{$randomString}} | Random alphanumeric string | a7b3f9d2 |
{{$randomBoolean}} | Random boolean | true or false |
Variable References
Variables can reference other variables:
domain: example.com
apiUrl: https://api.{{domain}}
authUrl: https://auth.{{domain}}
Resolution happens at request time.
Environment Variables
Defined in environment configurations:
Development:
baseUrl: https://dev-api.example.com
apiKey: dev_key_123
Production:
baseUrl: https://api.example.com
apiKey: prod_key_xyz
Collection Variables
Defined in collection settings:
apiVersion: v2
timeout: 5000
defaultLimit: 100
Extracted Variables
Set during conduit execution from responses:
Extract from response:
data.userId → {{userId}}
token → {{accessToken}}
Variable Type Handling
Strings
"email": "{{userEmail}}"
Outputs: "email": "user@example.com"
Numbers
"count": {{itemCount}}
Outputs: "count": 42 (no quotes)
Booleans
"active": {{isActive}}
Outputs: "active": true (no quotes)
Null
"optional": {{nullValue}}
Outputs: "optional": null
Special Cases
Variable Not Found
If variable doesn't exist:
{{undefinedVar}}
Outputs: {{undefinedVar}} (literal string)
Empty Variable
If variable exists but is empty:
{{emptyVar}}
Outputs: `` (empty string)
Reserved Characters
If variable contains special characters, values are used as-is.
Usage Locations
Variables can be used in:
- Request URLs
- Query parameters
- Headers
- Request body (JSON, XML, text)
- Authentication configurations
- Assertions
- Environment values (chained)
- Conduit step configurations
Best Practices
- Use descriptive names:
userIdnotid1 - Follow naming convention: camelCase or snake_case
- Don't expose secrets in global scope
- Document variables in environments
- Use parent environments to reduce duplication
Limitations
- Variable names are case-sensitive
- Cannot use variables in variable names
- Circular references are not supported
- Maximum variable value length: (check docs)