CLI
The rq CLI is the command-line interface for working with .rq files. It lets you discover and run requests, inspect environments and authentication configurations, and is the main way to integrate rq into scripts and CI.
If you haven’t installed rq yet, see the INSTALLATION guide first.
At a high level:
rqwithout subcommands runs a request (request run).rq requestmanages requests (list, show, run).rq envlists and inspects environments found in.rqfiles.rq authlists and inspects auth providers.rq checkvalidates.rqfiles without executing requests.
All subcommands accept a global -d, --debug flag that writes a diagnostic trace to stderr (see Debug logging).
Debug logging
Every command accepts -d, --debug. It writes a trace to stderr, in the style of curl -v, while stdout keeps the normal output. Each line starts with the time elapsed since rq started:
[ 5ms] * rq 0.7.0 (macos aarch64)
[ 6ms] * Command: rq request run -s api -e local -v token=***
[ 6ms] * Working directory: /Users/ana/project
[ 6ms] * Source: api (directory)
[ 7ms] * Found 3 .rq file(s) in api
[ 20ms] * Parsed /Users/ana/project/api/users.rq (imports: /Users/ana/project/api/_shared.rq)
[ 21ms] * Environment 'local' for /Users/ana/project/api/users.rq: base_url, api_key
[ 21ms] * Secrets from api/.env: api_key
[ 21ms] * Secrets from RQ__ environment variables: none
[ 22ms] * Running 1 request(s) from /Users/ana/project/api/users.rq
[ 22ms] * Variable base_url from env:local
[ 22ms] * Variable token from cli
[ 23ms] * Applying auth 'tok' (bearer)
[ 23ms] > POST http://localhost:8080/users
[ 23ms] > authorization: ***
[ 29ms] < 201 Created (6 ms)
[ 29ms] < content-type: application/json
[ 30ms] * Finished with exit code 0
- Lines starting with
*describe what rq is doing: which files it found and parsed, which environment and secret sources it used, where each variable used by a request comes from (cli,request,endpoint,secret,env:<name>orlet), OAuth2 token requests, and thechecksummary. - Lines starting with
>show the request exactly as it is sent, after variables and auth are resolved, and lines starting with<show the response status and headers. - The last line reports the exit code and, when the command fails, the error.
Secret values never appear in the trace. Secrets and variables are listed by name, -v values in the command line are shown as NAME=***, header values whose name contains authorization, cookie, token, secret, key or password are masked, and so are body fields whose key contains a secret marker.
Reporting a bug
Run the failing command again with -d and save the trace to a file:
rq request run -s api -e local -d 2> rq-debug.log
Attach rq-debug.log to the issue. It already includes the rq version, the platform and the exact command. Secret values are masked, but review the file before sharing it, since URLs, file paths and non-secret values are kept as they are.
Global usage
rq [OPTIONS] [COMMAND]
Commands:
env– Manage environments.auth– Manage authentication.request– Manage requests.check– Validate.rqfiles.
If you call rq without a subcommand, it behaves like rq request run with the same arguments.
Global options:
-d, --debug– Enable debug logging.-V, --version– Print CLI version.-h, --help– Show help.
Unless otherwise noted, most commands share these common flags:
-s, --source <SOURCE>– Path to a.rqfile or directory (defaults to current directory).-f, --format <FORMAT>– Output format:textorjson(defaults totext, case-insensitive).
Which files rq reads
When --source is a directory, rq looks for .rq files in it and in every subdirectory except hidden ones (any name starting with ., such as .git or .venv). A hidden directory given as the source itself is still read. Other files are only read when a request asks for them, for example through io.read_file.
To skip more directories or .rq files, list them in a .rqignore file in the source directory, or in the file’s own directory when --source is a file. rq reads only that .rqignore, not those of parent folders or subfolders, so a different source needs its own:
# one entry per line; blank lines and lines starting with # are ignored
node_modules
target
fixtures/large
scratch.rq
!.config
- A bare name, such as
node_modulesorscratch.rq, skips every directory or.rqfile with that name at any depth. - A path with a
/, such asfixtures/largeorapi/old.rq, skips only that directory or file, relative to the source. - A leading
/, as in/target, skips only the entry of that name at the root of the source. **/at the start and/**at the end are accepted, so**/node_modules,node_modules/**and**/fixtures/large(that path at any depth) work as in a.gitignore.- Wildcards such as
*.egg-infoorbuild*are not supported; rq ignores those lines and says so in the debug log (-d). !namereads a hidden directory that would otherwise be skipped.
.rqignore only decides where rq looks for .rq files. A file a request names by path is always read, even inside an ignored folder: an import, io.read_file or io.read_json. So a data folder full of JSON bodies can go in .rqignore to keep the search fast, and requests still read the bodies they use.
To keep a wrong source, such as your home directory, from hanging, rq stops after 50,000 files and directories. The error names the largest folders it found so you can add them to .rqignore, or point --source at the folder that holds your .rq files.
The VS Code extension and the MCP server read files the same way, with the .rqignore of the opened folder.
Managing requests: rq request
The request subcommand lets you list, inspect, and run requests defined in .rq files.
rq request [OPTIONS] <COMMAND>
Commands:
list– List requests.show– Show request details.run– Run a request.
rq request list
List all requests discovered under a file or directory.
rq request list [OPTIONS]
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-f, --format <FORMAT>– Output format:textorjson(default:text).
Behavior:
- In
textmode, printsRequests found:followed by request names (for example- basic,- users/list), orNo requests found. - In
jsonmode, prints a JSON array of objects with a singlenamefield (for example{"name": "users/list"}). Userq request showfor the details of a request.
Example:
rq request list -s tests/request/run/input
rq request list -s tests/request/run/input -f json
rq request show
Show detailed information about a single request.
rq request show [OPTIONS]
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-n, --name <NAME>– Name of the request to show (required). If the request is defined inside an endpoint, use<endpoint>/<request>or<endpoint>.<request>(for exampleusers/listorusers.list).-e, --env <ENVIRONMENT>– Environment name to resolve variables and env-specific settings.--no-var-interpolation– Skip variable interpolation and show raw values.-f, --format <FORMAT>– Output format:textorjson(default:text).
Behavior:
- Resolves the specified request (including endpoint context if applicable).
- In
textmode, printsname,method,url,headers, the optionalbody,timeoutandauth(asname (type)), andlocationasfile:line:column. - In
jsonmode, prints the same fields as an object:name,method,url,headers, optionalbody,timeoutandauth({"name", "type"}), plusfile,lineandcolumn.
Example:
rq request show -s tests/request/run/input -n basic
rq request show -s tests/request/run/input -n basic -e local -f json
rq request run
Run one or more requests from .rq files.
rq request run [OPTIONS]
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-n, --name <NAME>– Name of the request to run. If omitted, every request in the source runs. If the request is defined inside an endpoint, use<endpoint>/<request>or<endpoint>.<request>(for exampleusers/listorusers.list).-e, --env <ENVIRONMENT>– Environment name.-v, --variable <NAME=VALUE>– Override variables at runtime (can be provided multiple times).-f, --format <FORMAT>– Output format:textorjson(default:text).-p, --print <PARTS>– Response parts to print, as any combination ofm(meta: request name, method, URL, status and elapsed time),h(response headers) andb(response body). Letters combine in a single value, in any order:-p hbprints the headers and the body,-p mhbprints everything. Defaults tomb. The same parts are printed intextandjsonmode.--no-lint– Skip the lint summary printed before running.
Behavior:
- Before running, lints the source with the same lint rules as
rq check. When any rule fires it prints a single line to stderr, such asWarning: 2 lint warnings found, run \rq check -s api.rq` for details(injsonmode, a{“warning”: {…}}object). When–sourceis a file, only that file is linted, so cross-file rules are left torq check`; when it is a directory, every file in it is linted against the others. Lint findings never change the exit code or stdout, and a lint failure never stops the run. - Uses the same variable precedence described in the language definition, with
-v NAME=VALUEproviding the highest-precedence overrides. -
In
textmode, prints one block per request: a line with the request name, method and URL, a status line with the reason phrase and elapsed time, and the response body. JSON bodies are indented without reordering their keys.-ppicks which of these sections to print;hadds the response headers, onename: valueper line sorted by name, between the status line and the body. Request headers are shown only with-d:basic GET http://localhost:8080/get 200 OK · 5 ms { "status": "ok" } - In
jsonmode, prints aresultsarray with one object per request, holding only the fields of the selected parts:request_name,method,url,statusandelapsed_msform;response_headersforh;bodyforb. Request headers are not part of the output in either mode; use-dto see them. -p bprints only the response body, so the output can be piped straight into tools such asjq.
Examples:
# Run a single request in a file
rq request run -s tests/request/run/input/basic.rq -n basic
# Print only the response headers
rq request run -s tests/request/run/input/basic.rq -p h
# Print the meta, the response headers and the body
rq request run -s tests/request/run/input/basic.rq -p mhb
# Run using an environment and a CLI variable override
rq request run -s tests/request/run/fixtures/cli_override/override.rq -e local -v color=red
# Default invocation (same as `rq request run`)
rq -s tests/request/run/input/basic.rq -n basic
Error handling:
- If
--sourcepoints to a non-existent path, the command exits with code2and printsPath does not exist. - If a variable override does not follow
NAME=VALUE, or the variable name is invalid, the command fails with clear validation messages.
Required variables
If a request declares one or more [required(var_name)] attributes (see Language Definition — required attribute), the CLI validates that every required variable has been supplied at runtime via -v before sending the request. let bindings, environment blocks, and secrets do not satisfy a required declaration.
If one or more required variables are missing, the CLI exits with code 3 and prints:
Error: Validation error: Required variable(s) not set: var_name
To supply the missing values, pass them with -v:
rq request run -s api.rq -n users/create -v user_name=Alice -v user_role=admin
Managing environments: rq env
The env subcommand helps you discover available environments in your .rq files.
rq env [OPTIONS] <COMMAND>
Commands:
list– List environments.
rq env list
List environment names defined across .rq files.
rq env list [OPTIONS]
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-f, --format <FORMAT>– Output format:textorjson(default:text).
Behavior:
- Recursively scans the given path for
.rqfiles and collects all environment names (fromenv <name> { ... }blocks). - In
textmode, prints a short list prefixed withEnvironments found:or a message likeNo environments foundfor empty results. - In
jsonmode, prints a JSON array of objects with a singlenamefield.
Examples:
rq env list -s tests/env/list/input/simple.rq
rq env list -s tests/env/list/input -f json
# Using the current directory as source
cd tests/request/run/input
rq env list
Error handling:
- A non-existent
--sourcepath causes the command to exit with code2and an error mentioningPath does not exist.
Managing auth providers: rq auth
The auth subcommand lets you list and inspect authentication configurations declared in your .rq files.
rq auth [OPTIONS] <COMMAND>
Commands:
list– List auth configurations.show– Show details for a specific auth configuration.
All rq auth commands accept -d, --debug.
rq auth list
List all auth providers defined across .rq files.
rq auth list [OPTIONS]
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-f, --format <FORMAT>– Output format:textorjson(default:text).
Behavior:
- In
textmode, printsAuth configurations found:followed by provider names (for example- bearer_auth), orNo auth configurations found. - In
jsonmode, prints a JSON array of objects with a singlenamefield. Userq auth showfor the type and fields of a provider. - For empty directories, prints
No auth configurations found.
Examples:
rq auth list -s tests/request/run/input
rq auth list -s tests/request/run/input -f json
rq auth show
Show the full configuration of a single auth provider.
rq auth show [OPTIONS] --name <NAME>
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-n, --name <NAME>– Name of the auth configuration (required).-e, --env <ENVIRONMENT>– Environment name to resolve environment-specific overrides for that auth provider.-f, --format <FORMAT>– Output format:textorjson(default:text).
Behavior:
- Resolves the auth provider (e.g.
bearer_auth,github_oauth) and shows its type and fields. - In
textmode, prints a human-readable summary like:name: bearer_authtype: bearertoken: ...
- In
jsonmode, prints an object with keys:name– Provider name.type– Provider type (bearer,oauth2_authorization_code, etc.).environment– Optional, when-e/--envis provided.fields– Map of field names to values (for exampleclient_id,authorization_url,token_url).file,line,column– Where the provider is declared.
Examples:
rq auth show -s tests/request/run/input -n bearer_auth
rq auth show -s tests/request/run/input -n github_oauth -f json
rq auth show -s tests/request/run/input -n local_auth -e local
Error handling:
- If the named auth provider does not exist, the command fails with an error mentioning that the auth configuration was not found.
Validating files: rq check
Parse and validate .rq files without executing any requests, and run the lint rules over them. Errors fail the check; lint findings are reported as warnings.
rq check [OPTIONS]
Options:
-s, --source <SOURCE>– Path to the.rqfile or directory (default:.).-e, --env <ENVIRONMENT>– Environment name to use for variable resolution.-f, --format <FORMAT>– Output format:text(default) orjson.--deny-warnings– Exit with code1when lint reports any warning.
Behavior:
- In
textmode, prints one line per error asfile:line:column: message, then one line per warning asfile:line:column: warning[rule]: messagefollowed by an indentedhelp:line when the rule suggests a fix. It ends with the error and warning counts, orNo errors found. - In
jsonmode, outputs anerrorsarray and awarningsarray. Each error containsmessageand, when known,file,lineandcolumn. Each warning containsfile,line,column,rule,messageand, when the rule has one,suggested_fix. - Errors that are not tied to a position (for example, a file that cannot be read) are reported with their message only.
- Files that fail to parse are not linted; fix their errors first.
- Cross-file rules see every
.rqfile under the source directory, or under the file’s own directory when--sourceis a file. - Exits with code
1if any errors are found, or if any warnings are found with--deny-warnings; exits with code0otherwise.
Example:
rq check -s src/
rq check -s src/api.rq -e local
rq check -s src/ -f json
rq check -s src/ --deny-warnings
Example output (text):
src/api.rq:5:3: unexpected token
src/users.rq:2:13: warning[empty_url_string]: Request `list` passes an empty URL string. ...
help: Replace `rq list("")` with `rq list()`.
1 error, 1 warning found
Example output (json, no findings):
{
"errors": [],
"warnings": []
}
Example output (json, with errors and warnings):
{
"errors": [
{
"file": "src/api.rq",
"line": 5,
"column": 3,
"message": "unexpected token"
}
],
"warnings": [
{
"file": "src/users.rq",
"line": 2,
"column": 13,
"rule": "empty_url_string",
"message": "Request `list` passes an empty URL string. ...",
"suggested_fix": "Replace `rq list(\"\")` with `rq list()`."
}
]
}
Output formats
Across all commands, the -f, --format flag controls how results are printed:
text– Human-readable, stable but meant for terminals.json– Machine-readable, designed for scripting and automated checks.
The value is case-insensitive, so --format json and --format JSON are equivalent. Invalid values cause a clear clap error indicating the allowed values.
When integrating rq into other tools or CI, prefer --format json so you can parse responses reliably.
JSON conventions
Every command follows the same rules in json mode:
- Keys are
snake_case. listcommands return only names, as an array of{"name": ...}objects;showcommands return the full detail of one item. Both output modes carry the same content.- Source locations are reported as
file,lineandcolumn.fileis an absolute path, andlineandcolumnstart at 1, sofile:line:columnpoints at the same place an editor shows. - Optional fields are omitted when they have no value, instead of being printed as
null. - Results go to stdout and always end with a newline.
- Errors go to stderr as
{"error": {"type": ..., "message": ..., "file": ..., "line": ..., "column": ...}}, where the location fields are present only when known. - Warnings that do not stop the command (for example, a file that fails to parse while listing a directory) go to stderr with the same shape under a
warningkey.