Skip to content

The Terminal Session Management API provides endpoints for listing, creating, inspecting, and destroying terminal sessions, connecting to them via WebSocket, retrieving command history and raw output, and capturing screenshots of the terminal buffer.


Returns a JSON array of all active terminal sessions with session metadata and recent command history (best-effort).

NameInTypeRequiredDescription
history_limitqueryintegerNoMax command_history entries to include per session (default: 50, max: 1000)
history_linesqueryintegerNoAlias of history_limit
sessions = client.terminal.sessions.listIterator(
history_limit=50,
)
[
{
"id": 1,
"shell": "bash",
"cwd": "/home/user",
"started_at": "2025-01-15T10:30:00Z",
"command_history": [
"ls -la",
"cd projects",
"git status"
]
},
{
"id": 2,
"shell": "zsh",
"cwd": "/var/log",
"started_at": "2025-01-15T11:00:00Z",
"command_history": [
"tail -f syslog"
]
}
]

Create a new terminal session or return success if it already exists. By default, when a Hoody Display is configured, the endpoint blocks until the display TCP port (4000 + display_number) is accepting connections, ensuring the caller can immediately use the display after the response.

FieldTypeRequiredDescription
terminal_idstringNoTerminal session ID (numeric 1-65535). Required unless ephemeral is true, in which case it is auto-generated (range 40000-65535).
ephemeralbooleanNoAuto-generate terminal ID and enable ephemeral session mode. Ephemeral sessions auto-clean after idle timeout and strip DISPLAY environment. (default: false)
displaystringNoX11 display number (e.g., "1" or ":1"). Sets the DISPLAY env var and enables Hoody Display readiness waiting.
shellstringNoShell to use (bash/zsh/fish/sh). Ignored for SSH sessions.
userstringNoSystem user to spawn the shell as. Ignored for SSH sessions.
cwdstringNoWorking directory for the terminal. Ignored for SSH sessions.
startup_scriptstringNoPath to startup script to run
welcomebooleanNoShow welcome message on startup (default: false)
debugbooleanNoEnable debug output in wrapper script (default: false)
desktopbooleanNoEnable Hoody Display desktop mode. Provides a full desktop environment instead of seamless individual windows (default: false)
desktop_envstringNoDesktop environment to launch (implies desktop=true). Valid values: xfce, mate
colsintegerNoTerminal columns (default: 80)
rowsintegerNoTerminal rows (default: 24)
wait_until_displaybooleanNoWhether to wait for Hoody Display readiness (default: true when display is configured)
wait_timeoutintegerNoTimeout in seconds for waiting (default: 300)
ssh_hoststringNoSSH hostname/IP. Required together with ssh_user for SSH sessions.
ssh_userstringNoSSH username. Required together with ssh_host for SSH sessions.
ssh_portstringNoSSH port (default: 22)
ssh_passwordstringNoSSH password. Cannot contain shell-dangerous characters.
ssh_keystringNoBase64-encoded SSH private key (PEM format)
socks5_hoststringNoSOCKS5 proxy hostname/IP for routing SSH connections
socks5_portstringNoSOCKS5 proxy port (default: 1080)
socks5_userstringNoSOCKS5 proxy authentication username
socks5_passstringNoSOCKS5 proxy authentication password
{
"terminal_id": "5",
"display": "5",
"shell": "bash",
"user": "user",
"cwd": "/home/user",
"welcome": false,
"cols": 80,
"rows": 24
}
session = client.terminal.sessions.create(
data={
"terminal_id": "5",
"display": "5",
"shell": "bash",
"cwd": "/home/user",
}
)
{
"status": "created",
"terminal_id": 5,
"display": ":5",
"shell": "bash"
}

Completely destroy and remove a terminal session. This kills any running process, frees all resources, and removes the session from memory. Clients will be disconnected. Use this to cleanly terminate sessions without waiting for idle timeout.

NameInTypeRequiredDescription
terminal_idpathstringYesTerminal session ID to delete (numeric 1-65535)
result = client.terminal.sessions.delete(terminal_id="5")
{
"status": "deleted",
"terminal_id": 5
}

