Skip to content

Variables

lex edited this page Jul 23, 2026 · 2 revisions

Variables

Variable Definitions

File-Level @var

Defined before the first ### block separator. Available to all requests.

@base_url = https://api.example.com
@api_key = sk-abc123

The = is optional:

@base_url https://api.example.com

Block-Level @var

Defined between ### and the request line. Overrides file-level variables with the same name.

### Staging
@base_url = https://staging.example.com
GET {{base_url}}/health

Multi-Line @var (=>>> / <<<)

@headers_block =>>>
Content-Type: application/json
Authorization: Bearer {{token}}
X-Custom: value
<<<

The =>> delimiter starts the block, <<< ends it. Newlines are preserved.

Quoted Values

@name = "John Doe"
@greeting = 'Hello World'

Quotes are stripped during resolution.

Variable References

Standard Reference

GET {{base_url}}/users/{{user_id}}

Magic Variables

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

Cross-Request References

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}}

Environment Variables

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"
  }
}

Prompt Variables (<<)

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.

Text Input

<<username
<<password

Shows vim.ui.input() prompt. The resolved value replaces the << line as @varname = value.

Selection from List

<<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]

Dynamic Options from Prior Response

<<item_id [{{ListItems.response.body.items}}]

With jq-style mapping:

<<item_id [{{ListItems.response.body | {name: .name, key: .id, desc: .description} }}]

Reference from @var

@options = [a, b, c]
<<choice {{options}}

Commented-Out Prompt

# <<auth_token

The prompt is skipped.

Variable Resolution Priority

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).

Variable Namespace

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.

Clone this wiki locally