KPIs API
SQCDP performance indicators — definitions, measurements, targets, and threshold alerting.
KPIs API
ProBeya provides a comprehensive KPI system organized around the SQCDP framework: Safety, Quality, Cost, Delivery, and People. Each KPI definition is attached to a board and supports manual/automated value entry, target management, time-series analysis, threshold-based alerting (green/amber/red), and SPC (Statistical Process Control) with control limits and capability indices.
Quick Start: Ingesting OEE from Your MES
Record a daily OEE measurement from your manufacturing execution system in a single call:
Endpoints
GET /api/v1/kpis
List all KPI definitions for a specific board, enriched with the latest value and active target for each.
tRPC: kpis.list | Scope: read:kpis | Org context: Required
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
boardId | string (query) | Yes | The board to list KPIs for |
Response:
{
"data": [
{
"id": "clx9kp001",
"name": "OEE (Overall Equipment Effectiveness)",
"category": "delivery",
"unit": "%",
"frequency": "daily",
"direction": "higher_is_better",
"dataSource": "manual",
"boardId": "clx9bd001",
"organizationId": "clx9abc123def",
"thresholds": {
"red": 65,
"amber": 75,
"green": 85
},
"latestValue": {
"value": 82.5,
"date": "2026-04-12",
"status": "amber"
},
"activeTarget": {
"targetValue": 90,
"periodStart": "2026-01-01",
"periodEnd": "2026-12-31"
},
"createdAt": "2026-02-01T10:00:00.000Z"
},
{
"id": "clx9kp002",
"name": "Right First Time",
"category": "quality",
"unit": "%",
"frequency": "daily",
"direction": "higher_is_better",
"dataSource": "manual",
"boardId": "clx9bd001",
"organizationId": "clx9abc123def",
"thresholds": {
"red": 90,
"amber": 95,
"green": 98
},
"latestValue": {
"value": 96.2,
"date": "2026-04-12",
"status": "amber"
},
"activeTarget": {
"targetValue": 99.0,
"periodStart": "2026-01-01",
"periodEnd": "2026-06-30"
},
"createdAt": "2026-02-01T10:05:00.000Z"
},
{
"id": "clx9kp003",
"name": "Safety Incidents (LTI)",
"category": "safety",
"unit": "count",
"frequency": "monthly",
"direction": "lower_is_better",
"dataSource": "manual",
"boardId": "clx9bd001",
"organizationId": "clx9abc123def",
"thresholds": {
"green": 0,
"amber": 1,
"red": 3
},
"latestValue": {
"value": 0,
"date": "2026-04-01",
"status": "green"
},
"activeTarget": {
"targetValue": 0,
"periodStart": "2026-01-01",
"periodEnd": "2026-12-31"
},
"createdAt": "2026-02-01T10:10:00.000Z"
}
]
}
Errors:
| Code | Description | Cause | Fix |
|---|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid authentication | Check your Bearer token |
| 404 | NOT_FOUND | Board not found in this organization | Verify the boardId and org context |
POST /api/v1/kpis/:id/values
Record a single manual KPI measurement. Uses upsert semantics — if a value already exists for the same KPI and date, it is overwritten. The enteredById is automatically set to the authenticated user for audit trail compliance.
tRPC: kpis.setValue | Scope: write:kpis | Org context: Required
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
id | string (path) | Yes | The KPI definition ID |
value | number or string | Yes | The measurement value |
date | string | Yes | ISO 8601 date (e.g., 2026-04-13) |
comment | string | No | Optional note about the measurement |
source | string | No | Data source identifier (default: manual) |
Response:
{
"data": {
"id": "clx9kv120",
"kpiDefinitionId": "clx9kp002",
"value": 97.8,
"date": "2026-04-13",
"comment": "Reject on Line 1 was a labeling error, not product quality",
"source": "manual",
"enteredById": "clx9us001",
"organizationId": "clx9abc123def",
"createdAt": "2026-04-13T14:00:00.000Z"
}
}
Side effects:
- Logs activity event with KPI name, value, and date
- Evaluates threshold alerts (red/amber/green) and sends notifications if breached
- Fires
kpi.value_recordedwebhook - Invalidates Redis cache for KPI data
Errors:
| Code | Description | Cause | Fix |
|---|---|---|---|
| 400 | BAD_REQUEST | Invalid date format or missing value | Use YYYY-MM-DD date format |
| 401 | UNAUTHORIZED | Missing or invalid authentication | Check your Bearer token |
| 403 | FORBIDDEN | Insufficient scope | API key needs write:kpis scope |
| 404 | NOT_FOUND | KPI definition not found in this org | Verify the KPI ID and org context |
POST /api/v1/kpis/:id/batch-values (tRPC: kpis.batchSetValues)
Record multiple measurements in a single call. Ideal for MES/SCADA integrations that push daily data for multiple dates or multiple KPIs. Scales linearly: 365 rows take approximately 200ms.
Response:
{
"data": {
"inserted": 4,
"kpiDefinitionId": "clx9kp001"
}
}
Threshold Alerting
KPIs support automatic traffic-light evaluation based on configurable thresholds. When a new measurement breaches the red threshold, ProBeya sends a notification to relevant team members.
| Direction | Green | Amber | Red |
|---|---|---|---|
higher_is_better | value >= green | value >= amber AND value < green | value < amber |
lower_is_better | value <= green | value <= amber AND value > green | value > amber |
Example: OEE thresholds
Thresholds: red=65, amber=75, green=85 (higher_is_better)
OEE = 87.3% → GREEN (87.3 >= 85)
OEE = 79.1% → AMBER (79.1 >= 75 but < 85)
OEE = 62.4% → RED (62.4 < 75) — notification sent
SQCDP Categories
| Category | Description | Typical KPIs |
|---|---|---|
safety | Safety incidents, near-misses, compliance | LTI rate, near-miss count, safety observation rate |
quality | Defect rates, yield, first-pass quality | Right First Time %, batch rejection rate, OOS count |
cost | Cost per unit, budget variance, waste | Cost per unit, scrap %, energy cost/unit |
delivery | OEE, on-time delivery, lead time | OEE %, on-time-in-full (OTIF), cycle time |
people | Absenteeism, training hours, engagement | Absenteeism %, training hours/FTE, mood score |
Pharma Integration Scenarios
SPC (Statistical Process Control)
ProBeya includes a built-in SPC engine for advanced KPI analysis, accessible via the tRPC-only kpis.getControlChart procedure:
- Control limits calculated using standard Western Electric rules (X-bar, R-chart)
- Capability indices (Cp, Cpk) for process capability assessment
- Rule violations detected automatically: runs above/below center, trends, outliers
- Configurable via the
spcConfigfield on the KPI definition
Expected response time: 20-100ms depending on dataset size (SPC calculations are performed in-memory).
KPI Hierarchy
KPIs can be organized in parent-child relationships. A parent KPI’s value is automatically computed from its children (e.g., a site-level OEE computed from individual line OEEs). Use kpis.getTree to fetch the full hierarchy and kpis.recalculate to recompute parent values.
tRPC-Only KPI Procedures
| Procedure | Description | Expected Latency |
|---|---|---|
kpis.define | Create a new KPI definition on a board | 10-30ms |
kpis.update | Update KPI definition (name, thresholds, unit, etc.) | 10-30ms |
kpis.delete | Delete a KPI and all its values/targets (cascade) | 15-50ms |
kpis.listByCategory | List KPIs grouped by SQCDP category | 10-50ms |
kpis.getValue | Get the latest value for a specific KPI | 3-10ms |
kpis.getHistory | Get time-series data with optional date range filter | 5-30ms |
kpis.batchSetValues | Record multiple measurements in a single call | 20-200ms |
kpis.getAlerts | Get KPIs currently breaching red/amber thresholds | 10-50ms |
kpis.getTargets | Get all targets for a KPI | 3-10ms |
kpis.setTarget | Create or update a period-specific target | 10-30ms |
kpis.getTree | Get full KPI hierarchy tree for a board | 10-50ms |
kpis.getChildren | Get child KPIs of a parent KPI | 5-20ms |
kpis.recalculate | Recompute a parent KPI value from children | 15-60ms |
kpis.getControlChart | Get SPC control chart data with control limits | 20-100ms |
kpis.updateSpcConfig | Update SPC configuration for a KPI | 10-30ms |
Rate Limiting
| Plan | Requests/min | Batch values/call |
|---|---|---|
| Free | 60 | 30 |
| Starter | 120 | 90 |
| Pro | 300 | 365 |
| Enterprise | 600 | 1000 |
Was this page helpful?