API Reference
The Procunit agent exposes a local REST API at http://localhost:8090/api/v1. All requests require Authorization: Bearer <api_key>. Retrieve your API key from the agent dashboard at http://localhost:8090/dashboard. The API is local-only by default — it does not listen on external network interfaces unless you explicitly configure api.bind in agent.yaml.
Model Management
/api/v1/models
List all trained models on this agent.
{
"models": [
{
"name": "door-latch-v1",
"status": "live",
"camera": "line-1-cam",
"defect_classes": ["edge-crack", "surface-score"],
"trained_at": "2026-04-12T03:42:18Z",
"latency_p95_ms": 7.3
}
]
}
/api/v1/models/{name}/activate
Activate a model on a camera channel. Replaces any currently running model on that channel.
// POST body
{ "camera": "line-1-cam" }
// Response 200
{
"model": "door-latch-v1",
"camera": "line-1-cam",
"status": "live",
"latency_p95_ms": 7.3
}
Frame Submission API
Submit a frame for synchronous inference. Use for integration testing or offline batch analysis. Live inspection uses the hardware-triggered camera path.
/api/v1/inspect
curl -X POST http://localhost:8090/api/v1/inspect \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @frame.jpg
{
"verdict": "FAIL",
"confidence": 0.94,
"detections": [
{
"class": "edge-crack",
"confidence": 0.94,
"bbox": { "x": 412, "y": 228, "w": 38, "h": 12 }
}
],
"inference_ms": 5.1,
"frame_id": "f3a91b"
}
Defect Event Webhooks
Configure a webhook URL in agent.yaml to receive real-time FAIL events pushed to your MES or SCADA system.
webhook:
url: "http://mes-server:3000/quality-events"
on_fail: true
on_pass: false
secret: "your-hmac-secret"
Webhook payload for a FAIL event:
{
"event": "defect.detected",
"timestamp": "2026-05-14T14:32:07.214Z",
"camera": "line-1-cam",
"model": "door-latch-v1",
"verdict": "FAIL",
"defect_class": "edge-crack",
"confidence": 0.91,
"frame_archive_id": "20260514-143207-f3a91b"
}
PLC Interface Protocol
Procunit supports three PLC interface modes. Configure in agent.yaml under the plc key.
| Interface | Config value | Notes |
|---|---|---|
| Ethernet/IP | ethernet_ip | Implicit messaging, coil address in Logix format O:0/1 |
| Modbus TCP | modbus_tcp | Coil register number. Default port 502. |
| Discrete I/O | discrete_io | Requires USB digital I/O module (see hardware BOM) |
Reject signal timing: the FAIL coil is pulsed for plc.fail_pulse_ms (default 120ms). The pulse starts within 8ms (P95) of the camera trigger signal. Signal timing is deterministic — Procunit uses a real-time priority thread for PLC output.