Endpoint
Copy
POST {sandbox_public_host}/commands/run
Authentication
Copy
Authorization: Bearer {auth_token}
Request
Request Body
Copy
{
"command": "ls -la /workspace",
"timeout": 30,
"working_dir": "/workspace",
"env": {
"API_KEY": "sk-test-123"
}
}
Response
Copy
{
"stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Jan 15 10:30 .",
"stderr": "",
"exit_code": 0,
"execution_time": 0.045
}
Examples
cURL
Copy
curl -X POST https://1761048129dsaqav4n.hopx.dev/commands/run \
-H "Authorization: Bearer {auth_token}" \
-H "Content-Type: application/json" \
-d '{
"command": "ls -la /workspace",
"timeout": 30
}'
Python
Copy
import requests
data = {
"command": "ls -la /workspace",
"timeout": 30,
"working_dir": "/workspace"
}
response = requests.post(
f"{sandbox_public_host}/commands/run",
headers={"Authorization": f"Bearer {auth_token}"},
json=data
)
result = response.json()
print(f"Output: {result['stdout']}")
print(f"Exit code: {result['exit_code']}")
JavaScript
Copy
const response = await fetch(`${sandboxPublicHost}/commands/run`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${authToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'ls -la /workspace',
timeout: 30
})
});
const result = await response.json();
console.log(`Output: ${result.stdout}`);
console.log(`Exit code: ${result.exit_code}`);
Related
- Code Execution - Execute code
- File Operations - File operations

