.http Request Files
Recon stores saved requests as plain-text .http files in your workspace’s collections_dir. One file can hold many requests. You write them by hand, the web UI writes them when you save, and recon import --save generates them. This page describes exactly what the parser accepts.
Example
Section titled “Example”This is the first request in the file that recon init --demo writes to collections/campus-demo.http:
### List Students (PII Airlock + Twin-Run Drift Demo)# @name List Students# @folder Campus SIS# @assert status == 200# @assert jsonpath $.students[0].program == MDivGET {{base_url}}/v1/studentsAuthorization: Bearer {{DEV_API_TOKEN}}A request with a JSON body:
### Create Enrollment# @name Create Enrollment# @folder Campus SIS# @assert status == 201POST {{base_url}}/v1/enrollmentsContent-Type: application/jsonAuthorization: Bearer {{DEV_API_TOKEN}}
{ "student_id": "001001", "course": "CS-401"}You run saved requests by ID or by name with recon send, recon test and other commands. See Send & Test.
File structure
Section titled “File structure”Recon loads every file with the .http extension under collections_dir, including subdirectories, in sorted path order. Other extensions (including .rest) are not loaded. Windows line endings are accepted.
Each file is split into blocks:
- A line whose trimmed text starts with
###ends the current block and starts a new one. Text after the###is the block’s heading. A bare###has no heading. - Lines before the first
###form a block too, so a file with a single request needs no separator. - Inside a block, Recon skips blank lines, comment lines (starting with
#or//) and file variable lines (@name = value) until it reaches the first other line. That line is the request line. - Lines after the request line, up to the first blank line, are headers.
- Everything after that blank line, up to the next
###, is the body.
A block with no request line (only comments, for example) is skipped without an error.
Request line
Section titled “Request line”METHOD URLThe request line is split on whitespace. The first token is the method and the second is the URL. Anything after the URL (such as HTTP/1.1) is ignored.
- The method is case-insensitive and is stored in upper case.
GET,POST,PUT,PATCH,DELETE,HEADandOPTIONSare known; any other token is kept as a custom method, sopurge https://example.com/xsendsPURGE. - A method is required. A line holding only a URL fails with
missing URL after method `https://example.com/x`. - The URL cannot contain spaces. This also applies to template placeholders:
GET {{ base_url }}/usersis cut at the first space. Write{{base_url}}on the request line.
Query parameters in the URL are split out and stored separately:
- If the URL contains
{{, the part after the first?is split on&, and each pair on its first=. A key without=gets an empty value. Values are kept as written. - Otherwise the URL is parsed as an absolute URL. Query values are percent-decoded, and the URL is normalised (for example
https://example.combecomeshttps://example.com/). If parsing fails, the URL is kept as written with no query split.
Headers
Section titled “Headers”Each header line is split at its first :. The name and value are trimmed. Header lines that start with # or // are skipped. A line without : ends the headers and starts the body, even without a blank line. A body line that contains : and is not preceded by a blank line is read as a header, so always put a blank line before the body.
The body is every remaining line in the block, joined and trimmed. Comment lines in the body are kept as body text. Recon decides the body kind like this:
- If a
Content-Typeheader containsjson, or the body starts with{or[, the body is JSON. - Otherwise it is text.
The JSON is not validated when the file is parsed.
When the request is sent and has no Content-Type header, Recon adds one: application/json for JSON bodies and text/plain; charset=utf-8 for text bodies.
The parser only produces JSON and text bodies. URL-encoded forms, multipart bodies and raw binary bodies can exist in memory (from importers or the web UI), and they are written to .http files as described in How files are written back, but they come back as text bodies the next time the file is loaded.
Names and IDs
Section titled “Names and IDs”A request’s display name is the first of:
- the
# @namedirective, - the
###heading text, METHOD URL, using the URL without its query string (for exampleGET https://example.com/first).
Its ID is <file stem>-<slug>, where the slug is the name lower-cased, with every run of non-alphanumeric characters turned into one - and leading or trailing dashes removed. collections/campus-demo.http with the name List Students gives campus-demo-list-students. If the slug is empty, the ID is <file stem>-<index>.
Commands that take a request accept either the exact ID or the name, compared case-insensitively. The first match wins. Only the file stem is used, so files with the same name in different subdirectories can produce the same IDs. Subdirectories do not set a folder; use # @folder.
Directives
Section titled “Directives”Directives are comment lines of the form # @directive value or // @directive value placed before the request line. Directives after the request line are not read. Unknown directives are ignored. Except for the bare forms listed, a directive needs a space before its value.
| Directive | Value | Effect |
|---|---|---|
@name |
text | Display name. |
@folder |
text, for example Campus SIS or A/B |
Folder shown in the web UI sidebar. |
@handler |
path:line, for example src/routes.rs:42 |
Source location for Jump-to-Handler. An empty value is ignored. See Code Scanning. |
@auth |
JSON object | Structured authentication. See @auth JSON. The last @auth line wins. An invalid value fails the file. |
@pre-script |
one line of Rhai, or nothing | Appends one line to the pre-request script. Bare # @pre-script adds an empty line. |
@post-script |
one line of Rhai, or nothing | Appends one line to the post-response script. |
@assert |
an assertion rule | Adds an assertion. See Assertions. An unrecognised rule fails the file. |
@taint-scope |
comma-separated host patterns | Adds hosts allowed to receive secrets in this request. Repeatable. |
@timeout |
milliseconds, with an optional ms suffix |
Request timeout. Default 15000. A value that is not a whole number is ignored silently. Values below 100 are raised to 100 ms when the request is sent. |
@no-redirect |
none | Do not follow 3xx redirects. Redirects are followed by default. |
Script lines are joined with newlines in file order. What scripts can do is covered in Pre/Post Scripting.
@taint-scope patterns apply to every secret in the request that has an empty allowed_hosts list, and to every {{$env.NAME}} value. See Outbound Secret Firewall.
@auth JSON
Section titled “@auth JSON”The value is a JSON object with a kind field. Unknown kinds and missing required fields fail the file, for example invalid @auth JSON directive: missing field `location` .
kind |
Required fields | Optional fields (default) |
|---|---|---|
none |
||
bearer |
token |
|
basic |
username, password |
|
api_key |
key, value, location (header or query) |
|
oauth2 |
token_url, client_id |
grant (client_credentials; also authorization_code, refresh_token), auth_url, client_secret, scope, audience, profile, use_pkce (true) |
aws_sigv4 |
access_key_id, secret_access_key, region, service |
session_token |
hmac |
secret |
algorithm (sha256; also sha512), header_name (X-Signature), timestamp_header, payload_template ({timestamp}\n{method}\n{path}\n{body}), encoding (hex; also base64) |
String fields accept {{variables}}.
# @auth {"kind":"bearer","token":"{{API_TOKEN}}"}GET {{base_url}}/meWhen variables are resolved, Recon applies bearer, basic and api_key itself:
beareraddsAuthorization: Bearer <token>unless the request already has anAuthorizationheader.basicaddsAuthorization: Basic <base64(username:password)>unless the request already has anAuthorizationheader.api_keywithlocation: headeradds the header unless a header with that name exists. Withlocation: queryit always appends the key to the query string.
oauth2, aws_sigv4 and hmac are applied later, when the request is sent. See Auth & Request Signing.
File variables
Section titled “File variables”A line of the form @name = value that appears before a block’s request line defines a file variable. It is not a comment, so it has no #.
@api = https://example.com/v2
### ListGET {{api}}/items- File variables replace the exact text
{{name}}in the request line, header values and the body while the file is parsed.{{ name }}with spaces is not replaced by a file variable. - They are not applied to directive values, so
@assertand@authdo not see them. - A file variable stays defined for every later block in the same file, and a later definition with the same name replaces it.
- Because they are applied at parse time, a file variable wins over an environment variable with the same name.
Templates
Section titled “Templates”Recon resolves {{...}} placeholders when it prepares a request to send or export.
Syntax
Section titled “Syntax”A placeholder is {{, optional spaces, a name made of letters, digits, _, ., $, : and -, optional spaces, then }}. {{ token }} and {{token}} are the same placeholder (outside the request line, which cannot hold spaces).
Placeholders are resolved in:
- the URL,
- query parameter values,
- header values,
- string fields of
@auth, - JSON and text bodies, URL-encoded form values, and multipart text parts.
They are not resolved in header names or query parameter names.
Resolution order
Section titled “Resolution order”For each placeholder, Recon uses the first rule that matches:
| Placeholder | Result |
|---|---|
{{$uuid}} |
A new random UUID v4. |
{{$timestamp}} |
Current Unix time in seconds. |
{{$isoTimestamp}} |
Current UTC time in RFC 3339 format. |
{{$env.NAME}} |
The operating system environment variable NAME. If it is unset, the placeholder is left as is. The value is tracked as a secret with the label NAME. |
| any other name | 1. A runtime override: a dataset row value or a value set by a pre-request script (script values replace row values). 2. A variable in the active environment. 3. Otherwise the placeholder is left as is. |
There is no escape syntax. A placeholder that does not resolve is sent literally, and in a query string it is percent-encoded (%7B%7Bmissing%7D%7D). If the URL itself is still a placeholder, the request fails with invalid URL.
Secret environment variables are recorded with the place they were inserted, so the Outbound Secret Firewall can check them and code export can mask them. Secret URIs such as age:// in environment values are resolved before sending; see Vault & Secret URIs.
Assertions
Section titled “Assertions”Each # @assert line adds one check that runs after the response arrives.
| Rule | Passes when |
|---|---|
status == 200 |
The status code equals the number. |
status in 200..299 |
The status is between the two numbers, both included. 200..=299 is accepted too. |
header <name> exists |
A response header with that name exists (name compared case-insensitively). |
header <name> == <value> |
That header exists and its value equals <value> exactly (case-sensitive). |
jsonpath <path> exists |
The body is JSON and the path matches at least one value that is not null. |
jsonpath <path> == <value> |
The body is JSON and the first match equals <value>. See below. |
latency < 500ms |
Total time is below the number of milliseconds (strictly less). The ms suffix is optional. |
body contains <text> |
The decoded body contains <text> (case-sensitive). |
Text after == and after contains is trimmed. For jsonpath ... == <value>, the first matched value is compared two ways and either one passing is enough:
- Recon removes one pair of surrounding double quotes from
<value>, if present, and compares the result with the match’s text. For a JSON string, the text is the string without quotes. For anything else, it is the JSON text, such as3.92,trueornull. - Recon compares the match’s JSON text with
<value>exactly as written.
So jsonpath $.id == 42 and jsonpath $.id == "42" both pass for {"id":"42"}.
recon test expands non-secret placeholders in assertions before it checks them: the header name and value, the JSONPath and expected value, and the body contains text. Only runtime overrides and plain environment variables are used; secrets and $ built-ins are left as is. recon send checks assertions without expanding them.
Each result has three fields: assertion (the rule as text), passed, and detail. A run of every rule against the demo sandbox:
recon --format json test asserts{ "failed": 1, "passed": 0, "results": [ { "assertions": [ { "assertion": "status == 200", "detail": "observed status 200", "passed": true },... { "assertion": "jsonpath $.students[?(@.gpa > 3.8)].student_id == \"001001\"", "detail": "observed `001001`", "passed": true }, { "assertion": "jsonpath $.missing exists", "detail": "0 match(es)", "passed": false }, { "assertion": "latency < 2000ms", "detail": "observed 7.85ms", "passed": true },...Failure details you can see: observed status <n>, header `<name>` absent, observed `<value>` , response body is not valid JSON, no matching node, <n> match(es), observed <n>ms, substring not found in response body, or a JSONPath syntax error.
JSONPath
Section titled “JSONPath”Recon has its own small JSONPath implementation. It is used by jsonpath assertions, by the JSONPath query in the web UI response viewer (POST /api/v1/jsonpath), and by Flows extraction.
If the expression does not start with $, Recon adds it: .store.name becomes $.store.name, and store.name becomes $.store.name.
| Selector | Example | Matches |
|---|---|---|
| Root | $ |
The whole document. |
| Child | $.store.name |
A named key of an object. |
| Quoted child | $['a.b'], $["a b"] |
A key that contains dots or spaces. |
| Index | $.items[0] |
One array element. Zero-based. |
| Slice | $.items[1:], $.items[:2], $.items[1:3] |
Elements from start (included) to end (excluded). Either bound may be left out. |
| Wildcard | $.items[*], $.store.* |
Every array element, or every object value. |
| Recursive field | $..name |
Every key with that name at any depth, the shallower match first. |
| Filter | $.items[?(@.price > 50)] |
Array elements whose field passes the comparison. |
Filter rules:
- The form is
[?(@.<field> <op> <value>)]with one comparison.<field>can be a dotted path such as@.tags.k, or@for the element itself. - Operators:
==,!=,>=,<=,>,<. ==and!=compare JSON values. The right side is read astrue,false,null, a quoted string (single or double quotes), an integer, a float, or else an unquoted string. A number never equals a string.>,>=,<,<=need a number on both sides; otherwise the element does not match.- An element that does not have the field never matches, even with
!=. - Filters apply to arrays only.
Not supported:
| Expression | What happens |
|---|---|
Negative index [-1] |
Error: invalid array index `-1` |
Index unions [0,1] |
Error: invalid array index `0,1` |
Existence filter [?(@.ok)] |
Error: unsupported filter predicate `@.ok` |
&& or || in a filter |
No error, but nothing matches. |
$..* and $..[0] |
$..* matches nothing (it looks for a key named *); $..[0] is an error: expected field name after `..` |
Slice steps [::2], functions, script expressions |
Not available. |
Each match is returned with a concrete path such as $.store.items[1].id. A quoted key is printed with a dot, so $['a.b'] reports the path $.a.b.
Datasets
Section titled “Datasets”recon test --data <file> runs every selected request once per row of a CSV or JSONL file. Each row’s columns become runtime overrides, so {{column}} resolves to the row value before environment variables are checked.
recon --format human test data --data rows.csv[PASS] Data Driven [row 1: mdiv case][PASS] Data Driven [row 2: quoted, "ma"][FAIL] Data Driven [row 3: nope]2 passed, 1 failedWith this rows.csv and a request that asserts body contains {{program}}:
_name,programmdiv case,MDiv"quoted, ""ma""",MA
nope,PhDFormat detection:
.csvis CSV..jsonland.ndjsonare JSONL (extension compared case-insensitively).- For any other extension, the first non-blank line decides: JSONL if it starts with
{, otherwise CSV. - A leading UTF-8 byte order mark is removed.
CSV rules (RFC 4180):
- The first record is the header row. Column names are trimmed. A header with no names is an error.
- Fields are separated by
,. A field that starts with"is quoted; inside it,""is a literal quote, and commas and line breaks are kept. - Records end with
\nor\r\n. Empty lines are skipped. - Every data row must have as many fields as the header.
- Values are kept exactly as written, including spaces.
JSONL rules:
- One JSON object per line. Blank lines are skipped.
- Strings are used as is, numbers and booleans as their JSON text,
nullas an empty string, and arrays or objects as compact JSON text.
Row labels: if a row has a non-empty _name, case or label column (checked in that order), that value labels the row in output, JUnit and Markdown reports. Otherwise the row shows only its number. Rows are numbered from 1 in human output and from 0 in the JSON row_index field.
Dataset errors:
| Message | Cause |
|---|---|
parse error in `dataset csv row 2`: expected 2 columns matching header, found 3 |
A row has the wrong number of fields. The row number counts the header as row 1. |
CSV dataset is missing a header row / CSV header row contains no column names |
Empty file or empty header. |
unterminated quoted CSV field |
A quote was opened and never closed. |
parse error in `dataset jsonl line 1`: each JSONL line must be a JSON object |
A line is valid JSON but not an object. |
parse error in `dataset`: dataset contained zero data rows |
Only a header, or only blank lines. |
How files are written back
Section titled “How files are written back”The web UI (when you save, rename, duplicate or delete a request), recon import --save, and code scanning sync rewrite whole .http files. Each request is written in this order:
### <name>and# @name <name># @folder,# @handler,# @auth <json>(only if auth is notnone)- one
# @pre-scriptline per script line, then one# @post-scriptline per script line - one
# @taint-scopeline per pattern # @timeout <n>ms(only if it is not15000),# @no-redirect(only if redirects are off)- one
# @assertline per assertion - the request line, with enabled query parameters appended as
key=value(orkeywhen the value is empty) - enabled headers as
Name: value - a blank line and the body, if any
Requests are separated by a blank line. Body kinds are written as:
| Body kind | Written as |
|---|---|
| JSON or text | The text, with trailing whitespace removed. |
| URL-encoded form | Enabled fields joined as key=value&key=value, without encoding. |
| Multipart | Parts separated by --recon-boundary, each with a Content-Disposition line, an optional Content-Type line, a blank line, and the value. Base64 file parts are written as <binary-base64-omitted>. Ends with --recon-boundary--. |
| Binary (Base64) | The Base64 text. |
Errors
Section titled “Errors”A parse error in any .http file stops every command that loads the workspace. The CLI reports it as E_CLI_RUNTIME and exits with status 2. Errors from directives do not name the file.
| Message | Cause |
|---|---|
parse error in `collections/a.http`: missing URL after method `<token>` |
The request line has one token. |
parse error in `@assert`: unrecognized @assert rule `status is 200` |
The rule matches no form in the table above. |
parse error in `@assert`: invalid status code in `status == abc` |
Also invalid status min, invalid status max, invalid latency threshold (for example latency < 1s). |
parse error in `@auth`: invalid @auth JSON directive: ... |
The @auth value is not valid JSON for a known kind. |
Also available via
Section titled “Also available via”- HTTP API:
GET /api/v1/workspacereturns every parsed request;POST /api/v1/requests/save,DELETE /api/v1/requests/{id},POST /api/v1/requests/{id}/duplicateandPOST /api/v1/requests/{id}/renamerewrite.httpfiles;POST /api/v1/jsonpathwith{"json_text": "...", "expr": "..."}returns{"matches": [...]}. See HTTP API. - MCP:
recon_list_requestsreturns each request’sid,name,folder,method,urlandsource_file. See MCP Tools, Resources & Prompts. - CLI:
recon testandrecon sendread these files; see Send & Test.