API Reference
API Reference
REST API reference for the CPI IoT Dashboard Platform, generated from the OpenAPI specification.
Overview
The CPI REST API is available at https://api.cpi.lovinka.com/api/v1.
Authentication
Most endpoints require JWT authentication via httpOnly cookie (access_token). Authenticate with:
curl -X POST https://api.cpi.lovinka.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-c cookies.txt \
-d '{"email": "your@email.com", "password": "your-password"}'Base URL
| Environment | URL |
|---|---|
| Production | https://api.cpi.lovinka.com/api/v1 |
| Local Development | http://localhost:4410/api/v1 |
Interactive Documentation
The API also provides Swagger UI at:
- Production:
https://api.cpi.lovinka.com/api-docs - Local:
http://localhost:4410/api-docs
Endpoints
Auth
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register | Register a new user |
| POST | /auth/login | Login, receive JWT cookie |
| POST | /auth/logout | Clear JWT cookie |
| GET | /auth/me | Get current user profile |
Devices
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /devices | Any | List devices (paginated) |
| POST | /devices | OPERATOR+ | Register a new device |
| GET | /devices/:id | Any | Get device details |
| PATCH | /devices/:id | OPERATOR+ | Update device |
| DELETE | /devices/:id | ADMIN | Delete device |
| POST | /devices/:id/provision | ADMIN | Generate provisioning package |
| POST | /devices/:id/mqtt-token | ADMIN | Issue fresh MQTT JWT |
| POST | /devices/:id/rotate-secret | ADMIN | Rotate HMAC secret |
| POST | /devices/:id/suspend | ADMIN | Suspend device |
| POST | /devices/:id/reactivate | ADMIN | Reactivate device |
| POST | /devices/:id/revoke | ADMIN | Decommission device |
| POST | /devices/:id/commands | OPERATOR+ | Send command |
Telemetry
| Method | Endpoint | Description |
|---|---|---|
| GET | /telemetry/:deviceId | Get telemetry data (supports time_bucket aggregation) |
Alerts
| Method | Endpoint | Description |
|---|---|---|
| GET | /alerts | List alerts (paginated) |
| POST | /alerts | Create alert rule |
| PATCH | /alerts/:id | Update alert |
| POST | /alerts/:id/acknowledge | Acknowledge alert |
| POST | /alerts/:id/resolve | Resolve alert |
Users
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /users | ADMIN | List users |
| PATCH | /users/:id | ADMIN | Update user role |
For detailed request/response schemas, visit the interactive Swagger documentation at /api-docs.