hitspec serve --api-only. All endpoints are prefixed with /api/v1. Responses are JSON with Content-Type: application/json.
Security and Request Requirements
The API can read, write and delete workspace files and send arbitrary requests, so the server protects itself against web pages that try to reach it through your browser:- JSON bodies need
Content-Type: application/json. A request that has a JSON body but any other content type (text/plain,application/x-www-form-urlencoded, none at all) is rejected with415 Unsupported Media Type.curl -dsends form-encoded data by default, so add-H "Content-Type: application/json". Requests without a body (for examplePOST /stress/stop) need no content type.PUT /files/{path}takes the raw file text and is not affected. - Host. When the server is bound to a loopback address, the
Hostheader must belocalhost,127.0.0.1or[::1](optionally with the server’s port); anything else gets403 Forbidden(DNS-rebinding protection). - Origin. A request that carries an
Originheader (browsers always send one cross-site) must come fromhttp(s)://localhost,127.0.0.1or[::1]on the server’s own port, or on any port when--corsis set; otherwise403 Forbidden. This also applies to the WebSocket upgrade. Requests withoutOrigin(curl, scripts, server-side code) are not affected. - Token. If
--api-token/HITSPEC_API_TOKENis set, every request needsAuthorization: Bearer <token>(scheme is case-insensitive) or?token=<token>, else401. If the server binds to a non-loopback address, or--allow-shell/--allow-dbis set, and no token is configured, a random token is generated and printed once to stderr. - CORS preflights. With
--cors,OPTIONSpreflights from an allowed origin are answered with204and CORS headers without a token; the actual request still needs it. - Workspace file references. A
< filebody or a multipart file that points outside the workspace is refused (file reference ... is outside the workspace). This applies to run, execute, stress and contract verification.hitspec runis not subject to this.
Read-only mode
With--read-only, writes to files, hitspec.yaml, environments (switching the active environment is still allowed), stress profiles and history return 403. Running requests, stress, mock, record start/stop, contract verification, export/curl, import (POST /import/*) and POST /record/export keep working, because they only return text and write nothing. Runs in read-only mode do not persist cookies.
Timeouts and shutdown
/run and /execute are not subject to the 60s response timeout. On shutdown the server lets in-flight requests finish for up to 10s; a second signal exits at once. --parent-pid <pid> shuts the server down when that process exits, so a supervisor that dies without cleaning up does not leave it running.
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.200 OK
List Files
Returns a flat list of all.http and .hitspec files in the workspace with metadata.
200 OK
Get Parsed File
Returns the fully parsed content of a single.http or .hitspec file, including all requests, variables, assertions, and captures.
Relative path to the file within the workspace. Uses wildcard path matching (
{path...}).200 OK
Get Raw File Content
Returns the raw text content of a file. Use this for source editing.200 OK with Content-Type: text/plain
Create File
Create a new.http or .hitspec file in the workspace.
Relative path for the new file. Must end in
.http or .hitspec and be within the workspace.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.text/plain.
Response 200 OK
Delete File
Delete a.http or .hitspec file from the workspace.
204 No Content
Execution
Execute Request
Execute one or more requests from a specific file. WhenrequestName 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.
Environment name to use for variable interpolation. Overrides the server’s active environment.
200 OK
warnings, an array of strings with non-fatal findings (a capture that matched nothing, a {{reference}} sent unresolved). It is omitted when empty.
Run File
Run all requests in a file. Similar toexecute but always runs every request (no name filter).
200 OK — same RunResultDTO structure as the Execute Request endpoint.
Environments
List Environments
Returns all environments defined inhitspec.yaml, including the currently active environment.
200 OK
Set Active Environment
Switch the server’s active environment. Broadcasts anenvironment_changed event over WebSocket.
204 No Content
Get Environment
Get the variables for a specific environment.200 OK
Update Environment
Create or update the variables for a named environment.200 OK
Config
Get Configuration
Returns the currenthitspec.yaml configuration. Returns an empty object if no config file is present.
200 OK
Update Configuration
Partially update the server configuration. Only provided fields are updated; omitted fields remain unchanged. Changes are persisted to thehitspec.yaml config file on disk. If no config file exists, one is created in the workspace root.
0 or "": retries: 0 disables retries and proxy: "" clears the proxy. For timeout, retryDelay, maxRedirects and concurrency, 0 resets the value to its default. Negative numbers return 400.
Response 200 OK — returns the resulting configuration.
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.200 OK
Clear In-Memory History
Clear all in-memory history entries.204 No Content
List Persistent Runs
Returns paginated persistent run history from the SQLite database.200 OK
Get Run Details
Returns a single run with its full results and assertion details.200 OK
warnings (an array of strings, omitted when empty) when its request produced non-fatal findings. Runs stored by older versions have none.
Delete a Run
Delete a specific run and all its associated results and assertions (cascade delete).204 No Content
Delete All Runs
Delete all persistent run history.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).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 viastress_update messages.
Duration of the stress test as a Go duration string (e.g.,
"30s", "5m", "1h"). Required unless profile is set, in which case the profile’s duration is used.Name of a saved stress profile. The profile’s duration, rate, VUs, max VUs, think time, ramp-up and thresholds are the base for the run;
duration, rate, vus and maxVUs in the request win over the profile’s. A threshold written without an operator gets the metric’s natural one (rps means >, the others <), and one written with an operator keeps it. An unknown profile is a 400 Bad Request.200 OK
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 returns200 OK with an "already_stopped" status instead of an error.
200 OK
Get Stress Test Status
Returns whether a stress test is running and, if so, the current metrics.200 OK
incomplete counts requests still in flight, and assertionChecks / assertionFailures count responses that were checked against expect lines and those that failed one. Assertion failures are not part of errors. The three fields are omitted when zero, and the same fields appear in stress_update messages. duration is the run’s configured length in seconds (from the request or its profile), so a client can draw progress as elapsed / duration; it is omitted when unknown.
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.200 OK
incomplete, assertionChecks, assertionFailures, assertionFailRate, warnings, thresholds and breakdown[].assertionFailures are omitted when empty or zero. incomplete requests were still in flight when the window closed and are not counted in total or errors. warnings describe the run itself, for example a target rate that was not reached.
When the run could not start (invalid settings, a failed setup request), the result has an error field saying why and its counters are zero. The final stress_update WebSocket event ("completed": true) carries the same error.
When no result is available:
List Stress Profiles
Returns the stress test profiles defined inhitspec.yaml.
200 OK
Create Stress Profile
Create a new stress profile. The profile is persisted tohitspec.yaml.
201 Created
409 Conflict if a profile with the same name already exists.
Update Stress Profile
Update an existing stress profile. The changes are persisted tohitspec.yaml.
name).
Response 200 OK
404 Not Found if the profile does not exist.
Delete Stress Profile
Delete a stress profile. The deletion is persisted tohitspec.yaml.
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.
200 OK
409 Conflict if a mock server is already running, or if the port is busy or the address cannot be bound.
Stop Mock Server
Stop the running mock server.200 OK
Get Mock Routes
Returns the current status and registered routes of the mock server.200 OK (when running)
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.Path to a script that is run with the state name as its argument before each interaction that declares a state. Because this executes a program on the server, the request is rejected with
403 Forbidden unless the server was started with --allow-shell, and the script (after resolving symlinks) must be inside the workspace. Relative paths are resolved from the workspace root.List of contract file paths. When omitted, all
.http/.hitspec files in the workspace are used.200 OK
List Contract Files
Returns all.http/.hitspec files in the workspace that can be used as contract files.
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.When true, duplicate requests with the same method and path are only recorded once.
List of header names whose values should be sanitized (replaced with placeholders) in the recorded output.
200 OK
409 Conflict if a recording proxy is already running, or if the port is busy or the address cannot be bound. 400 Bad Request if targetUrl is missing or is not a valid URL.
Stop Recording
Stop the recording proxy.200 OK
Get Recording Status
Returns whether the recording proxy is running, how many requests have been captured, and the captured request details.200 OK (when running)
200 OK (when not running)
Export Recordings
Export all captured recordings as.http file content. The proxy must be running.
200 OK
Clear Recordings
Clear all captured recordings without stopping the proxy.200 OK
Import
Import curl
Convert a curl command or a file containing curl commands into.http format.
command or filePath is required.
Response 200 OK
Import Insomnia
Convert an Insomnia export (JSON) into.http format.
data or filePath is required.
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.
Path to the OpenAPI specification file (relative to workspace) or a URL. Supports YAML and JSON, OpenAPI v2 and v3.
Override the base URL from the spec. Useful when the spec references a production URL but you want to target localhost.
200 OK
Export
Export as curl
Convert requests from a.http/.hitspec file into curl commands.
200 OK
System
Get System Info
Returns version, build time, Go version, and platform information.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.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.
status field is either "started" or "completed". The passed, duration and warnings fields are only present when status is "completed"; warnings is an array of strings and is omitted when empty.
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.
event field can be "started", "stopped", or "request".
ping / pong
Clients can send {"type": "ping"} messages and the server will respond with a pong: