Execute command in VM instance
Command & File Operations
Execute Command
Executes shell commands on VM instances and returns output with file change tracking.
POST
Execute command in VM instance
Executes shell commands within VM instances and returns output with comprehensive file change tracking. This is the core endpoint for running code, scripts, and system commands in your development environments.Documentation Index
Fetch the complete documentation index at: https://docs.gentility.ai/llms.txt
Use this file to discover all available pages before exploring further.
Request Body
command field accepts any valid shell command that can be executed within the VM environment.
Use Cases
- Code Execution: Run Python scripts, Node.js applications, shell scripts
- Package Installation: Install dependencies with npm, pip, apt, etc.
- File Manipulation: Create, edit, and organize files and directories
- Data Processing: Execute data analysis, transformations, and exports
- Development Tasks: Build projects, run tests, compile code
Response Structure
The response includes detailed information about command execution and any files that were changed:Successful Command Execution
Command with Output
Command Failure
File Change Tracking
The API automatically tracks file changes during command execution:File Change Types
created- New files that were createdmodified- Existing files that were changeddeleted- Files that were removed
File Metadata
- path: Full path to the changed file
- size: File size in bytes
- mime_type: Detected MIME type (e.g.,
image/png,text/plain) - public_url: Direct URL to access the file without authentication
Long-running Commands
Commands have reasonable timeout limits, but for very long-running processes:- Use background processes with
nohuporscreen - Break large tasks into smaller steps
- Consider using interim file outputs to track progress
Example Commands
Python Data Analysis
Node.js Package Installation
Git Operations
File Processing
Error Handling
Always check theexit_code and status fields:
exit_code: 0andstatus: "success"- Command executed successfullyexit_code: non-zeroandstatus: "error"- Command failed- Check the
outputfield for error messages and debugging information
Best Practices
- Command Composition: Chain multiple commands with
&&for conditional execution - Output Redirection: Use
>and>>to capture output to files - Error Handling: Check exit codes before proceeding with dependent operations
- Resource Management: Be mindful of CPU and memory usage for intensive operations
- File Organization: Use descriptive paths and organize outputs in logical directories
Authorizations
API key authentication using Bearer token format: 'Bearer rk_live_'
Path Parameters
UUID of the profile
Room identifier
Body
application/json
Shell command to execute
Example:
"python -c 'print(\"Hello World\")'"