WebSocket API
Real-time communication with agents.
Connection
Agent WebSocket
wss://your-server.com/api/v1/ws/agents/{uuid}Requires mTLS authentication with agent certificate.
Frontend WebSocket
wss://your-server.com/api/v1/ws/dashboard
Authorization: Bearer YOUR_TOKENMessage Format
All messages are JSON:
json
{
"type": "message_type",
"data": { ... },
"timestamp": "2024-01-15T10:30:00Z"
}Agent Messages
Heartbeat
json
{
"type": "heartbeat",
"data": {
"cpu_usage": 25.5,
"memory_usage": 50.0,
"uptime": 86400
}
}Command Response
json
{
"type": "command_response",
"data": {
"command_id": "cmd-uuid",
"status": "success",
"output": "command output here",
"exit_code": 0
}
}Inventory Data
json
{
"type": "inventory",
"data": {
"scan_type": "software",
"items": [ ... ]
}
}Server Commands
Run Command
json
{
"type": "run_command",
"data": {
"command": "hostname",
"timeout": 30
}
}Start Terminal
json
{
"type": "terminal_start",
"data": {
"cols": 80,
"rows": 24
}
}File Transfer
json
{
"type": "upload_file",
"data": {
"path": "/tmp/file.txt",
"content": "base64_encoded_content"
}
}Error Handling
json
{
"type": "error",
"data": {
"code": "COMMAND_FAILED",
"message": "Command execution failed",
"details": { ... }
}
}