REST API
A harness that calls HTTP directly, such as one built on function calling, can use the same ten tools that MCP clients get. The server runs on your computer, on 127.0.0.1 and a port that the operating system picks every time Valakes starts. It is off until you turn it on in Settings, Agent API, and create an agent as described on the Claude Code page.
Prove the server before you send the token
Section titled “Prove the server before you send the token”A harness must do what the bridge does, in this order, before the token leaves its process.
- Open
api.jsonin the data folder of Valakes. It holds the port and the instance id. The folder is%APPDATA%\ValakesAppon Windows and~/Library/Application Support/ValakesAppon macOS. Do not use the file unless it is yours alone; on Windows it must lie inside that folder. - Read the token from
agents/<handle>.tokenin the same folder, with the same check. - Call
GET /v1/hello?agent=<handle>&nonce=<64 random hex characters>with noAuthorizationheader. Check thatinstance_idequals the one inapi.json, and thatproofequals the value of this formula:
base64url(HMAC-SHA256(SHA-256(token), "valakes-server-v1" || nonce || instance_id))
- Only then send the header
Authorization: Bearer <token>, and only on that same connection.
Do not skip the proof. The port changes at every start, and a process that binds it after Valakes stops would receive your token if you sent it unchecked. The token controls what the agent may do on your servers. The OpenAPI document at /v1/openapi.json lists the same steps under x-valakes-handshake.
The routes
Section titled “The routes”Each tool is one route. The OpenAPI document at /v1/openapi.json describes every one of them in full.
| Method | Path | Tool |
|---|---|---|
GET |
/v1/hosts |
list_hosts |
POST |
/v1/sessions |
open_session |
DELETE |
/v1/sessions/{session_id} |
close_session |
POST |
/v1/sessions/{session_id}/commands |
run_command |
GET |
/v1/blocks/{block_id}/output |
read_output |
GET |
/v1/sessions/{session_id}/screen |
get_screen |
POST |
/v1/sessions/{session_id}/keys |
send_keys |
GET |
/v1/hosts/{host_id}/credentials |
list_credentials |
POST |
/v1/sessions/{session_id}/uploads |
upload_file |
POST |
/v1/sessions/{session_id}/downloads |
download_file |
GET /v1/guide returns the built-in guide as Markdown and needs the agent’s token like every other route. GET /v1/hello and GET /v1/openapi.json need none.
What the server refuses
Section titled “What the server refuses”The server is built so that a web page cannot call it, and so a mistake in a harness fails closed.
- A request with an
Originheader or aSec-Fetch-header is refused, which is what a browser sends. A Node client cannot use the built-infetch, which addsSec-Fetch-Modeby itself; usenode:http, as the bridge does. - The
Hostheader must be exactly127.0.0.1:<port>.localhostis not accepted. - A
POSTneedsContent-Type: application/jsonand a body of at most 256 KiB. - The token is read only from the
Authorization: Bearerheader, never from the query string, a cookie or the body. - A paused agent gets
423withagent_paused, and a revoked or unknown token gets401. Past the rate limit the answer is429with aRetry-Afterheader. A call may wait for your approval for minutes, and the connection stays open while it does.
Errors come as { "error": { "code": "...", "message": "..." } } from a fixed catalogue. The limits that apply to a call are on how agents work: one command at a time per session, at most 4 at a time per agent, at most 5 open sessions per agent, and about 20 requests per second per agent.
The /mcp endpoint
Section titled “The /mcp endpoint”The same server answers MCP on POST /mcp. It takes the same bearer token and sits behind the same checks, so a client that talks to it directly, and not through the bridge, must do the proof above first, on every connection. Most MCP clients should use the bridge, as on the pages for Claude Code and other MCP clients.
If the proof fails, the program at the port did not know your token. Do not work around it. Check that Valakes is the process that is running and restart it, and if the failure stays, rotate the agent’s token in the Agents panel and treat the old token file as exposed.