REST API · v1.0

API Reference

Complete endpoint documentation with request schemas, response examples, and notes.

Base URLhttps://rca-backend-5jlv.onrender.com
!
Authentication

Include your API key as a header: Authorization: Bearer YOUR_API_KEY. API keys are generated in Settings → API Keys after sign up.

Sensor

POST/api/sensor/ingest

Ingest a single sensor reading. Returns ensemble score, severity, is_anomaly flag, and workflow_id if RCA was triggered.

Request
{
  "machine_id": "eq-001",       // string, required
  "air_temperature": 298.1,     // number (K), required
  "process_temperature": 308.6, // number (K), required
  "rotational_speed": 1551,     // number (RPM), required
  "torque": 42.8,               // number (Nm), required
  "tool_wear": 0,               // number (min), required
  "machine_type": "M"           // "H" | "L" | "M", required
}
Response
{
  "reading_id": "rdg_abc123",
  "ensemble_score": 0.73,
  "is_anomaly": true,
  "severity": "high",
  "workflow_id": "wf_def456",   // present if RCA triggered
  "timestamp": "2026-05-05T10:22:00Z"
}
GET/api/sensors/history

Retrieve reading history for a given equipment ID. Supports limit and hours query parameters.

Request
GET /api/sensors/history?machine_id=eq-001&hours=24&limit=100
Response
{
  "readings": [
    {
      "reading_id": "rdg_abc123",
      "ensemble_score": 0.73,
      "is_anomaly": true,
      "severity": "high",
      "timestamp": "2026-05-05T10:22:00Z"
    }
  ],
  "total": 47
}

Equipment

GET/api/equipment

List all registered equipment with current health scores, anomaly counts, and status.

Request
GET /api/equipment
Response
{
  "equipment": [
    {
      "id": "eq-001",
      "name": "CNC Mill 01",
      "machine_type": "M",
      "health_score": 82,
      "status": "warning",
      "anomaly_count": 3,
      "last_reading": "2026-05-05T10:22:00Z"
    }
  ]
}
POST/api/equipment

Register a new piece of equipment.

Request
{
  "name": "CNC Mill 01",
  "machine_type": "M",   // "H" | "L" | "M"
  "location": "Bay 3"   // optional
}
Response
{
  "id": "eq-001",
  "name": "CNC Mill 01",
  "machine_type": "M",
  "health_score": 100,
  "status": "normal",
  "created_at": "2026-05-05T09:00:00Z"
}

Alerts

GET/api/alerts

List active alerts. Filter by severity (critical | high | medium) and acknowledged status.

Request
GET /api/alerts?severity=critical&acknowledged=false
Response
{
  "alerts": [
    {
      "id": "alt_xyz789",
      "machine_id": "eq-001",
      "severity": "critical",
      "ensemble_score": 0.91,
      "message": "Probable heat dissipation failure",
      "acknowledged": false,
      "timestamp": "2026-05-05T10:22:00Z"
    }
  ],
  "total": 1
}
PATCH/api/alerts/{id}/acknowledge

Acknowledge an alert by ID. Removes it from the active alerts count.

Request
PATCH /api/alerts/alt_xyz789/acknowledge
Response
{
  "id": "alt_xyz789",
  "acknowledged": true,
  "acknowledged_at": "2026-05-05T10:35:00Z"
}

Dashboard

GET/api/dashboard/summary

Fleet overview — total equipment, active alerts by severity, anomalies in last 24h, open maintenance tasks.

Request
GET /api/dashboard/summary
Response
{
  "total_equipment": 12,
  "active_alerts": {
    "critical": 1,
    "high": 3,
    "medium": 7
  },
  "anomalies_24h": 14,
  "open_maintenance_tasks": 5,
  "fleet_health_avg": 78
}

Maintenance

GET/api/maintenance/tasks

List all maintenance tasks with status. Filter by status (open | in_progress | done) and machine_id.

Request
GET /api/maintenance/tasks?status=open
Response
{
  "tasks": [
    {
      "id": "tsk_001",
      "machine_id": "eq-001",
      "title": "Inspect bearing — probable wear",
      "priority": "high",
      "status": "open",
      "rca_id": "wf_def456",
      "created_at": "2026-05-05T10:23:00Z"
    }
  ]
}
POST/api/maintenance/history

Log a completed maintenance event. Feeds the Learning Agent for continuous improvement.

Request
{
  "machine_id": "eq-001",
  "task_id": "tsk_001",
  "action_taken": "Replaced bearing unit B-12",
  "confirmed_root_cause": "bearing_wear",
  "technician": "J. Smith",
  "completed_at": "2026-05-05T14:00:00Z"
}
Response
{
  "history_id": "hst_001",
  "status": "logged",
  "learning_agent_updated": true
}