Skip to main content
HTTPSpec extends the familiar .http file format with assertion capabilities, enabling you to write executable HTTP requests that validate API responses automatically.

File Extensions

HTTPSpec supports two file extensions:
  • .httpspec - The recommended extension for HTTPSpec files
  • .http - Standard HTTP file format, also supported for compatibility
Both extensions work identically in HTTPSpec. The tool will automatically discover and execute all .http and .httpspec files when you run it against a directory.

Basic Structure

Each HTTPSpec file contains one or more request blocks. A request block consists of:
  1. Optional name - A comment starting with ### to describe the test
  2. Request line - HTTP method, URL, and optional HTTP version
  3. Headers - Key-value pairs for HTTP headers
  4. Request body - Optional body content (JSON, XML, etc.)
  5. Assertions - Lines starting with //# that validate the response
### Optional test name
GET https://api.example.com/endpoint
Header-Name: Header-Value

Optional request body

//# status == 200
//# body contains "expected content"

Multiple Requests

You can include multiple request blocks in a single file, separated by blank lines or test names. HTTPSpec executes them sequentially, which is useful for:
  • Setup and teardown operations
  • Testing request sequences
  • Grouping related API tests
Multiple Requests
### Create a user
POST https://api.example.com/users
Content-Type: application/json

{
  "name": "Alice"
}

//# status == 201
//# body contains "Alice"

### Get the user
GET https://api.example.com/users/1

//# status == 200
Requests are executed in the order they appear in the file.

Learn More

Request Format

Detailed syntax for HTTP requests, headers, and bodies

Assertions

How to write assertions to validate responses

Variables

Use variables for dynamic values in requests

Assertion Types

All available assertion operators and examples

Build docs developers (and LLMs) love