REST API: Tags & Folders Organization Endpoints
The Tags and Folders API allows administrators and integration scripts to organize camera devices into hierarchical folder trees and colored tag categories.
1. Camera Tags API
1.1 List Tags (GET /api/tags)
bash
curl -H "Authorization: Bearer <TOKEN>" http://localhost:8080/api/tagsResponse (200 OK):
json
[
{ "id": "outdoor", "name": "Outdoor Cameras", "color": "#10B981" },
{ "id": "ptz", "name": "PTZ Controllable", "color": "#3B82F6" },
{ "id": "critical", "name": "Critical Perimeter", "color": "#EF4444" }
]1.2 Create Tag (POST /api/tags)
- Required Role:
operator,admin, orservice
bash
curl -X POST http://localhost:8080/api/tags \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{ "id": "parking", "name": "Parking Area", "color": "#F59E0B" }'1.3 Delete Tag (DELETE /api/tags/:id)
Deletes the tag from BadgerDB:
bash
curl -X DELETE http://localhost:8080/api/tags/parking \
-H "Authorization: Bearer <TOKEN>"Response (200 OK): {"message": "tag deleted"}.
2. Hierarchical Folders API
2.1 List Folders (GET /api/folders)
bash
curl -H "Authorization: Bearer <TOKEN>" http://localhost:8080/api/foldersResponse (200 OK):
json
[
{ "id": "hq", "name": "Headquarters", "parent_id": "" },
{ "id": "bldg-a", "name": "Building A", "parent_id": "hq" },
{ "id": "floor-2", "name": "Floor 2", "parent_id": "bldg-a" }
]2.2 Create Folder (POST /api/folders)
- Required Role:
operator,admin, orservice
bash
curl -X POST http://localhost:8080/api/folders \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{ "id": "warehouse-east", "name": "East Warehouse", "parent_id": "" }'2.3 Delete Folder (DELETE /api/folders/:id)
Deletes the folder from BadgerDB:
bash
curl -X DELETE http://localhost:8080/api/folders/warehouse-east \
-H "Authorization: Bearer <TOKEN>"Response (200 OK): {"message": "folder deleted"}.