API Documentation
REST API Overview
The RACE Management Console provides a comprehensive REST API for programmatic access to all system functionality. All endpoints return JSON responses and use standard HTTP status codes.
Base Configuration
Base URL
https://your-domain.com/api
Content Type
Content-Type: application/json
Response Format
All responses are JSON formatted with consistent structure
Authentication
Session-Based
Current implementation uses session-based authentication through the web interface.
Future Enhancements
- API Key authentication
- JWT token-based access
- OAuth2 integration
API Endpoints
Template Management
/api/templates
Get All Templates
Retrieve all rule templates with optional filtering
/api/templates
Create Template
Create a new rule template with placeholders
/api/templates/{id}
Update Template
Update existing template (if not deployed)
/api/templates/{id}
Delete Template
Remove template (if no deployed instances)
Instance Management
/api/instances
Get All Instances
Retrieve all template instances with status
/api/instances
Create Instance
Create new template instance with mappings
/api/instances/{id}/deploy
Deploy Instance
Activate instance for runtime execution
/api/instances/{id}/undeploy
Undeploy Instance
Deactivate instance and close active events
Event Management
/api/rule-events
Get Events
Retrieve events with filtering and pagination
/api/rule-events/{id}
Update Event
Modify event details or close event
/api/rule-events/{id}/close
Close Event
Manually close an active event
/api/rule-events/{id}
Delete Event
Remove event from system (with audit trail)
Monitoring & System
/api/streams/active
Active Streams
Get all actively monitored data streams
/api/system-tags
System Tags
Get available system tags and current values
/api/packages
Get Packages
Retrieve all template packages
/api/plant-model
Plant Model
Get ISA-95 plant hierarchy structure
Request/Response Examples
Creating a Template
Request:
POST /api/templates
Content-Type: application/json
{
"name": "Equipment Health Monitor",
"description": "Monitor equipment operational status",
"category": "maintenance",
"package_id": 1,
"color": "#28a745",
"rules": [
{
"rule_id": "Equipment.HighTemp",
"rule_name": "High Temperature Alert",
"conditions": [
{
"stream": "<TEMP_SENSOR>",
"operator": "greater_than",
"value": 85.0
}
],
"event_name": "<EQUIPMENT>.HighTemp",
"event_description": "Equipment temperature exceeded threshold"
}
],
"placeholders": [
{
"placeholder_name": "TEMP_SENSOR",
"data_type": "NUM",
"description": "Temperature sensor stream",
"is_required": true
},
{
"placeholder_name": "EQUIPMENT",
"data_type": "STR",
"description": "Equipment identifier",
"is_required": true
}
]
}
Response:
{
"success": true,
"message": "Template created successfully",
"template": {
"id": 15,
"template_id": "TMPL_EQ_HEALTH_015",
"name": "Equipment Health Monitor",
"description": "Monitor equipment operational status",
"category": "maintenance",
"package_id": 1,
"color": "#28a745",
"is_active": true,
"allow_instances": true,
"created_at": "2025-08-07T07:45:00.000Z",
"created_by": "User",
"rules_count": 1,
"placeholders_count": 2,
"instances_count": 0
}
}
Deploying an Instance
Request:
POST /api/instances/5/deploy
Response:
{
"success": true,
"message": "Instance deployed successfully",
"instance": {
"id": 5,
"instance_id": "ROA022_INST",
"instance_name": "Roaster 022 Health Monitor",
"is_deployed": true,
"deployment_date": "2025-08-07T07:45:15.000Z",
"template": {
"id": 15,
"name": "Equipment Health Monitor"
},
"placeholder_mappings": {
"TEMP_SENSOR": "Wonderbrew.Roaster022.Temperature.PV",
"EQUIPMENT": "Roaster022"
}
}
}
Error Response
Error Response Format:
{
"success": false,
"error": "Template cannot be modified - has deployed instances",
"details": {
"template_id": 15,
"deployed_instances": 3,
"error_code": "TEMPLATE_IN_USE"
}
}
HTTP Status Codes:
- 200 - Success
- 201 - Created
- 400 - Bad Request
- 403 - Forbidden (deployment protection)
- 404 - Not Found
- 500 - Internal Server Error
Query Parameters & Filtering
Event Filtering
Available query parameters for /api/rule-events:
hours- Filter events by time range (default: 24)category- Filter by event categoryis_active- Filter active/closed eventstemplate_id- Filter by templateinstance_id- Filter by instanceseverity- Filter by severity level
Example:
GET /api/rule-events?hours=1&category=production&is_active=true
Template/Instance Filtering
Available query parameters:
package_id- Filter by packagecategory- Filter by categoryis_active- Filter active itemsis_deployed- Filter deployed instanceshas_instances- Templates with instances
Pagination:
page- Page number (default: 1)per_page- Items per page (default: 50)