Request Chaining
Last updated: December 18, 2025
Request Chaining
Execute requests in sequence with automatic dependency resolution and variable extraction.
Overview
Request chaining allows you to:
- Define dependencies between requests
- Automatically extract values from responses
- Pass extracted values to dependent requests
- Execute requests in the correct order
Annotations
@depends
Specify files this request depends on. Dependencies execute first.
# @depends login.http
# @depends chain/setup.http
GET https://api.example.com/user/profile
Multiple dependencies can be listed (space-separated):
# @depends login.http setup.http
Or use multiple @depends lines:
# @depends login.http
# @depends setup.http
@extract
Extract values from response body using JMESPath and store in session variables.
# @extract token access_token
# @extract userId user.id
POST https://api.example.com/auth/login
Format: @extract <varName> <jmesPath>
varName: Variable name to store the extracted valuejmesPath: JMESPath expression to extract the value from JSON response
Basic Example
Step 1: Login Request
chain/login.http:
### Login to API
# @extract token access_token
# @extract userId user.id
POST https://api.example.com/auth/login
Content-Type: application/json
{
"username": "[email protected]",
"password": "secret"
}
Response:
{
"access_token": "eyJhbGc...",
"user": {
"id": 123,
"name": "John Doe"
}
}
Variables extracted:
token= “eyJhbGc…”userId= 123
Step 2: Dependent Request
chain/get-profile.http:
### Get User Profile
# @depends chain/login.http
GET https://api.example.com/users/{{userId}}
Authorization: Bearer {{token}}
This request:
- Waits for
chain/login.httpto execute - Uses extracted
tokenanduserIdvariables - Executes with resolved values
Execution Flow
When you execute a request with dependencies:
- Graph Building: System builds a dependency graph
- Topological Sort: Determines execution order
- Sequential Execution: Executes requests in dependency order
- Variable Extraction: After each request, extracts variables using
@extract - Session Storage: Stores extracted variables in session
- Variable Resolution: Subsequent requests use extracted variables
Multi-Level Dependencies
Chains can have multiple levels:
chain/setup.http:
### Setup API
# @extract apiKey key
POST https://api.example.com/setup
chain/login.http:
### Login
# @depends chain/setup.http
# @extract token access_token
POST https://api.example.com/auth/login
X-API-Key: {{apiKey}}
chain/get-data.http:
### Get Data
# @depends chain/login.http
GET https://api.example.com/data
Authorization: Bearer {{token}}
X-API-Key: {{apiKey}}
Execution order: setup.http → login.http → get-data.http
JMESPath Extraction Examples
Simple Field
# @extract userId id
Response: {"id": 123} → userId = 123
Nested Field
# @extract token user.credentials.access_token
Response:
{
"user": {
"credentials": {
"access_token": "abc123"
}
}
}
Result: token = "abc123"
Array Element
# @extract firstId items[0].id
Response: {"items": [{"id": 1}, {"id": 2}]} → firstId = 1
Complex Query
# @extract adminIds users[?role=='admin'].id
Response:
{
"users": [
{"id": 1, "role": "admin"},
{"id": 2, "role": "user"},
{"id": 3, "role": "admin"}
]
}
Result: adminIds = [1, 3] (as JSON array string)
TUI Usage
Execute Chain
- Select a file with
@dependsannotation - Press
Enterto execute - System automatically:
- Detects dependencies
- Builds execution graph
- Executes chain in order
- Shows progress: “Executing chain: N requests”
Chain Progress
Status bar shows:
Executing chain: 3 requests- during executionChain completed: 3 requests executed- on successRequest 2/3 (login.http) failed: ...- on failure
Final Response
After chain completion:
- Response panel shows the final request’s response (the one you selected)
- All intermediate responses execute silently
- Extracted variables available in session
View Extracted Variables
Press v to open variable editor and see extracted values in the session variables section.
Error Handling
Dependency Parse Error
Failed to parse dependency chain/login.http: invalid syntax
Fix the syntax error in the dependency file.
Variable Extraction Error
Failed to extract variables from login.http: response is not valid JSON
Ensure response is valid JSON when using @extract.
Circular Dependency
Circular dependency detected: profile.http depends on itself
Remove circular reference from @depends annotations.
Missing Dependency
Failed to parse start file chain/missing.http: no such file
Ensure all files in @depends exist.
Path Resolution
Dependency paths are resolved relative to the profile’s workdir:
{
"profiles": [
{
"name": "dev",
"workdir": "/Users/you/project/requests"
}
]
}
If workdir is /Users/you/project/requests:
@depends login.http→/Users/you/project/requests/login.http@depends chain/setup.http→/Users/you/project/requests/chain/setup.http
Absolute paths work too:
@depends /path/to/other/request.http
Limitations
- Single Request Per File: Only first request in each file is used for chaining
- JSON Only: Variable extraction requires JSON responses
- No Parallel Execution: Dependencies execute sequentially
- No Conditional Chains: All dependencies always execute
- Session Scope: Extracted variables stored in session (cleared on profile switch)
Best Practices
-
Organize Chain Files: Use subdirectory for chain requests (
chain/,workflows/) -
Descriptive Names: Name files clearly (
login.http,create-user.http) -
Document Extractions: Comment what each extraction does
### Login # Extract access token for subsequent requests # @extract token access_token # Extract user ID for profile lookup # @extract userId user.id -
Minimal Dependencies: Only depend on what’s needed
-
Error Responses: Handle authentication failures gracefully
-
Categories: Tag chain files for filtering
# @category chain # @category auth
Advanced Example: User Creation Workflow
chain/admin-login.http:
### Admin Login
# @extract adminToken access_token
POST https://api.example.com/admin/login
Content-Type: application/json
{
"username": "admin",
"password": "{{adminPassword}}"
}
chain/create-user.http:
### Create User
# @depends chain/admin-login.http
# @extract newUserId id
POST https://api.example.com/users
Authorization: Bearer {{adminToken}}
Content-Type: application/json
{
"email": "{{userEmail}}",
"name": "{{userName}}"
}
chain/send-welcome.http:
### Send Welcome Email
# @depends chain/create-user.http
POST https://api.example.com/emails/welcome
Authorization: Bearer {{adminToken}}
Content-Type: application/json
{
"userId": {{newUserId}},
"template": "welcome"
}
Execute send-welcome.http:
- Admin login executes → extracts
adminToken - Create user executes → uses
adminToken, extractsnewUserId - Send welcome executes → uses both
adminTokenandnewUserId