Skip to main content
The hitspec server exposes a REST API when you run hitspec serve --api-only. All endpoints are prefixed with /api/v1. Responses are JSON with Content-Type: application/json.

Error Format

All error responses follow a consistent structure:

Workspace & Files

Get Workspace Overview

Returns the workspace file tree, total request count, active environment, and whether a config file exists.
Response 200 OK

List Files

Returns a flat list of all .http and .hitspec files in the workspace with metadata.
Response 200 OK

Get Parsed File

Returns the fully parsed content of a single .http or .hitspec file, including all requests, variables, assertions, and captures.
string
required
Relative path to the file within the workspace. Uses wildcard path matching ({path...}).
Response 200 OK

Get Raw File Content

Returns the raw text content of a file. Use this for source editing.
string
required
Relative path to the file within the workspace.
Response 200 OK with Content-Type: text/plain

Create File

Create a new .http or .hitspec file in the workspace.
Request Body
string
required
Relative path for the new file. Must end in .http or .hitspec and be within the workspace.
Response 201 Created

Save File

Save raw text content to an existing file. The file watcher suppresses the corresponding change notification to prevent UI reload loops.
string
required
Relative path to the file within the workspace.
Request Body: Raw file content as text/plain. Response 200 OK

Delete File

Delete a .http or .hitspec file from the workspace.
string
required
Relative path to the file within the workspace.
Response 204 No Content

Execution

Execute Request

Execute one or more requests from a specific file. When requestName is provided, only that request runs (filtered by name). When omitted, all requests in the file execute. Real-time progress is broadcast over the WebSocket connection during execution.
Request Body
string
required
Relative path to the .http or .hitspec file within the workspace.
string
Name of a specific request to execute. When omitted, all requests in the file are executed.
string
Environment name to use for variable interpolation. Overrides the server’s active environment.
Response 200 OK

Run File

Run all requests in a file. Similar to execute but always runs every request (no name filter).
Request Body
string
required
Relative path to the .http or .hitspec file within the workspace.
string
Environment name to use. Overrides the server’s active environment.
Response 200 OK — same RunResultDTO structure as the Execute Request endpoint.

Environments

List Environments

Returns all environments defined in hitspec.yaml, including the currently active environment.
Response 200 OK

Set Active Environment

Switch the server’s active environment. Broadcasts an environment_changed event over WebSocket.
Request Body
string
required
The name of the environment to set as active.
Response 204 No Content

Get Environment

Get the variables for a specific environment.
string
required
Environment name.
Response 200 OK

Update Environment

Create or update the variables for a named environment.
string
required
Environment name.
Request Body
object
required
Map of variable names to values for this environment.
Response 200 OK

Config

Get Configuration

Returns the current hitspec.yaml configuration. Returns an empty object if no config file is present.
Response 200 OK

Update Configuration

