Skip to Content
FeaturesHTTP API

HTTP API

While running, Stash serves a set of HTTP control endpoints for querying runtime state, switching proxy groups, refreshing remote resources, and diagnosing DNS, proxies, and routing. The endpoints stay compatible with the Clash control API, so existing Clash dashboards can connect to Stash directly; on top of that, Stash adds its own endpoints under /stash and /diagnosis.

Enabling and Authentication

  • iOS / tvOS: Turn on external control under Settings - External Access and set an API secret. The page lists the addresses an external controller can connect to.
  • macOS: Configure the control port in Settings; the default is 9090.

Every request carries the secret in the Authorization header:

Authorization: Bearer <API secret>

When a WebSocket client cannot set custom headers, pass the secret as the token query parameter instead, e.g., /traffic?token=<API secret>.

⚠️

The endpoints that run scripts or read and write script storage only accept requests from the local loopback address, and only when a secret is set.

Basics

MethodPathDescription
GET/App version, OS version, device ID, architecture, and platform
GET/versionVersion number
GET/configsCurrent mode, log-level, and the mixed proxy port
PATCH/configsSwitch the mode; body {"mode": "rule"} with rule, global, or direct
GET/logsLive log stream; accepts a level parameter
GET/trafficCurrent upload and download rates with totals
GET/stash/speedCurrent rates and totals

Connections

MethodPathDescription
GET/connectionsActive connections with source, destination, matched rule, and proxy chain
GET/connections/{id}Details and log of one connection
DELETE/connections/{id}Close the connection
GET/httpRecent requests captured by the HTTP engine
GET/http/{id}Full request and response of one captured HTTP request

Rules

MethodPathDescription
GET/rulesThe rules in effect
GET/rules/countTotal rule count, with rule sets counted by their entries
GET/rules/matchReport which rule and outbound a destination would match, without opening a connection

Query parameters of /rules/match:

  • target: Required. A domain, domain:port, or IP address.
  • network: tcp or udp, tcp by default.
  • port: Destination port, 443 by default; a port inside target wins.
  • process, user-agent: A simulated process path and User-Agent for PROCESS-NAME, PROCESS-PATH, and USER-AGENT rules.
  • src-ip, src-port: A simulated source address and port for SRC-IP and SRC-PORT rules.
  • resolve: Whether DNS resolution may run for the match, true by default.

The response includes the matched rule (type, payload, and index), the final outbound, the proxy chain, the resolution outcome, and the number of rules evaluated.

Proxies and Groups

MethodPathDescription
GET/proxiesEvery proxy and group with latency and current selection
PUT/proxies/{name}Change a group’s selection; body {"name": "<proxy name>"}
GET/proxies/{name}/delayRun one latency test on the proxy and return the result
GET/proxies/{name}/infoDetails of the proxy
GET/stash/proxiesProxy names
GET/stash/proxy/countProxy count
GET/stash/proxy/display/v2The summary the app’s group page uses
PUT/stash/proxy/delay/{name}Trigger a latency test for the proxy

Tailscale proxies have their own endpoints: GET /proxies/{name}/tailscale returns the node status, GET /proxies/{name}/tailscale/stream pushes status changes, POST /proxies/{name}/tailscale/login and /logout start login and logout, and PUT or DELETE /proxies/{name}/tailscale/exit-node set or clear the exit node.

Remote Resources

MethodPathDescription
GET/providers/proxiesRemote proxy sets and their nodes
PUT/providers/proxies/{name}Update the proxy set now
GET/providers/proxies/{name}/healthcheckRun latency tests on the set’s nodes
GET/providers/rulesRule sets
PUT/providers/rules/{name}Update the rule set now
GET/providers/scriptsScripts
PUT/providers/scripts/{name}Update the script now
GET/providers/geodbGeoIP / ASN database information
PUT/providers/geodb/{name}Update the database now
PUT/stash/providerUpdate every remote resource now

DNS

MethodPathDescription
GET/dns/recordDNS cache contents: question, record type, answers, answering server, and cost
GET/dns/countNumber of cached entries
GET/dns/resolve/{host}Resolve a domain through the current DNS configuration and return the record
POST/dns/flushFlush the DNS cache

Diagnosis

MethodPathDescription
GET/diagnosis/dnsTest each configured DNS server, reporting name, cost, and error
GET/diagnosis/dns/latencyDNS resolution latency
GET/diagnosis/proxiesTest each proxy for HTTP and UDP connectivity
GET/diagnosis/tracerouteTrace the route to a destination
GET/diagnosis/usedMemoryMemory the core currently uses
GET/diagnosis/availableMemoryAvailable memory

Query parameters of /diagnosis/traceroute: target (required), proxy (an explicit outbound; the rules decide when omitted), direct (true traces the direct path), and maxHops and probes (maximum hops and probes per hop). The response first reports the routing decision (matched rule, outbound, and chain), then one hop at a time, with each address annotated with its country, ASN, and organization. A destination that goes through a proxy is traced only as far as the proxy server.

Scripts

MethodPathDescription
POST/script/evaluateRun a script in a mock environment and return its output, logs, notifications, and elapsed time
GET / POST/script/runtime/store/{key}Read or write script persistent storage

Request body fields of /script/evaluate: script (required, the script source), engine (webkit or jsc), timeout (seconds), argument, and name.

Live Updates

List endpoints such as /traffic, /connections, /http, /dns/record, /proxies, and /diagnosis/dns/latency can be upgraded to WebSocket connections. After the upgrade, Stash pushes the full data once, then pushes again whenever the data changes, at the interval set by the interval query parameter in milliseconds. /diagnosis/dns and /diagnosis/proxies are WebSocket-only and stream each test result as it completes.

Dashboard

GET /dashboard serves the built-in web dashboard, which can be opened directly in a browser.

Last updated on