REST API
Manage sessions, windows, and panes over HTTP under /api. Send the
access token with every request.
api="${BTMUX_API_URL:-http://127.0.0.1:8004}/api"auth="Authorization: Bearer $BTMUX_AUTH_TOKEN"
# Create a session; the reply has its first pane's IDcurl -H "$auth" -X POST "$api/sessions" --json '{"name":"build"}'
# Type into a pane, then read its screencurl -H "$auth" -X POST "$api/panes/<pane-id>/input" --json '{"text":"echo hi","keys":["Enter"]}'curl -H "$auth" "$api/panes/<pane-id>/capture?lines=20"
# Bring a pane to the front in every clientcurl -H "$auth" -X POST "$api/panes/<pane-id>/focus"Input and output
Section titled “Input and output”inputsendstextverbatim, thenkeys: tmux-style key names such asEnter,Tab,Escape,Space,BSpace,Up,PageDown,F5,C-c, orM-x. Cursor keys follow the program’s cursor key mode, as in tmux.capturereturns the pane as rendered plain text with wrapped lines joined, liketmux capture-pane -pJ. It covers the visible screen;scrollback=trueadds all retained history above it, andhistory=Nat most N rows of it.lines=Nkeeps the last N lines.outputreturns the raw bytes instead, escapes included.
Panes and windows
Section titled “Panes and windows”splittakesdirection(left,right,up, ordown: where the new pane goes), optionalcwd, andselect(default true), and returns the newpane_id. Creating a session or window returns itspane_idtoo.focusswitches every connected client to the pane’s window and session. It replies 204, or 404 for an unknown pane.open-file-browserdoes the same and then opens a dialog there. Itsmodeis"files"(default),"git", or"process", as<prefix> + f,g, andtopen. In file mode,pathis the directory and optionalfocus_filenames an entry in it to focus.
Endpoints
Section titled “Endpoints”The API reference gives each endpoint’s parameters,
request and response bodies, and status codes. It is generated from the
server’s code as an OpenAPI 3.1 document, which clients and tools can read
too: a server serves the one for its version at /api/openapi.json, and this
site the latest. Endpoints the btmux app uses for itself,
such as file previews and editors, aren’t listed.
Every endpoint can reply 401 for a missing or wrong token, and 403 for a
Host or Origin the server doesn’t allow. Error bodies, if any, are plain
text. Malformed IDs and JSON bodies get 400, a body over the size limit 413,
one without Content-Type: application/json 415, and one that doesn’t match
its schema 422.
Sessions
Section titled “Sessions”| Endpoint | Does |
|---|---|
GET /api/sessions |
List sessions |
POST /api/sessions |
Create a session |
DELETE /api/sessions |
Clear sessions |
GET /api/sessions/{session_id} |
Get a session |
DELETE /api/sessions/{session_id} |
Kill a session |
POST /api/sessions/{session_id}/rename |
Rename a session |
Windows
Section titled “Windows”| Endpoint | Does |
|---|---|
POST /api/sessions/{session_id}/windows |
Create a window |
POST /api/sessions/{session_id}/windows/switch |
Switch windows |
POST /api/sessions/{session_id}/windows/rename |
Rename the active window |
POST /api/sessions/{session_id}/windows/close |
Close the active window |
DELETE /api/windows/{window_id} |
Kill a window |
POST /api/windows/{window_id}/select |
Select a window |
POST /api/windows/{window_id}/rename |
Rename a window |
| Endpoint | Does |
|---|---|
GET /api/panes |
List panes |
POST /api/panes/{pane_id}/split |
Split a pane |
DELETE /api/panes/{pane_id} |
Kill a pane |
POST /api/panes/{pane_id}/select |
Select a pane |
GET /api/panes/{pane_id}/ports |
List a pane's listening ports |
GET /api/panes/{pane_id}/exit |
Wait for a pane's program to exit |
POST /api/panes/{pane_id}/focus |
Focus a pane |
POST /api/panes/{pane_id}/open-file-browser |
Open the file browser |
POST /api/panes/{pane_id}/open-editor |
Open an editor |
Session panes
Section titled “Session panes”| Endpoint | Does |
|---|---|
POST /api/sessions/{session_id}/panes/{pane_id}/split |
Split an active-window pane |
DELETE /api/sessions/{session_id}/panes/{pane_id} |
Kill an active-window pane |
POST /api/sessions/{session_id}/panes/{pane_id}/zoom |
Zoom a pane |
POST /api/sessions/{session_id}/panes/{pane_id}/select |
Select an active-window pane |
POST /api/sessions/{session_id}/panes/navigate |
Move to a neighboring pane |
POST /api/sessions/{session_id}/panes/cycle |
Cycle panes |
POST /api/sessions/{session_id}/panes/swap |
Swap panes |
POST /api/sessions/{session_id}/layout |
Select a layout |
POST /api/sessions/{session_id}/layout/next |
Next layout |
Pane I/O
Section titled “Pane I/O”| Endpoint | Does |
|---|---|
POST /api/panes/{pane_id}/input |
Send input |
GET /api/panes/{pane_id}/output |
Read raw output |
GET /api/panes/{pane_id}/capture |
Capture the screen |
Agents
Section titled “Agents”| Endpoint | Does |
|---|---|
GET /api/agents |
List agents |
POST /api/panes/{pane_id}/prompt |
Prompt an agent |
GET /api/panes/{pane_id}/wait |
Wait for an agent |
GET /api/panes/{pane_id}/agent-status |
Explain an agent's status |
POST /api/panes/{pane_id}/agent-status |
Set an agent's status |
DELETE /api/panes/{pane_id}/agent-status |
Clear an agent's status |
GET /api/telemetry |
Agent usage |
GET /api/agent-limits |
Subscription limits |
Worktrees
Section titled “Worktrees”| Endpoint | Does |
|---|---|
POST /api/panes/{pane_id}/worktree |
Create a worktree |
DELETE /api/panes/{pane_id}/worktree |
Remove a worktree |
Popups
Section titled “Popups”| Endpoint | Does |
|---|---|
POST /api/panes/{pane_id}/popup |
Open a popup |
GET /api/panes/{pane_id}/popup/{id} |
Wait for a popup |
Events
Section titled “Events”| Endpoint | Does |
|---|---|
GET /api/events |
Stream events |
Notifications
Section titled “Notifications”| Endpoint | Does |
|---|---|
POST /api/notify |
Show a notification |
POST /api/panes/{pane_id}/notify |
Report an agent event |
DELETE /api/panes/{pane_id}/notify |
Clear a pane's notification |
Server
Section titled “Server”| Endpoint | Does |
|---|---|
GET /api/info |
Describe the server |
GET /api/system |
Describe the server host |
GET /api/health |
Check optional programs |
POST /api/server/upgrade |
Upgrade in place |
POST /api/server/shutdown |
Shut down the server |
GET /api/openapi.json |
This API's OpenAPI document |