The Unified RTPI API provides a RESTful interface for managing red team operations, including target management, agent deployment, vulnerability tracking, and operational orchestration. The API uses JSON for request and response bodies and implements role-based access control (RBAC) for secure operations.
Base URL: http://localhost:3000/api/v1
API Version: v1
The RTPI API supports two authentication methods:
Traditional username and password authentication with session-based cookies.
OAuth authentication via Google for streamlined user access.
All API endpoints (except authentication endpoints) require a valid session. Sessions are managed using Redis and express-session with the following characteristics:
- Session Duration: Configurable via environment variables
- Cookie Settings: HttpOnly, Secure (in production), SameSite
- Session Storage: Redis for distributed session management
The API implements role-based access control with three roles:
- Admin: Full access to all endpoints and operations
- Operator: Access to operational endpoints, limited administrative access
- Viewer: Read-only access to most resources
All API responses follow a consistent JSON format:
{
"success": true,
"data": { ... },
"message": "Operation completed successfully"
}{
"error": "Error message description",
"code": "ERROR_CODE",
"details": { ... }
}{
"items": [...],
"pagination": {
"page": 1,
"pageSize": 50,
"total": 150
}
}200 OK- Request succeeded201 Created- Resource created successfully204 No Content- Request succeeded with no response body400 Bad Request- Invalid request parameters401 Unauthorized- Authentication required403 Forbidden- Insufficient permissions404 Not Found- Resource not found409 Conflict- Resource conflict (e.g., duplicate)422 Unprocessable Entity- Validation error429 Too Many Requests- Rate limit exceeded500 Internal Server Error- Server error503 Service Unavailable- Service temporarily unavailable
Common error codes returned in the code field:
AUTH_REQUIRED- Authentication requiredINVALID_CREDENTIALS- Invalid username or passwordINSUFFICIENT_PERMISSIONS- User lacks required permissionsRESOURCE_NOT_FOUND- Requested resource not foundVALIDATION_ERROR- Request validation failedRATE_LIMIT_EXCEEDED- Too many requestsINTERNAL_ERROR- Internal server error
API endpoints are protected by rate limiting to prevent abuse:
- Authentication endpoints: 5 requests per 15 minutes per IP
- Password change: 3 requests per 15 minutes per user
- General API endpoints: 100 requests per 15 minutes per user
When rate limit is exceeded, the API returns a 429 Too Many Requests response with a Retry-After header.
GET /api/v1/auth/csrf-tokenReturns a CSRF token required for state-changing operations.
Response:
{
"csrfToken": "abc123..."
}POST /api/v1/auth/loginAuthenticate with username and password.
Request Body:
{
"username": "admin",
"password": "SecurePassword123!"
}Response:
{
"success": true,
"user": {
"id": "user_123",
"username": "admin",
"email": "admin@example.com",
"role": "admin",
"authMethod": "local"
}
}Rate Limit: 5 requests per 15 minutes
GET /api/v1/auth/googleInitiates Google OAuth flow. Redirects to Google authentication.
OAuth Callback:
GET /api/v1/auth/google/callbackHandles OAuth callback from Google. On success, redirects to dashboard.
POST /api/v1/auth/logoutTerminates the current session.
Response:
{
"success": true,
"message": "Logged out successfully"
}GET /api/v1/auth/meReturns information about the currently authenticated user.
Response:
{
"user": {
"id": "user_123",
"username": "admin",
"email": "admin@example.com",
"role": "admin",
"authMethod": "local",
"isActive": true,
"mustChangePassword": false,
"lastLogin": "2025-01-11T09:15:30Z",
"createdAt": "2024-01-01T00:00:00Z"
}
}PUT /api/v1/auth/passwordChanges the current user's password.
Request Body:
{
"currentPassword": "OldPassword123!",
"newPassword": "NewSecurePassword456!"
}Password Requirements:
- Minimum 12 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- At least one special character (@$!%*?&)
- Cannot reuse last 5 passwords
Response:
{
"success": true,
"message": "Password changed successfully"
}Rate Limit: 3 requests per 15 minutes
GET /api/v1/targetsReturns a list of all targets.
Required Role: Authenticated user
Response:
{
"targets": [
{
"id": "target_001",
"name": "Production Server",
"ipAddress": "192.168.1.100",
"hostname": "prod-server-01",
"osType": "Linux",
"status": "active",
"createdAt": "2025-01-01T00:00:00Z",
"updatedAt": "2025-01-11T09:00:00Z"
}
]
}GET /api/v1/targets/:idReturns detailed information about a specific target.
Required Role: Authenticated user
Response:
{
"target": {
"id": "target_001",
"name": "Production Server",
"ipAddress": "192.168.1.100",
"hostname": "prod-server-01",
"osType": "Linux",
"status": "active",
"ports": [22, 80, 443],
"services": ["ssh", "http", "https"],
"vulnerabilities": ["CVE-2024-1234"],
"notes": "Critical infrastructure component",
"createdAt": "2025-01-01T00:00:00Z",
"updatedAt": "2025-01-11T09:00:00Z"
}
}POST /api/v1/targetsCreates a new target.
Required Role: Admin or Operator
Request Body:
{
"name": "New Target Server",
"ipAddress": "192.168.1.101",
"hostname": "new-server-01",
"osType": "Linux",
"ports": [22, 80, 443],
"notes": "Development environment"
}Response:
{
"target": {
"id": "target_002",
"name": "New Target Server",
"ipAddress": "192.168.1.101",
"hostname": "new-server-01",
"osType": "Linux",
"status": "pending",
"ports": [22, 80, 443],
"createdAt": "2025-01-11T09:30:00Z",
"updatedAt": "2025-01-11T09:30:00Z"
}
}Status Code: 201 Created
PUT /api/v1/targets/:idUpdates an existing target.
Required Role: Admin or Operator
Request Body:
{
"name": "Updated Server Name",
"status": "active",
"notes": "Updated notes"
}Response:
{
"target": {
"id": "target_002",
"name": "Updated Server Name",
"status": "active",
"updatedAt": "2025-01-11T09:35:00Z"
}
}DELETE /api/v1/targets/:idDeletes a target.
Required Role: Admin
Response:
{
"message": "Target deleted successfully"
}Status Code: 200 OK
POST /api/v1/targets/:id/scanInitiates a scan operation on the specified target.
Required Role: Admin or Operator
Request Body:
{
"scanType": "full",
"options": {
"portRange": "1-65535",
"intensity": "aggressive"
}
}Response:
{
"message": "Scan initiated",
"targetId": "target_001",
"scanId": "scan_123"
}GET /api/v1/agentsReturns a list of all deployed agents.
Required Role: Authenticated user
Response:
{
"agents": [
{
"id": "agent_001",
"name": "Agent Alpha",
"type": "beacon",
"status": "active",
"targetId": "target_001",
"lastSeen": "2025-01-11T09:30:00Z",
"capabilities": ["shell", "file-transfer", "screenshot"]
}
]
}GET /api/v1/agents/:idReturns detailed information about a specific agent.
POST /api/v1/agentsDeploys a new agent to a target.
Required Role: Admin or Operator
PUT /api/v1/agents/:idUpdates agent configuration.
Required Role: Admin or Operator
DELETE /api/v1/agents/:idRemoves an agent.
Required Role: Admin
GET /api/v1/containersReturns a list of all containers.
GET /api/v1/containers/:idReturns detailed information about a container.
POST /api/v1/containersCreates a new container.
Required Role: Admin or Operator
POST /api/v1/containers/:id/startStarts a stopped container.
POST /api/v1/containers/:id/stopStops a running container.
DELETE /api/v1/containers/:idDeletes a container.
Required Role: Admin
GET /api/v1/devicesReturns a list of all managed devices.
GET /api/v1/devices/:idReturns detailed information about a device.
POST /api/v1/devicesRegisters a new device.
PUT /api/v1/devices/:idUpdates device information.
DELETE /api/v1/devices/:idUnregisters a device.
GET /api/v1/mcp-serversReturns a list of all MCP (Model Context Protocol) servers.
GET /api/v1/mcp-servers/:idReturns detailed information about an MCP server.
POST /api/v1/mcp-serversRegisters a new MCP server.
PUT /api/v1/mcp-servers/:idUpdates MCP server configuration.
DELETE /api/v1/mcp-servers/:idRemoves an MCP server.
GET /api/v1/operationsReturns a list of all operations.
GET /api/v1/operations/:idReturns detailed information about an operation.
POST /api/v1/operationsCreates a new operation.
Required Role: Admin or Operator
PUT /api/v1/operations/:idUpdates an operation.
POST /api/v1/operations/:id/closeCloses an active operation.
GET /api/v1/vulnerabilitiesReturns a list of all discovered vulnerabilities.
GET /api/v1/vulnerabilities/:idReturns detailed information about a vulnerability.
POST /api/v1/vulnerabilitiesReports a new vulnerability.
PUT /api/v1/vulnerabilities/:idUpdates vulnerability information.
POST /api/v1/vulnerabilities/:id/fixMarks a vulnerability as fixed.
GET /api/v1/health-checksReturns overall system health status.
Response:
{
"status": "healthy",
"components": {
"database": "healthy",
"redis": "healthy",
"disk": "healthy",
"memory": "healthy"
},
"timestamp": "2025-01-11T09:30:00Z"
}GET /api/v1/health-checks/databaseReturns database health status.
GET /api/v1/health-checks/redisReturns Redis cache health status.
The RTPI platform provides real-time updates via WebSocket connections.
const ws = new WebSocket('ws://localhost:3000/ws');WebSocket connections are authenticated using the session cookie from HTTP authentication.
All WebSocket messages follow this format:
{
"type": "EVENT_TYPE",
"data": { ... },
"timestamp": "2025-01-11T09:30:00Z"
}agent.status- Agent status updatestarget.scan.progress- Scan progress updatesoperation.update- Operation status changesvulnerability.discovered- New vulnerability discoveredsystem.alert- System alerts and notifications
{
"type": "agent.status",
"data": {
"agentId": "agent_001",
"status": "active",
"lastSeen": "2025-01-11T09:30:00Z"
},
"timestamp": "2025-01-11T09:30:00Z"
}// Authenticate
const response = await fetch('http://localhost:3000/api/v1/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'admin',
password: 'password123',
}),
credentials: 'include', // Important for session cookies
});
const data = await response.json();
console.log('Logged in:', data.user);
// List targets
const targetsResponse = await fetch('http://localhost:3000/api/v1/targets', {
credentials: 'include',
});
const targets = await targetsResponse.json();
console.log('Targets:', targets);import requests
# Create session for cookie persistence
session = requests.Session()
# Authenticate
response = session.post(
'http://localhost:3000/api/v1/auth/login',
json={
'username': 'admin',
'password': 'password123'
}
)
user = response.json()['user']
print(f"Logged in as: {user['username']}")
# List targets
targets_response = session.get('http://localhost:3000/api/v1/targets')
targets = targets_response.json()['targets']
print(f"Found {len(targets)} targets")# Login and save cookies
curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"password123"}' \
-c cookies.txt
# List targets using saved cookies
curl http://localhost:3000/api/v1/targets \
-b cookies.txt- HTTPS Required in Production: Always use HTTPS in production environments
- CSRF Protection: Include CSRF token in state-changing requests
- Rate Limiting: Respect rate limits to avoid account lockouts
- Session Management: Sessions expire after inactivity
- Audit Logging: All operations are logged for security audit trails
- Role-Based Access: Ensure users have minimum required permissions
- Password Requirements: Enforce strong password policies
- OAuth Scopes: Limit OAuth scopes to required permissions only
For API support and questions:
- Review the main README.md
- Check the Development Guide
- Consult the Deployment Guide