Auth
Bearer token JWT trong header Authorization: Bearer <jwt>. SPA lưu token tại localStorage.vms_v2_token. Tất cả endpoint /v2/api/* và WebSocket realtime đều bắt buộc token có tenant_id và scope phù hợp.
Health
| Method | Path | Mô tả |
| GET | /v2/health | {"status":"ok"} · liveness |
| GET | /v2/health/ready | Kiểm tra postgres + redis · readiness |
| GET | /v2/metrics | Prometheus exposition (basic-auth) |
Cameras
| Method | Path | Mô tả |
| GET | /v2/api/cameras | List camera của tenant. |
| POST | /v2/api/cameras | Tạo mới. Tôn trọng camera_limit, lọc features. |
| PATCH | /v2/api/cameras/{id} | Cập nhật một phần. |
| DELETE | /v2/api/cameras/{id} | Xoá. |
Camera schema
{
"id": "cam-front-01",
"tenant_id": "default",
"name": "Front gate",
"rtsp_url": "rtsp://user:[email protected]:554/stream",
"features": ["person","vehicle","license_plate"],
"fps": 5,
"enabled": true,
"record": true,
"status": "online",
"created_at": "2026-04-30T10:00:00Z",
"updated_at": "2026-04-30T10:00:00Z"
}
Events
| Method | Path | Mô tả |
| GET | /v2/api/events | Query · params: camera_id, type, since (ISO-8601), limit (1-100). |
| WS | /v2/ws/events?token={jwt} | Stream realtime theo tenant. Server gửi envelope {"v":2,"data":{…}}. |
Event schema
{
"id": "evt-abc123",
"tenant_id": "default",
"camera_id": "cam-front-01",
"type": "violence",
"confidence": 0.87,
"payload": { "boxes": [...], "track_id": 42 },
"snapshot_url": "/v2/hls/cam-front-01/2026-04-30/14/snap-12.jpg",
"trace_id": "uuid-v4",
"model_version":"yolo@2026-05-01",
"ts": "2026-04-30T14:23:45.123Z"
}
Playback
| Method | Path | Mô tả |
| GET | /v2/api/playback/timeline?camera_id={id}&date={YYYY-MM-DD} | Liệt kê các giờ có HLS segment. |
| GET | /v2/api/playback/event/{id} | Trả về URL playlist + offset cho event đó. |
| GET | /v2/hls/{cam}/{date}/{hour}/index.m3u8?token={jwt} | HLS playlist qua core, có kiểm tra tenant. |
Quickstart curl
# Liệt kê camera
curl -s https://vmsclient.vnso.vn/v2/api/cameras \
-H "Authorization: Bearer $JWT" | jq
# Tạo camera
curl -s -X POST https://vmsclient.vnso.vn/v2/api/cameras \
-H "Authorization: Bearer $JWT" \
-H 'content-type: application/json' \
-d '{"name":"Lobby","rtsp_url":"rtsp://...","features":["person"]}'
# Stream realtime events
websocat "wss://vmsclient.vnso.vn/v2/ws/events?token=$JWT"