Skip to content

Server API

The EasyShell server exposes a RESTful API on port 18080. All endpoints require authentication unless otherwise noted.

All API requests must include a valid session token obtained via the login endpoint.

Terminal window
# Login and obtain token
curl -X POST http://localhost:18080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin123"}'

Response:

{
"code": 200,
"data": {
"token": "eyJhbGciOiJIUzI1NiJ9...",
"user": {
"id": 1,
"username": "admin",
"role": "ADMIN"
}
}
}

Include the token in subsequent requests:

Terminal window
curl -H "Authorization: Bearer <token>" http://localhost:18080/api/hosts
GET /api/hosts

Query parameters:

ParameterTypeDefaultDescription
pagenumber0Page number (zero-based)
sizenumber20Page size
searchstringFilter by hostname or IP
statusstringFilter by status: ONLINE, OFFLINE, WARNING
clusterIdnumberFilter by cluster ID
GET /api/hosts/{id}

Returns host information including system info, agent status, resource metrics, and tags.

POST /api/hosts
{
"hostname": "web-server-01",
"ip": "192.168.1.100",
"sshPort": 22,
"authType": "PASSWORD",
"username": "root",
"password": "...",
"tags": { "env": "production", "role": "web" }
}
DELETE /api/hosts/{id}
GET /api/scripts

Query parameters:

ParameterTypeDescription
pagenumberPage number
sizenumberPage size
typestringScript type: BASH, PYTHON, POWERSHELL
categorystringCategory filter
POST /api/scripts
{
"name": "Check Disk Usage",
"description": "Reports disk usage across all mounted filesystems",
"type": "BASH",
"content": "#!/bin/bash\ndf -h | grep -v tmpfs",
"timeout": 30,
"tags": ["monitoring", "disk"]
}
POST /api/scripts/{id}/execute
{
"hostIds": [1, 2, 3],
"params": {
"threshold": "80"
},
"async": true
}

Response:

{
"code": 200,
"data": {
"taskId": "task_20260220_001",
"status": "RUNNING",
"hostCount": 3
}
}
GET /api/tasks/{taskId}

Returns the overall task status and per-host execution results.

GET /api/tasks/{taskId}/logs

Query parameters:

ParameterTypeDescription
hostIdnumberFilter logs by specific host
followbooleanStream logs in real-time (SSE)
GET /api/clusters
POST /api/clusters
{
"name": "Production Web Servers",
"description": "All production web server instances",
"hostIds": [1, 2, 5, 8]
}
POST /api/clusters/{id}/execute
{
"scriptId": 10,
"params": {},
"strategy": "PARALLEL"
}

Execution strategies:

StrategyDescription
PARALLELExecute on all hosts simultaneously
SEQUENTIALExecute one host at a time, stop on failure
ROLLINGExecute in batches with configurable batch size
GET /api/users
POST /api/users
{
"username": "operator",
"password": "securePassword123",
"role": "OPERATOR",
"email": "[email protected]"
}

All API responses follow a consistent format:

{
"code": 200,
"message": "success",
"data": { ... }
}

Error responses:

{
"code": 400,
"message": "Validation failed",
"errors": [
{ "field": "hostname", "message": "must not be blank" }
]
}

Common HTTP status codes:

CodeMeaning
200Success
201Created
400Bad Request — validation error
401Unauthorized — missing or invalid token
403Forbidden — insufficient permissions
404Not Found
500Internal Server Error