Establishes a WebSocket connection for real-time bidirectional terminal I/O. Multiple clients can share the same terminal session using the same terminal_id. The protocol uses efficient binary framing where the first byte indicates message type (0-4 for commands, specific bytes for data). Supports session sharing, read-only mode, SSH connections, PID attachment, and comprehensive terminal features.

NameInTypeRequiredDescription
terminal_idquerystringNoTerminal session ID (numeric 1-65535, auto-generated if not provided) - Multiple clients can share by using same ID
readonlyquerybooleanNoEnable read-only mode for this client (blocks keyboard input) - Use 'true', '1', or no value
cwdquerystringNoWorking directory for new sessions
cwd_auto_createquerybooleanNoAuto-create cwd when the requested working directory does not exist yet. Only applies when cwd is explicitly provided for a new local session. Enable with 'true', '1', or no value (default: false)
shellquerystringNoShell to use (bash, zsh, fish, tmux, ssh, etc.)
userquerystringNoSystem user to spawn shell as (requires permissions)
cmdquerystringNoBase64-encoded command to auto-execute on spawn
envquerystringNoEnvironment variable KEY=VALUE (repeatable)
displayquerystringNoDISPLAY variable for X11 apps (auto-formats :N)
pidqueryintegerNoAttach to existing process PID for monitoring
ssh_hostquerystringNoSSH server hostname/IP for remote connections
ssh_userquerystringNoSSH username (required if ssh_host provided)
ssh_portquerystringNoSSH port (default: 22)
ssh_passwordquerystringNoSSH password (use with caution)
socks5_hostquerystringNoSOCKS5 proxy for SSH
socks5_portquerystringNoSOCKS5 port (default: 1080)
ws = client.terminal.sessions.connectWebSocket(
terminal_id="5",
shell="bash",
cwd="/home/user",
)
"Switching Protocols"

GET /api/v1/terminal/history/{terminal_id}

Section titled “GET /api/v1/terminal/history/{terminal_id}”

Retrieve the execution history for a specific terminal session, including all commands executed and their status.

NameInTypeRequiredDescription
terminal_idpathstringYesTerminal session ID (numeric 1-65535, can also be provided as query parameter)
history = client.terminal.sessions.listHistoryIterator(terminal_id="5")
{
"description": "Command history for the terminal session"
}

Retrieve the raw terminal output buffer for a terminal session. Supports multiple output formats via the format query parameter. Defaults to text/download format if format parameter is not provided.

NameInTypeRequiredDescription
terminal_idquerystringNoTerminal session ID (numeric 1-65535, defaults to "1" if not provided)
formatquerystringNoOutput format: download, text, or html (defaults to "download" if not provided)
tailqueryintegerNoReturn only the last N lines of output
output = client.terminal.sessions.getRawOutput(
terminal_id="5",
format="text",
tail=100,
)
{
"type": "application/octet-stream",
"content": "Terminal output buffer as binary text"
}

Convert the terminal’s ANSI output buffer to an image with customizable styling. Screenshots are automatically saved to /hoody/storage/hoody-terminal/screenshots/{terminal_id}/ with timestamp as filename.

NameInTypeRequiredDescription
terminal_idquerystringYesTerminal session ID (numeric 1-65535)
formatquerystringNoOutput format: png, jpeg, gif (default: png)
foregroundquerystringNoForeground color: black, red, green, yellow, blue, magenta, cyan, white, or RGB (R,G,B,A) (default: white)
backgroundquerystringNoBackground color: same as foreground options (default: black)
fontsizequeryintegerNoFont size in pixels (default: 20)
savequerybooleanNoSave to storage directory (default: true)
screenshot = client.terminal.sessions.captureScreenshot(
terminal_id="5",
format="png",
foreground="white",
background="black",
fontsize=20,
save=True,
)
{
"type": "image/gif",
"X-Screenshot-Path": "/hoody/storage/hoody-terminal/screenshots/5/2025-01-15_10-30-45.gif"
}