.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:
Request Line
Every request starts with an HTTP method followed by a URL:Headers
Headers follow the request line, one per line, using standardName: Value format:
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:
.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:? prefix syntax for readability:
Assertion Blocks
Wrap assertions in>>> and <<< markers:
Capture Blocks
Capture response values for use in later requests: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).
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:"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