MedServLink API

Medical Device Remote Service Management Platform ยท API Documentation

Version 0.1.0Base URL: https://www.medservlink.cn/api Auth: JWT Bearer TokenLast Updated: 2026-08-07
AuthenticationUser ManagementDevice Management Order ManagementRemote SessionsTRTC Audio/Video Data ModelsError Handling

1. Authentication

POST /api/auth/register Public

Register a new user. Returns a JWT Token on success.

{
  "username": "engineer01",
  "password": "pass123",
  "role": "engineer",
  "name": "Engineer Zhang"
}

role: admin | manufacturer | engineer | hospital

Response 201:

{
  "access_token": "eyJhbG...",
  "user": {
    "id": "uuid",
    "username": "engineer01",
    "role": "engineer",
    "name": "Engineer Zhang"
  }
}
POST /api/auth/login Public

User login. Returns a JWT Token. Token is valid for 7 days.

{
  "username": "admin",
  "password": "admin123"
}

Response 200 / 401

GET /api/auth/me Auth Required

Get the current logged-in user's information.

Headers: Authorization: Bearer <token>

{
  "id": "uuid",
  "username": "admin",
  "role": "admin",
  "name": "Andrew",
  "email": null,
  "phone": null,
  "company": null,
  "active": true,
  "createdAt": "2026-08-06T..."
}

2. User Management Auth Required (admin)

GET /api/users

Get a list of all users.

GET /api/users/:id

Get details of a single user.

POST /api/users

Create a new user. Note: The password is not bcrypt-hashed (calls UsersService directly). It is recommended to create users via /api/auth/register instead.

PUT /api/users/:id

Update user information.

DELETE /api/users/:id

Delete a user.

3. Device Management Auth Required

GET /api/devices

Get a list of all devices.

POST /api/devices

Register a new device.

{
  "name": "Non-contact Tonometer",
  "model": "TX-20",
  "category": "Ophthalmology - Tonometer",
  "manufacturerId": "uuid",
  "serialNumber": "SN-2026-001",
  "status": "active"
}
GET/api/devices/:id
PUT/api/devices/:id
DELETE/api/devices/:id

4. Order Management Auth Required

GET /api/orders ?status=pending|accepted|in_progress|completed|cancelled

Get a list of orders. Optional ?status=xxx filter.

POST/api/orders
{
  "title": "Tonometer Calibration Fault",
  "description": "Device displays E02 error code...",
  "deviceCategory": "Ophthalmology - Tonometer",
  "deviceModel": "TX-20",
  "manufacturerId": "uuid",
  "engineerId": "uuid",
  "priority": "medium",
  "status": "pending"
}

status: pending โ†’ accepted โ†’ in_progress โ†’ completed | cancelled

priority: low | medium | high | urgent

GET/api/orders/:id
PUT/api/orders/:id
DELETE/api/orders/:id

5. Remote Sessions Auth Required

GET/api/sessions
POST/api/sessions
{
  "orderId": "uuid",
  "manufacturerUserId": "uuid",
  "engineerUserId": "uuid",
  "trtcRoomId": "room-123",
  "notes": "Tonometer mainboard troubleshooting"
}
GET/api/sessions/:id
PUT/api/sessions/:id
DELETE/api/sessions/:id

6. TRTC Audio/Video Auth Required

POST /api/trtc/usersig

Generate a TRTC UserSig for the client to enter an audio/video room.

{
  "userId": "engineer-01"
}
{
  "sdkAppId": 1600155894,
  "userId": "engineer-01",
  "userSig": "eJwt..."
}

SDKAppID: 1600155894. UserSig is valid for 7 days by default.

7. Data Models

User

FieldTypeDescription
idUUIDPrimary key
usernamestringUnique, login name
passwordstringbcrypt hash, not returned by API
roleenumadmin/manufacturer/engineer/hospital
namestring?Real name
companystring?Company / hospital name
phonestring?Phone number
emailstring?Email address
activebooleanWhether the account is enabled

Device

FieldTypeDescription
idUUIDPrimary key
namestringDevice name
modelstringDevice model
categorystringDevice category (e.g. "Ophthalmology - Tonometer")
manufacturerIdstringManufacturer user ID
hospitalIdstring?Hospital user ID
serialNumberstring?Device serial number
installDateDate?Installation date
warrantyExpiryDate?Warranty expiry date
statusstringactive/inactive

Order

FieldTypeDescription
idUUIDPrimary key
titlestringOrder title
descriptiontext?Problem description
deviceCategorystringDevice category
deviceModelstring?Device model
manufacturerIdstringManufacturer ID
engineerIdstring?Assigned engineer ID
hospitalIdstring?Hospital ID
statusenumpending/accepted/in_progress/completed/cancelled
prioritystring?low/medium/high/urgent
scheduledAtDate?Scheduled service time
completedAtDate?Completion time

Session

FieldTypeDescription
idUUIDPrimary key
orderIdstringAssociated order ID
manufacturerUserIdstringManufacturer user ID
engineerUserIdstringEngineer user ID
trtcRoomIdstring?TRTC room ID
recordingbooleanWhether recording is enabled
notestext?Session notes
startedAtDate?Start time
endedAtDate?End time
durationSecondsnumberCall duration (seconds)

8. Error Handling

Authentication Error: For all endpoints requiring authentication, a missing token returns 401 Unauthorized.
Token Expired: Returns 401. The frontend automatically redirects to the login page.
Validation Error: Returns 400 Bad Request. The body contains { "message": "..." }.

Deployment Information

ItemValue
ServerAlibaba Cloud ECS 47.253.228.219
Web ServerNginx 1.24.0
BackendNestJS + TypeORM + sql.js (SQLite)
Process ManagerPM2 (medservlink-backend)
HTTPSLet's Encrypt (www.medservlink.cn)
TRTC SDKAppID1600155894
Source Location/opt/medservlink/backend/
Build Commandcd /opt/medservlink/backend && npm run build && pm2 restart medservlink-backend --update-env
Log Location~/.pm2/logs/medservlink-backend-*.log
Database/opt/medservlink/data/medservlink.db