Skip to content

Clash API endpoints ​

Every request needs the secret. Errors are {"message": "..."} with an HTTP status; an unknown path answers 404.

Read ​

EndpointAnswers
GET /{"hello": "clash"}
GET /version{"meta": true, "version": "Apranik 1.2.3"}
GET /configsmode (always rule), mode-list, log-level
GET /trafficbytes up and down in the last second, and totals, every second
GET /memorymemory in use, every second
GET /connectionsthe live list
GET /proxies, GET /proxies/{name}the outbounds; groups have now and all
GET /rulesthe routing rules and their hits
GET /logs?level=the live log: debug, info, warning, error
GET /logs/filethe log file
GET /dns/query?name=&type=one lookup through the resolver
GET /inbounds/{tag}/usersan inbound's user names
GET /inbounds/{tag}/users/{name}whether a user exists

/traffic, /memory, /connections and /logs stream over WebSocket, and the first three also as JSON lines.

Change ​

EndpointDoes
DELETE /connectionscloses every live connection
DELETE /connections/{id}closes one; a UDP entry ends its whole session
PUT /proxies/{name}switches a selector: {"name": "<member>"}
GET /proxies/{name}/delayone delay test: {"delay": 120}, in milliseconds
GET /group/{name}/delaya delay test of every member
POST /cache/dns/flushforgets cached DNS answers
POST /reloadreloads the config file: 400 with every problem, or 202
POST /inbounds/{tag}/usersadds a user
DELETE /inbounds/{tag}/users/{name}removes a user and ends their connections
POST /inbounds/{tag}/users:batchCreateadds many users
POST /inbounds/{tag}/users:batchDeleteremoves many users

Delay tests take url, timeout (milliseconds) and expected; what they leave out comes from delay_test. They go through the named outbound, never through routing.

Connections ​

Listed only while stats.tracking is on; otherwise 503. rule is where the router decided (routing.rules[3] or default), chains the outbounds from member to group, and metadata.host the sniffed name or the requested domain.

Rules ​

json
{
  "index": 1,
  "type": "route",
  "payload": "domain_suffix=ir port=443",
  "proxy": "direct",
  "hitCount": 12
}

type is the action, and default for the last entry. payload writes the match with the config's field names.

Log file ​

GET /logs/file serves the config's file log output; 404 without one.

ParameterDoes
output=Nthe N-th file output, from 0
tail=Nthe last N lines
contains=textonly lines containing the text
follow=truekeep sending what is appended
download=truesend as an attachment

Users ​

Changes the users of a Trojan, VLESS, SOCKS5, HTTP or mixed inbound. A user is written as in the protocol's users. A name in the path is one escaped segment.

sh
curl -X POST -H "Authorization: Bearer $SECRET" \
  -d '{"name": "alice", "password": "correct horse"}' \
  http://127.0.0.1:9090/inbounds/trojan-in/users

A batch runs its items in order, is not atomic, and answers one result per item. Status codes: 404 unknown inbound or user, 400 invalid user, 409 name taken, 413 body too large.

Not built ​

/providers, /restart, /upgrade, /script, /profile, /storage.