docs Request files
Captures
Store values from a response and reuse them in later requests.
@capture <scope> <name> <expression> evaluates after the response arrives and stores the result for reuse.
Captures run in declaration order. A capture can read values produced earlier in the same batch through vars.get, {{= ... }}, or {{name}}. Values are stored only after every capture succeeds, so a failed batch leaves request, file, and global values unchanged.
Expressions can reference:
response.statusCode,response.statusText,response.text()response.headers["header-name"]orresponse.header("Header-Name")for a single-valued headerresponse.json.pathshorthand (equivalent toresponse.json().path)stream.kind(),stream.summary().sentCount,stream.summary().dropped, andstream.events()[0].textfor streaming transcripts (available when the request used@sseor@websocket). A non-zerodroppedvalue means the retained transcript is incomplete.vars.*,env.*,last.*, imported@usemodules, and other RestermScript helpers
Example:
### Seed session
# @name AnalyticsSeedSession
# @capture global-secret analytics.sessionToken = response.json.sessionToken
# @capture file analytics.lastJobId = response.json.jobId
# @capture request analytics.trace = response.header("x-amzn-trace-id")
POST https://httpbin.org/anything/analytics/sessionsTemplate captures such as {{response.json.token}} remain supported and can be used alongside RTS capture expressions.
@capture treats a value with a complete, unquoted {{...}} marker as interpolated text. Otherwise it parses the value as RestermScript. In text mode, surrounding characters such as # and unmatched brackets are literal. In script mode, # starts a comment.
An unquoted marker in a script comment switches the capture to text mode. Resterm warns when the remaining text looks like a function call, but it cannot reliably detect every case. Quote markers mentioned in comments:
# @capture request x response.statusCode # mention "{{token}}"Set # @setting capture.strict true to make capture-path misses fail instead of silently resolving to an empty string.
Do not mix unquoted template markers and RTS call syntax in the same capture expression (for example contains({{name}}, "x")). Use pure RTS (contains(vars.get("name") ?? "", "x")) or a template expression ({{= contains(...) }}).
capture.strict is the canonical key. capture-strict and capture_strict are accepted for compatibility. When multiple aliases are present, precedence is capture.strict > capture-strict > capture_strict.