-
Notifications
You must be signed in to change notification settings - Fork 0
Variables
Defined before the first ### block separator. Available to all requests.
@base_url = https://api.example.com
@api_key = sk-abc123The = is optional:
@base_url https://api.example.comDefined between ### and the request line. Overrides file-level variables with the same name.
### Staging
@base_url = https://staging.example.com
GET {{base_url}}/health@headers_block =>>>
Content-Type: application/json
Authorization: Bearer {{token}}
X-Custom: value
<<<The =>> delimiter starts the block, <<< ends it. Newlines are preserved.
@name = "John Doe"
@greeting = 'Hello World'Quotes are stripped during resolution.
GET {{base_url}}/users/{{user_id}}Built-in dynamic values resolved at runtime:
| Syntax | Description |
|---|---|
{{$timestamp}} |
Current Unix timestamp (seconds since epoch) |
{{$uuid}} |
Random UUID v4 string |
{{$date}} |
Current date in ISO 8601 format |
{{$randomInt}} |
Random integer between 0 and 2^31-1 |
Reference values from prior responses:
{{RequestName.response.body.field}}
{{RequestName.response.headers.Header-Name}}
{{RequestName.request.body.field}}
{{RequestName.request.headers.Header-Name}}Examples:
### Login
POST https://api.example.com/auth
Content-Type: application/json
{"username": "admin", "password": "secret"}
### Get Profile
GET https://api.example.com/profile
Authorization: Bearer {{Login.response.body.token}}
### Get Resource
GET https://api.example.com/items/{{Login.response.body.user.id}}Variables from env.json files:
GET {{base_url}}/api/{{endpoint}}Where env.json contains:
{
"dev": {
"base_url": "https://dev.example.com",
"endpoint": "users"
},
"prod": {
"base_url": "https://example.com",
"endpoint": "api/v2/users"
}
}Interactive prompts that show a picker or text input at request time. Placed inside a request block (between ### and the request line). Resolved to block-level @var definitions — they are request-scoped, not file-level.
<<username
<<passwordShows vim.ui.input() prompt. The resolved value replaces the << line as @varname = value.
<<method [GET, POST, PUT, DELETE]
<<format [json|JSON, xml|XML, plain|Plain Text]Shows a picker. The first element is the value, the second is the display label:
<<method [GET|GET Request, POST|Create, PUT|Update, DELETE|Remove]<<item_id [{{ListItems.response.body.items}}]With jq-style mapping:
<<item_id [{{ListItems.response.body | {name: .name, key: .id, desc: .description} }}]@options = [a, b, c]
<<choice {{options}}# <<auth_tokenThe prompt is skipped.
| Priority | Source | Description |
|---|---|---|
| 1 (highest) | Import overrides | run #Login (@timeout=30) |
| 2 | Block-level @var | Between ### and request line |
| 3 | File-level @var | Before first ###
|
| 4 | Session variables | client.global.set('k','v') |
| 5 | Script variables | request.variables.set('k','v') |
| 6 | Environment variables |
env.json → {{key}}
|
| 7 (lowest) | Magic variables |
$timestamp, $uuid, $date, $randomInt
|
Chained references (@a = {{b}}, @b = value) are resolved iteratively (up to 20 passes).
Cross-request references use a dotted path syntax:
RequestName.response.body.field.subfield
RequestName.response.headers.Header-Name
RequestName.request.body.field
RequestName.request.headers.Header-Name
The RequestName matches the name after ### in the target request block.