CommandRM provides a REST API for programmatic access. All endpoints except authentication require a valid JWT token.
https://your-server:8080/api/v1
POST /api/v1/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "password"
}Response:
{
"access_token": "eyJ...",
"refresh_token": "eyJ...",
"expires_in": 900,
"user": {
"id": "uuid",
"username": "admin",
"email": "admin@example.com",
"is_admin": true,
"two_factor_enabled": false
}
}If 2FA is enabled, the response includes requires_2fa: true and you must complete login via /auth/2fa/login.
POST /api/v1/auth/refresh
Content-Type: application/json
{
"refresh_token": "eyJ..."
}Include the access token in the Authorization header:
Authorization: Bearer eyJ...GET /api/v1/agentsQuery parameters:
status- Filter by status:online,offline,pendinggroup_id- Filter by groupsearch- Search by name or hostnamepage- Page number (default: 1)page_size- Items per page (default: 20)
GET /api/v1/agents/{id}PUT /api/v1/agents/{id}
Content-Type: application/json
{
"name": "New Name",
"tags": ["production", "web"]
}DELETE /api/v1/agents/{id}GET /api/v1/agents/{id}/metrics?start=2024-01-01T00:00:00Z&end=2024-01-02T00:00:00ZGET /api/v1/agents/{id}/metrics/latestGET /api/v1/groupsPOST /api/v1/groups
Content-Type: application/json
{
"name": "Production Servers",
"description": "All production servers"
}PUT /api/v1/groups/{id}
Content-Type: application/json
{
"name": "Updated Name",
"description": "Updated description"
}DELETE /api/v1/groups/{id}POST /api/v1/groups/{id}/agents
Content-Type: application/json
{
"agent_ids": ["uuid1", "uuid2"]
}DELETE /api/v1/groups/{id}/agents/{agent_id}GET /api/v1/alert-rulesPOST /api/v1/alert-rules
Content-Type: application/json
{
"name": "High CPU",
"metric": "cpu_percent",
"operator": "gt",
"threshold": 90,
"duration_seconds": 300,
"severity": "warning",
"enabled": true
}Operators: gt (greater than), lt (less than), eq (equal), ne (not equal)
Severity levels: info, warning, critical
GET /api/v1/alerts?status=activeStatus options: active, acknowledged, resolved
POST /api/v1/alerts/{id}/acknowledgePOST /api/v1/alerts/{id}/resolveGET /api/v1/scripts?category=maintenance&language=bash&search=backupPOST /api/v1/scripts
Content-Type: application/json
{
"name": "Backup Script",
"description": "Backs up important files",
"language": "bash",
"category": "maintenance",
"content": "#!/bin/bash\ntar -czf backup.tar.gz /data",
"timeout_seconds": 300,
"run_as_admin": true,
"shared": true
}Languages: bash, powershell, python, batch
POST /api/v1/scripts/{id}/execute
Content-Type: application/json
{
"agent_ids": ["uuid1", "uuid2"],
"group_ids": ["group-uuid"]
}GET /api/v1/executions/{id}GET /api/v1/agents/{id}/inventory?package_manager=apt&search=nginxPOST /api/v1/agents/{id}/inventory/scan
Content-Type: application/json
{
"include_updates": true
}GET /api/v1/inventory?search=python&page=1&page_size=50GET /api/v1/inventory/statsResponse:
{
"total_packages": 15234,
"by_package_manager": {
"apt": 8521,
"chocolatey": 6713
},
"agents_with_outdated_packages": 12,
"total_outdated_packages": 156
}GET /api/v1/updates?severity=criticalPOST /api/v1/patches
Content-Type: application/json
{
"name": "January Security Updates",
"agent_ids": ["uuid1", "uuid2"],
"packages": ["openssl", "nginx"],
"reboot_policy": "if_required",
"scheduled_at": "2024-01-15T02:00:00Z"
}Reboot policies: never, if_required, always
POST /api/v1/patches/{id}/executeGET /api/v1/patches/{id}/resultsGET /api/v1/policies?policy_type=auto_update&enabled=truePolicy types: auto_update, scheduled_scan, script_schedule
POST /api/v1/policies
Content-Type: application/json
{
"name": "Daily Security Scan",
"policy_type": "scheduled_scan",
"schedule": {
"minute": "0",
"hour": "3",
"day_of_week": "*",
"day_of_month": "*"
},
"config": {
"include_updates": true
},
"target_type": "all",
"enabled": true
}POST /api/v1/policies/{id}/enable
POST /api/v1/policies/{id}/disableGET /api/v1/agents/{id}/files?path=/var/logGET /api/v1/agents/{id}/files/download?path=/var/log/syslogPOST /api/v1/agents/{id}/files/upload?path=/tmp/script.sh
Content-Type: multipart/form-data
file: [binary data]DELETE /api/v1/agents/{id}/files?path=/tmp/old-file.txtPOST /api/v1/agents/{id}/files/mkdir?path=/var/data/backupPOST /api/v1/agents/{id}/terminal
Content-Type: application/json
{
"rows": 24,
"cols": 80
}Response:
{
"session_id": "session-uuid",
"ws_url": "/api/v1/terminal/ws?session_id=session-uuid&token=..."
}DELETE /api/v1/terminal/{session_id}GET /api/v1/terminal/recordings?agent_id=uuid&page=1GET /api/v1/terminal/recordings/{id}/playbackReturns JSON Lines format with timestamped events.
POST /api/v1/agents/{id}/remote-desktop
Content-Type: application/json
{
"quality": "medium"
}Quality options: low, medium, high
DELETE /api/v1/agents/{id}/remote-desktop/{session_id}GET /api/v1/usersPOST /api/v1/users
Content-Type: application/json
{
"username": "newuser",
"email": "user@example.com",
"password": "SecurePassword123",
"is_admin": false
}PUT /api/v1/users/{id}
Content-Type: application/json
{
"email": "newemail@example.com",
"is_admin": true
}DELETE /api/v1/users/{id}POST /api/v1/auth/2fa/setupResponse:
{
"secret": "JBSWY3DPEHPK3PXP",
"qr_code": "data:image/png;base64,..."
}POST /api/v1/auth/2fa/verify
Content-Type: application/json
{
"code": "123456"
}Response includes backup codes.
POST /api/v1/auth/2fa/login
Content-Type: application/json
{
"code": "123456"
}POST /api/v1/auth/2fa/disable
Content-Type: application/json
{
"password": "current-password"
}GET /api/v1/enrollment-keysPOST /api/v1/enrollment-keys
Content-Type: application/json
{
"description": "Production servers",
"expires_at": "2024-12-31T23:59:59Z",
"max_uses": 100
}DELETE /api/v1/enrollment-keys/{id}GET /api/v1/audit-logs?action=delete&resource=agent&page=1GET /api/v1/audit-logs/{id}GET /api/v1/dashboard/statsResponse:
{
"total_agents": 150,
"online_agents": 142,
"offline_agents": 8,
"pending_agents": 0,
"active_alerts": 3,
"recent_activity": [...]
}GET /api/v1/versionResponse:
{
"version": "1.0.0",
"channel": "stable",
"build_time": "2024-01-15T10:30:00Z",
"git_commit": "abc123",
"min_agent_version": "1.0.0"
}GET /api/v1/updates/availableGET /healthGET /readyChecks database connectivity.
All errors follow this format:
{
"error": "Error message",
"code": "ERROR_CODE",
"details": {}
}Common HTTP status codes:
400- Bad Request (validation error)401- Unauthorized (missing/invalid token)403- Forbidden (insufficient permissions)404- Not Found429- Too Many Requests (rate limited)500- Internal Server Error
- General API: 100 requests/minute
- Login endpoint: 5 requests/minute
Rate limit headers are included in responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1705315200