Skip to content

API Routes

All API routes are prefixed with /api/v1/.


Auth Routes — /api/v1/auth

All routes are public (no authentication required).

MethodPathDescription
POST/signinAuthenticate with email + password
POST/signupRegister a new user account
POST/verify-signupVerify email address with token
POST/signup-send-verificationResend signup verification email
POST/forgot-passwordSend password reset email
POST/reset-passwordSet new password using reset token

User Routes — /api/v1/user

All routes require authCheck (valid JWT cookie).

MethodPathDescription
POST/signup(legacy) Register user
POST/signin(legacy) Sign in
GET/profileGet current user's profile
PUT/profileUpdate user profile fields
PUT/update-preferencesUpdate user preferences (e.g. enable_humidity)
POST/update-passwordChange password (requires current_password)
POST/logoutInvalidate session token

Unit Routes — /api/v1/unit

All routes require authCheck.

MethodPathDescription
POST/Create a new monitoring unit
GET/List all units for the authenticated user
PATCH/Update unit settings (thresholds, device link)
GET/live-alertsGet all units with active threshold alerts
PATCH/recipientUpdate email/SMS recipients for unit(s)

Unit Create/Update Body Fields

json
{
  "name": "Cold Room A",
  "min_temperature": 2,
  "max_temperature": 8,
  "min_humidity": 40,
  "max_humidity": 80,
  "min_volt": 210,
  "max_volt": 240,
  "device_id": "<objectId>"
}

Device Routes — /api/v1/device

All routes require authCheck.

MethodPathDescription
GET/List devices owned by the authenticated user
PATCH/Update one or more device names
PATCH/:deviceId/sensor-configUpdate the sensor configuration for a device

Query Parameters for GET /

ParamTypeDescription
pagenumberPage number (default: 1)
limitnumberItems per page (default: 10)
order_bystringField to sort by
order_typestringasc or desc
get_allbooleanReturn all records (no pagination)

Report Routes — /api/v1/report

All routes require authCheck.

MethodPathDescription
GET/downloadDownload sensor data report (CSV or PDF)
GET/generate-pdfGenerate and stream a PDF report

Query Parameters for /download

ParamTypeDescription
unit_idstringTarget unit (must be owned by user)
from_datestringStart date (ISO 8601)
to_datestringEnd date (ISO 8601)
file_typestringcsv or pdf

Recipient Routes — /api/v1/recipient

All routes require authCheck.

MethodPathDescription
POST/Create a new notification recipient
GET/List all active recipients for the user
PATCH/:idUpdate recipient (name, email, phone)
DELETE/:idSoft-delete recipient (removes from units)

Recipient Body Fields

json
{
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "+1234567890"
}

INFO

Deleting a recipient is a soft delete — the status is set to "deleted", the email is mangled, and the recipient is removed from all unit configurations atomically in a MongoDB transaction.


IoT Sensor Data — /api/v1/devices/sensor-data

Device Auth

This route uses deviceAuthCheck (static token), NOT the user JWT cookie. It is exclusively for IoT hardware devices.

MethodPathDescription
POST/Ingest sensor + network data from device

Request Headers

Authorization: Au@jsjKAKL9IJK@@Kks
Content-Type: application/json

Request Body

json
{
  "id": "DEVICE-CODE-001",
  "temperature": 5.2,
  "humidity": 62.1,
  "volt": 220.5,
  "seq_no": 1234
}

Admin — Devices /api/v1/admin/devices

All routes require adminAuthCheck (user with type === 'admin').

MethodPathDescription
POST/Create one or more new devices
GET/List all devices (with filters)
POST/usersAssign devices to a user
DELETE/usersRemove devices from a user
PATCH/batch-settingsUpdate settings for multiple devices
GET/logsView device assignment logs
GET/:device_id/sensor-dataView sensor data for a device
GET/:device_id/raw-sensor-dataView raw sensor data for a device
GET/:device_id/diagnostic-dataView diagnostic data for a device

Admin Device Query Parameters

ParamDescription
user_idFilter devices by assigned user
unassigned_onlyReturn only unassigned devices
search_stringText search on device code/name
drop_downReturn minimal fields for dropdown use
page / limitPagination

Admin — Users /api/v1/admin/users

All routes require adminAuthCheck.

MethodPathDescription
GET/List all users (paginated)
GET/:user_id/unitsList units for a specific user
GET/:user_id/devicesList devices for a specific user

Common Response Format

Success (200 / 201)

json
{
  "success": true,
  "message": "Fetched successfully",
  "data": { }
}

Paginated Response

json
{
  "success": true,
  "message": "...",
  "total": 42,
  "page": 1,
  "limit": 10,
  "total_pages": 5,
  "has_more": true,
  "items": [ ]
}

Error (400 / 401 / 403 / 404 / 500)

json
{
  "success": false,
  "message": "Descriptive error message"
}

All responses are generated by helper functions in src/helpers/response.helper.js.

Intecog Logistech IoT Monitoring Platform