Create Exec Instance
Path Parameters
The container ID or name
Query Parameters
The environment ID where the container is located
Request Body
The shell to execute. Common values:
/bin/sh- Bourne shell (most compatible)/bin/bash- Bash shell/bin/zsh- Z shell/bin/ash- Almquist shell (Alpine Linux)
The user to run the command as. Can be:
- Username (e.g., “root”, “www-data”)
- UID (e.g., “1000”)
- UID:GID (e.g., “1000:1000”)
Response
The ID of the created exec instance. Use this with a WebSocket connection to interact with the terminal.
Error Responses
Error message if the request fails
200- Exec instance created successfully401- Unauthorized (authentication required)403- Permission denied500- Failed to create exec instance
Example
Response Example
Using the Exec Instance
After creating an exec instance, establish a WebSocket connection to interact with the terminal:WebSocket Connection
Connect to the exec instance using a WebSocket:- Bidirectional communication: Send commands and receive output
- Terminal control sequences: Full terminal emulation support
- Real-time interaction: Interactive shell experience
Terminal Interaction
Once connected:- Send terminal input through the WebSocket (keyboard input, control sequences)
- Receive terminal output through the WebSocket (command output, prompts)
- Handle terminal resize events by sending resize commands
- Close the WebSocket when done to terminate the session
Example Terminal Session
Terminal Resize
To resize the terminal (e.g., when the user’s window changes size), send a resize request:h: Height in rows (e.g., 24)w: Width in columns (e.g., 80)envId: Environment ID
Notes
- The exec instance is created with TTY and stdin enabled for interactive use
- Each exec instance is single-use - create a new one for each terminal session
- The WebSocket connection must be established promptly after creating the exec instance
- Closing the WebSocket terminates the exec session
- All terminal emulation features are supported (colors, cursor movement, etc.)
- The default shell
/bin/shis the most portable across different container images
