{% extends 'base.html' %} {% block title %}Admin API Documentation{% endblock %} {% block head %} {% endblock %} {% block content %}

Admin API Documentation

Administrative API endpoints for system management

Admin Authentication Required

All endpoints require admin authentication via login session or admin API token (Bearer token in Authorization header).

GET

/admin/api/browse

Browse files and directories in the configured server directory for administrative purposes.

Parameters

path string (optional)
Directory path to browse (default: root directory)

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ "{{ request.host_url }}admin/api/browse?path=/some/path"

Response

{ "current_path": "/some/path", "items": [ { "name": "file.txt", "path": "/some/path/file.txt", "is_dir": false, "size": 1024 } ] }
POST

/admin/api/train

Start AI model training process. Costs 100 tokens (free for admins).

Parameters

output_model string (optional)
Name for the trained model (default: "MyCustomModel")
description string (optional)
Description of the model
train_path string (required)
Path to the training data directory

Curl Example

curl -X POST -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "output_model": "MyModel", "description": "Custom trained model", "train_path": "/path/to/training/data" }' {{ request.host_url }}admin/api/train

Response

{ "message": "Training completed", "tokens_used": 100, "remaining_tokens": 900 }
GET

/admin/api/users

Retrieve a complete list of all users in the system for administrative management.

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ {{ request.host_url }}admin/api/users

Response

{ "users": [ { "id": 1, "username": "user1", "email": "user1@example.com", "role": "user", "tokens": 100, "active": true, "created_at": "2024-01-01T00:00:00Z" } ] }
GET

/admin/api/cluster_tokens

List all cluster tokens for distributed processing management.

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ {{ request.host_url }}admin/api/cluster_tokens

Response

{ "tokens": [ { "id": 1, "name": "Worker Token", "token": "abc123...", "active": true, "created_at": "2024-01-01T00:00:00Z" } ] }
{% endblock %}