Partially update the server configuration. Only provided fields are updated; omitted fields remain unchanged. Changes are persisted to the hitspec.yaml config file on disk. If no config file exists, one is created in the workspace root.
Request Body
number
Request timeout in milliseconds. Must be greater than 0.
number
Number of automatic retries on failure. Must be greater than 0.
boolean
Whether to follow HTTP 3xx redirects.
boolean
Whether to validate SSL/TLS certificates.
string
HTTP proxy URL (e.g., http://proxy:8080).
boolean
Whether to run independent requests in parallel.
number
Maximum number of concurrent requests in parallel mode. Must be greater than 0.
Response 200 OK — returns the updated configuration object.

History

hitspec maintains two layers of history: a lightweight in-memory history for the current session and a persistent SQLite-backed history stored at ~/.hitspec/history.db.

Get In-Memory History

Returns the in-memory execution history for the current server session.
Response 200 OK

Clear In-Memory History

Clear all in-memory history entries.
Response 204 No Content

List Persistent Runs

Returns paginated persistent run history from the SQLite database.
number
default:"20"
Number of runs to return. Maximum 100.
number
default:"0"
Number of runs to skip for pagination.
Response 200 OK

Get Run Details

Returns a single run with its full results and assertion details.
number
required
Numeric run ID.
Response 200 OK

Delete a Run

Delete a specific run and all its associated results and assertions (cascade delete).
number
required
Numeric run ID.
Response 204 No Content

Delete All Runs

Delete all persistent run history.
Response 204 No Content

List Results by Request Name

Retrieve historical results for a specific request, filtered by file path. Useful for comparing how a single request’s responses have changed over time. Results are ordered by run start time (newest first).
string
required
The name of the request to look up.
string
required
The file path containing the request.
number
default:"20"
Maximum number of results to return (1–100).
number
default:"0"
Number of results to skip for pagination.
Response 200 OK

Stress Testing

Start Stress Test

Start a load test against the requests defined in one or more files. Metrics are broadcast in real time over the WebSocket connection via stress_update messages.
Request Body
string[]
required
List of .http or .hitspec file paths relative to the workspace.
string
required
Duration of the stress test as a Go duration string (e.g., "30s", "5m", "1h").
number
Target requests per second in rate mode.
number
Number of virtual users. Setting this switches from rate mode to VU mode.
number
Maximum number of concurrent virtual users.
Response 200 OK
Error 409 Conflict if a stress test is already running.

Stop Stress Test

Stop a running stress test. If no test is currently running, the endpoint returns 200 OK with an "already_stopped" status instead of an error.
Response 200 OK
When no test is running:

Get Stress Test Status

Returns whether a stress test is running and, if so, the current metrics.
Response 200 OK
When no stress test is running:

Get Stress Test Result

Returns the result of the last completed stress test, including summary metrics, latency percentiles, and per-request breakdown.
Response 200 OK
When no result is available:

List Stress Profiles

Returns the stress test profiles defined in hitspec.yaml.
Response 200 OK

Create Stress Profile

Create a new stress profile. The profile is persisted to hitspec.yaml.
Request Body
string
required
Unique name for the profile. Must not conflict with an existing profile.
string
required
Duration of the stress test as a Go duration string.
Response 201 Created
Error 409 Conflict if a profile with the same name already exists.

Update Stress Profile

Update an existing stress profile. The changes are persisted to hitspec.yaml.
string
required
Name of the profile to update.
Request Body: Same fields as Create Stress Profile (except name). Response 200 OK
Error 404 Not Found if the profile does not exist.

Delete Stress Profile

Delete a stress profile. The deletion is persisted to hitspec.yaml.
string
required
Name of the profile to delete.
Response 204 No Content Error 404 Not Found if the profile does not exist.

Mock Server

Start Mock Server

Start a mock server that serves responses based on the request/response pairs defined in your .http files. Incoming requests to the mock server are broadcast over WebSocket as mock_request events.
Request Body
string[]
required
List of .http or .hitspec file paths containing request/response pairs.
number
default:"3000"
Port on which the mock server will listen.
string
Artificial delay before each response, as a Go duration string (e.g., "100ms", "1s").
Response 200 OK
Error 409 Conflict if a mock server is already running.

Stop Mock Server

Stop the running mock server.
Response 200 OK

Get Mock Routes

Returns the current status and registered routes of the mock server.
Response 200 OK (when running)
Response 200 OK (when not running)

Contract Testing

Verify Contracts

Run contract verification against a live provider. Sends each request defined in the contract files to the provider URL and validates the responses match expectations.
Request Body
string
required
The base URL of the provider service to verify contracts against.
string
URL of an endpoint that accepts state setup requests before each interaction.
string[]
List of contract file paths. When omitted, all .http/.hitspec files in the workspace are used.
Response 200 OK

List Contract Files

Returns all .http/.hitspec files in the workspace that can be used as contract files.
Response 200 OK

Recording Proxy

Start Recording

Start a recording proxy that captures HTTP traffic passing through it. The proxy forwards requests to the target URL and records both request and response.
Request Body
string
required
The upstream URL that the proxy forwards requests to.
number
default:"8081"
Port on which the recording proxy will listen.
boolean
default:"false"
When true, duplicate requests with the same method and path are only recorded once.
string[]
List of URL path patterns to exclude from recording.
string[]
List of header names whose values should be sanitized (replaced with placeholders) in the recorded output.
Response 200 OK
Error 409 Conflict if a recording proxy is already running.

Stop Recording

Stop the recording proxy.
Response 200 OK

Get Recording Status

Returns whether the recording proxy is running, how many requests have been captured, and the captured request details.
Response 200 OK (when running)
Response 200 OK (when not running)

Export Recordings

Export all captured recordings as .http file content. The proxy must be running.
Response 200 OK

Clear Recordings

Clear all captured recordings without stopping the proxy.
Response 200 OK

Import

Import curl

Convert a curl command or a file containing curl commands into .http format.
Request Body
One of command or filePath is required.
string
A curl command string to convert to .http format.
string
Path to a file containing curl commands, relative to the workspace.
Response 200 OK

Import Insomnia

Convert an Insomnia export (JSON) into .http format.
Request Body
One of data or filePath is required.
string
Insomnia export JSON content as a string.
string
Path to an Insomnia JSON export file, relative to the workspace.
Response 200 OK

Import OpenAPI

Convert an OpenAPI specification (YAML or JSON, v2 or v3) into .http format. The spec can be a local file path or a URL.
Request Body
string
required
Path to the OpenAPI specification file (relative to workspace) or a URL. Supports YAML and JSON, OpenAPI v2 and v3.
string
Override the base URL from the spec. Useful when the spec references a production URL but you want to target localhost.
Response 200 OK

Export

Export as curl

Convert requests from a .http/.hitspec file into curl commands.
Request Body
string
required
Relative path to the .http or .hitspec file in the workspace.
string
Name of a specific request to export. When omitted, all requests are exported.
Response 200 OK

System

Get System Info

Returns version, build time, Go version, and platform information.
Response 200 OK

WebSocket

Connect

Establish a WebSocket connection for real-time event streaming. The server pushes events as they occur — no polling required.
The WebSocket endpoint accepts connections from localhost, 127.0.0.1, and [::1] origins only.
Connection Example

Message Envelope

All WebSocket messages use this envelope format:

Message Types

execution_start

Sent when a request execution begins.

request_progress

Sent for each individual request as it starts and completes during an execution.
The status field is either "started" or "completed". The passed and duration fields are only present when status is "completed".

execution_complete

Sent when an entire execution finishes. The result payload contains the full RunResultDTO.

error

Sent when an execution fails with an error.

environment_changed

Sent when the active environment is switched via PUT /api/v1/environments/active.

file_changed

Sent when a .http or .hitspec file is created, modified, or deleted in the workspace (via filesystem watcher).

stress_update

Sent every 500ms during an active stress test with current metrics. The running and completed booleans indicate the test lifecycle — the UI uses these to detect when a test finishes naturally (without an explicit stop) and transition to the results view.

mock_request

Sent when the mock server receives a request, or when it starts/stops.
The event field can be "started", "stopped", or "request".

ping / pong

Clients can send {"type": "ping"} messages and the server will respond with a pong:
Last modified on June 14, 2026