REST API Reference
Complete REST API reference for Certexi including authentication, WHMS endpoints, workflow operations, IoT integrations, and governance routes.
Last updated: 2025-02-18
REST API Reference
Certexi exposes a comprehensive REST API through Next.js API routes. All endpoints return JSON and follow consistent error handling patterns.
OpenAPI spec
The canonical machine-readable reference is GET
/api/openapi. Use it for code generation, Swagger UI, or
Postman. To regenerate the full list of API routes from the codebase, run
npm run docs:generate-api-list.
Authentication
All API requests (except /api/health and /api/ping) require authentication via headers:
Authorization: Bearer <token> | Basic <credentials>
X-NextCloud-Instance: <nextcloud_url>
X-NextCloud-Username: <username>
The API supports both OAuth Bearer tokens and Nextcloud App Password authentication with automatic fallback.
Rate Limiting
API endpoints are rate-limited per user/IP. Default limits are 100 requests
per minute. Exceeding the limit returns 429 Too Many Requests with a
Retry-After header.
Health & Monitoring
/api/healthSystem health check (no auth required)
Returns the health status of all system components.
{
"status": "healthy",
"timestamp": "2025-01-15T10:00:00Z",
"uptime": 86400,
"version": "2.0.0",
"checks": {
"database": { "status": "healthy", "responseTime": 5 },
"redis": { "status": "healthy", "responseTime": 2 }
}
}
/api/metricsPrometheus metrics (admin only)
Returns application metrics in Prometheus exposition format. Requires metrics:read permission.
Warehouse Management (WHMS)
Warehouses
/api/whms/warehousesList all warehouses
Returns all warehouses accessible to the authenticated user.
/api/whms/warehousesCreate a warehouse
{
"name": "Main Warehouse",
"location": { "lat": 19.43, "lng": -99.13 },
"timezone": "America/Mexico_City"
}
/api/whms/warehouses/:idGet warehouse details
Returns warehouse metadata, zone summary, and utilization statistics.
Zones
/api/whms/zonesList all zones
Returns zones with slot counts and occupancy data.
/api/whms/zonesCreate a zone
{
"name": "Zone A",
"zone_type": "storage",
"color": "#3b82f6",
"warehouseId": 1
}
/api/whms/zones/:id/slotsList slots in a zone
Returns all slots within a zone with current occupancy status.
Slots
/api/whms/slotsList all slots
Returns all slots with computed occupancy from the event ledger.
/api/whms/slots/:idGet slot with occupancy status
Returns slot metadata and computed current status: isOccupied, assetBarcode, isVerified.
/api/whms/slotsCreate a slot
{
"slot_id": "A-01-01",
"zone": "A",
"floor_plan_polygon": [
{ "x": 10, "y": 20 },
{ "x": 50, "y": 20 },
{ "x": 50, "y": 60 },
{ "x": 10, "y": 60 }
]
}
Transport Units
/api/whms/transport-unitsList transport units
Returns all transport units with current stage and status.
/api/whms/transport-units/:idGet transport unit details
Returns full transport unit record including workflow history and evidence.
Events
/api/whms/eventsQuery event history
Supports filtering by slot_id, asset_barcode, event_type, and pagination via limit/offset.
/api/whms/eventsCreate a placement event
{
"event_type": "PLACED",
"slot_id": 5,
"asset_barcode": "PLT-2024-00001",
"operator": "op-123",
"photo_url": "https://cloud.example.com/evidence/photo.jpg",
"scale_weight_kg": 1250
}
Assets
/api/whms/assetsList assets
Returns all registered assets with type and metadata.
/api/whms/assets/:barcode/locationGet asset location
Returns the current location (slot) of an asset derived from the event ledger.
Dashboard
/api/whms/dashboard/utilizationZone utilization statistics
{
"totalSlots": 200,
"occupiedSlots": 142,
"utilizationPercent": 71,
"pendingVerifications": 8,
"byZone": [
{ "zone": "A", "occupied": 45, "total": 60 },
{ "zone": "B", "occupied": 38, "total": 50 }
]
}
IoT & Surveillance
/api/iot/cctvList cameras (filtered by ownership)
Returns cameras accessible to the authenticated user. RTSP URLs and credentials are never exposed.
/api/iot/detection/motion-streamStart/stop motion detection
Control server-side FFmpeg motion detection per camera. See Motion Detection.
/api/iot/detection-eventsQuery detection events
Returns motion detection events with clip URLs and metadata.
Governance
/api/governance/auditQuery audit log
Returns audit trail entries with filtering by entity, operator, and time range.
/api/governance/incidentsCreate an incident report
Log a compliance incident with severity, category, and evidence references.
Error Handling
All endpoints return standardized error responses:
{
"success": false,
"error": {
"message": "Error description",
"code": "ERROR_CODE",
"details": "Additional context"
}
}
Common HTTP status codes: 400 (validation), 401 (unauthorized), 403 (forbidden), 404 (not found), 429 (rate limited), 500 (server error).