Remote API
Linux only
cortland-api puts Cortland’s control socket on your
Tailscale network over HTTP. Anything on your tailnet
can then see which agents are working, read what they said, and answer the
ones waiting on you: an app on your phone, a dashboard, a script on another
machine.
It speaks the control socket’s own protocol, so everything
cortland-ctl can do is one HTTP request
away. There’s no second API to learn. It’s off by default.
Turn it on
Section titled “Turn it on”-
Open Preferences → Remote and switch it on. That starts the
cortland-apisystemd user service, which listens on a private socket at$XDG_RUNTIME_DIR/cortland/api.sock. -
Publish that socket on your tailnet, once. The Remote page shows the exact command for your machine. It looks like this:
Terminal window sudo tailscale serve --bg --https=8443 unix:/run/user/1000/cortland/api.sock -
Check it from any device on your tailnet:
Terminal window curl https://<machine>.<tailnet>.ts.net:8443/v1/health# {"ok":true,"cortland_running":true}
On a source build, copy pkgbuild/cortland-api.service to
~/.config/systemd/user/ and point its ExecStart at
build/tools/cortland-api. The package installs the service for you.
Routes
Section titled “Routes”| Route | What it does |
|---|---|
POST /v1/command |
Sends one control-socket request as JSON and returns the socket’s reply unchanged. |
GET /v1/events |
Server-sent events: agent state changes, commands, and edit approvals. Filter with ?pane_id= and ?type=. |
GET /v1/health |
Whether Cortland is running. |
Build a phone app
Section titled “Build a phone app”Three calls cover what a phone needs.
See every agent. agent_summary returns each agent’s state, session
title, repository and branch, and its last reply. While an agent waits on you,
it also carries the question, the numbered choices, and what the agent is
asking to run.
curl -s https://<machine>.<tailnet>.ts.net:8443/v1/command \ -H 'Content-Type: application/json' \ -d '{"action":"agent_summary"}'Answer it. Type a choice or a reply into the agent’s pane with
pane_send_text, or press a key with pane_send_key:
{"action":"pane_send_text","pane_id":"<pane>","text":"1"}{"action":"pane_send_key","pane_id":"<pane>","key":"enter"}Approve an edit. approval_list shows edits parked at the
approval desk, and approval_resolve answers
one:
{"action":"approval_resolve","id":12,"accepted":true}To update live instead of polling, keep GET /v1/events open. It sends one
data: line per event.
Security
Section titled “Security”There are no tokens. Tailscale handles identity:
- The API listens only on a private socket (mode
0600) that sandboxed panes can’t reach, and accepts connections only fromtailscaled. - It answers only the Tailscale logins in
[remote] allowed_logins. Left empty, that’s the desktop’s own login. - Browser requests must come from an origin in
[remote] allowed_origins. - Every command is logged to
~/.local/state/cortland/api.logwith the time, login, action, and pane.
[remote]enabled = falseallowed_logins = []allowed_origins = [] # add your web app's origin to call it from a browserThe protocol reference (§13.5 and §13.6) has the full details.