Skip to main content
hitspec tests live in plain text files with .http or .hitspec extensions. Each file contains one or more HTTP requests along with optional variables, assertions, and captures.

Minimal Example

The smallest valid test is a request with one assertion:

File Structure

A typical .http file follows this structure:

Request Separator

Use ### to separate multiple requests within a single file. Everything before the first ### (or before the first request line if no separator is used) is treated as the file-level scope for variable definitions.
The ### separator is required when a file contains more than one request. Text after ### on the same line is treated as a human-readable title and is ignored by the parser.

Variables

Define variables at the top of a file using the @variable = value syntax:
Reference them anywhere in the file with double curly braces:
See Variables for the full variable system including built-in functions and captures.

Request Line

Every request starts with an HTTP method followed by a URL:

Headers

Headers follow the request line, one per line, using standard Name: Value format:
A blank line separates headers from the request body. Any lines after the blank line (until the next block marker or separator) are treated as the body.

Request Body

JSON

Form URL-Encoded

Use the & prefix syntax for readable form data:

Multipart Form Data

Use the >>>multipart block for file uploads and mixed form data:

GraphQL

Use >>>graphql and >>>variables blocks:

XML

File-Based Body

Reference an external file as the request body using < ./path:
The file path is resolved relative to the .http file’s directory. Content-Type is auto-detected from the file extension (.json, .xml, .yaml, .html, .csv, .txt) when no explicit Content-Type header is set. Variable interpolation works in the file path:

Query Parameters

Inline with the URL:
Or use the explicit ? prefix syntax for readability:

Assertion Blocks

Wrap assertions in >>> and <<< markers:
See Assertions for all 26 operators.

Capture Blocks

Capture response values for use in later requests:
See Captures for the full capture system.

Metadata Directives

Metadata directives are comments that start with # @ and control request behavior:

All Directives

@waitFor — Service Readiness Polling

The @waitFor directive polls a URL before executing the request. This is useful when your test depends on a service that may not be immediately available (e.g., a container that was just started).
Syntax:
If the URL does not return the expected status within the timeout, the request fails without executing.

@if / @unless — Conditional Execution

Skip requests based on variable values:
The condition is truthy when the variable is defined and not empty, "0", or "false".

Stress Test Annotations

Fine-tune how individual requests behave during stress testing:

Comments

Lines starting with # that do not have an @ directive are treated as regular comments and ignored:

Authentication

Use @auth to attach credentials to a request. hitspec supports 8 authentication methods:

File Extensions

hitspec recognizes two file extensions:
  • .http — the standard extension, compatible with REST Client and other HTTP file tools
  • .hitspec — an alternative extension for files that use hitspec-specific features
Both are functionally identical.
Last modified on July 13, 2026