Skip to main content
hitspec is configured through a hitspec.yaml (or hitspec.yml) file in your project root (hitspec also finds it from a subdirectory of the project; see Config File Search). All settings are optional — hitspec uses sensible defaults when no config file is present.

Creating a Config File

Run hitspec init to generate a starter configuration:
This creates a hitspec.yaml and an example.http file.

Full Configuration Reference


Options Reference

General

Network

Relative cacert, cert and key paths in hitspec.yaml resolve against the directory of the file; a bad or missing file exits with code 3. See TLS, cookies and HTTP options.

Headers

Headers defined in individual requests override config-level headers with the same name.

Output

Execution

verbose: true is applied by hitspec run and means -v. A -v, -vv or -vvv flag wins over it, and --verbose=0 turns it off. The key must be a boolean. noColor: true is applied by hitspec run too: --no-color (or --no-color=false) on the command line wins, then HITSPEC_NO_COLOR, then the file. The NO_COLOR environment variable is also honored and can only turn colors off.

Reporters and outputDir

hitspec run writes one report per entry of reporters. console always goes to stdout. With outputDir set, every other reporter writes a file there, replaced on each run (and on each --watch pass):
  • A relative outputDir is relative to the directory of the config file that sets it, not to the working directory. hitspec creates it before the run when at least one reporter writes a file there.
  • Without outputDir, every reporter writes to stdout, so only one is allowed. reporters: [junit] is the same as -o junit. Listing two or more exits with code 3.
  • An unknown reporter name exits with code 3. Duplicates are ignored. An empty list means ["console"].
  • -o/--output or --output-file on the command line, or a non-empty HITSPEC_OUTPUT or HITSPEC_OUTPUT_FILE, replace both keys: they are not read at all.
  • --quiet drops the report on stdout. The files are still written.
  • When no report goes to stdout (for example reporters: [junit] with outputDir: reports), the failed requests are listed on stderr, as with --quiet.
  • --stress and --dry-run ignore both keys.

Environments

Define per-environment variables inline:
Select the active environment with --env:
Variables defined in the active environment are available via {{variableName}} interpolation in your test files.

Stress Testing Profiles

Define reusable stress test profiles:
Use a profile with the --profile flag:

hitspec picks the config file in this order:
  1. the path given with --config (or HITSPEC_CONFIG) — used as is;
  2. otherwise the nearest hitspec.yaml (then hitspec.yml) found by looking in the working directory and then in each parent directory.
The search is bounded. It stops at the first directory that contains .git (your project root, after checking that directory itself), it never reads a config file from your home directory or from anything above it, and it stops at the filesystem root. If nothing is found, all default values are used. The working directory is where you ran the command for hitspec run, hitspec validate and hitspec contract verify, and the workspace directory for hitspec studio and hitspec serve. hitspec mcp serve never looks outside its workspace: a hitspec.yaml above the workspace root is ignored. Run hitspec run -v to print the config file in use on stderr. A config file that cannot be parsed stops the command with exit code 3 and a file:line message. An unknown key is only a warning:
The run goes ahead with the keys it understands. hitspec validate --strict turns the warning into an error (exit code 2), which makes it a good CI check.

Precedence

Every command that sends requests — hitspec run (including --stress), hitspec contract verify, hitspec studio and hitspec serve --api-only — resolves a setting the same way. From highest to lowest priority:
  1. a command-line flag (for example --timeout),
  2. a HITSPEC_* environment variable,
  3. hitspec.yaml,
  4. the built-in default.
The flags, and the --env / HITSPEC_ENV pair, belong to hitspec run. The other commands read the same variables for everything except the environment name. A @retry or @retryDelay annotation on a request overrides retries and retryDelay for that request, and a request’s own headers override headers. A number at or below zero in hitspec.yaml counts as “not set” (use followRedirects: false rather than maxRedirects: 0). The exception is maxResponseBytes, where 0 means the default and -1 means no limit. hitspec studio, hitspec serve --api-only and hitspec contract verify have no run flags. They read HITSPEC_TIMEOUT, HITSPEC_PROXY, HITSPEC_INSECURE, HITSPEC_PARALLEL, HITSPEC_CONCURRENCY and HITSPEC_BAIL, plus the TLS and HTTP variables from the table above (HITSPEC_CACERT, HITSPEC_CERT, HITSPEC_KEY, HITSPEC_HTTP1, HITSPEC_COOKIES, HITSPEC_MAX_RESPONSE_BYTES, HITSPEC_REDIRECT_FORWARD_HEADERS), then hitspec.yaml, then the defaults. Studio and serve choose the environment with their own --env (else defaultEnvironment, else dev) and ignore HITSPEC_ENV. contract verify finds hitspec.yaml from the current directory upward (or uses the path in HITSPEC_CONFIG) and has no environment of its own.

CLI Overrides

CLI flags always override config file values:
Last modified on October 19, 2026