Variable Capture
Variable Capture
Section titled “Variable Capture”The @capture directive extracts values from responses and stores them as variables for use in subsequent requests.
Basic Syntax
Section titled “Basic Syntax”@capture variableName = body.path.to.valueExample
Section titled “Example”@name LoginPOST {{baseUrl}}/auth/loginContent-Type: application/json
{ "email": "{{email}}", "password": "{{password}}"}
@capture token = body.access_tokenAfter this request executes, {{token}} is available in any subsequent request.
Scopes
Section titled “Scopes”By default, captured variables are stored in the session scope. You can specify a different scope with a prefix:
| Scope | Syntax | Persistence |
|---|---|---|
| Session (default) | @capture token = body.token | Current session only |
| Collection | @capture collection.token = body.token | Shared across the collection |
| Environment | @capture env.token = body.token | Saved to the active environment |
| Global | @capture global.token = body.token | Available everywhere |
Example with Scopes
Section titled “Example with Scopes”@name LoginPOST {{baseUrl}}/auth/login
@capture token = body.access_token@capture env.userId = body.user.id@capture collection.refreshToken = body.refresh_token@capture global.apiVersion = body.versionLiteral Values
Section titled “Literal Values”You can also capture literal values (strings, numbers, booleans):
@capture session.status = "active"@capture session.count = 42@capture session.flag = trueCapture Paths
Section titled “Capture Paths”The path supports dot notation to traverse the response body:
{ "user": { "id": 123, "profile": { "name": "John" } }}@capture userId = body.user.id@capture userName = body.user.profile.nameNext Steps
Section titled “Next Steps”- Learn about pre-request chains to build request flows
- Explore assertions for response validation