-
Notifications
You must be signed in to change notification settings - Fork 29
API Documentation
This comprehensive reference covers all REST API endpoints available in Flowcase, including authentication, request/response formats, and practical examples.
[!INFO] Implementation Status: This documentation covers both implemented and planned API endpoints. Features marked as "planned" or "future" are not yet available in the current version.
http://your-flowcase-instance.com
All API endpoints require authentication via session cookies obtained through login.
All responses follow a consistent JSON format:
{
"success": true|false,
"data": {},
"error": "Error message if success is false"
}Authenticate to obtain session cookies for API access.
POST /login
Content-Type: application/x-www-form-urlencoded
username=your_username&password=your_password&remember=onNote: The login endpoint expects form data, not JSON. The remember parameter is optional.
Response:
-
Success: HTTP 302 redirect to
/dashboardwith session cookies -
Error: HTTP 302 redirect to
/with error in session
Note: The login endpoint does NOT return JSON responses. It uses traditional form submission with redirects. Check the redirect location to determine success/failure.
Session Cookies Set:
-
userid- User ID -
username- Username -
token- User auth token - Flask session cookie
Terminate the current session.
GET /logoutResponse:
- HTTP 302 redirect to
/with cookies cleared
Verify authentication for droplet access.
GET /droplet_connectRequired Cookies: userid, token
Response:
- 200: Valid authentication
- 401: Invalid or missing authentication
Retrieve list of droplets available to the current user.
GET /api/dropletsResponse:
{
"success": true,
"droplets": [
{
"id": "droplet-uuid",
"display_name": "Ubuntu Desktop",
"description": "Full Ubuntu desktop environment",
"image_path": "/static/img/ubuntu.jpg",
"droplet_type": "container",
"container_docker_image": "ubuntu:20.04-desktop",
"container_docker_registry": "https://index.docker.io/v1/",
"container_cores": 2,
"container_memory": 2048,
"server_ip": null,
"server_port": null
}
]
}Retrieve all instances owned by the current user.
GET /api/instancesResponse:
{
"success": true,
"instances": [
{
"id": "instance-uuid",
"created_at": "2024-01-15T10:30:00.000000",
"updated_at": "2024-01-15T10:35:00.000000",
"droplet": {
"id": "droplet-uuid",
"display_name": "Ubuntu Desktop",
"description": "Full Ubuntu desktop environment",
"image_path": "/static/img/ubuntu.jpg",
"droplet_type": "container",
"container_docker_image": "ubuntu:20.04-desktop",
"container_docker_registry": "https://index.docker.io/v1/",
"container_cores": 2,
"container_memory": 2048,
"server_ip": null,
"server_port": null
}
}
]
}Create a new droplet instance.
POST /api/instance/request
Content-Type: application/json
{
"droplet_id": "droplet-uuid",
"resolution": "1920x1080"
}Response:
{
"success": true,
"instance_id": "new-instance-uuid",
"guac_token": "encrypted-token-string",
"redirect": "/droplet/new-instance-uuid"
}Terminate and remove an instance.
GET /api/instance/{instance_id}/destroyResponse:
{
"success": true,
"message": "Instance destroyed successfully"
}Get the droplet interface for an instance.
GET /droplet/{instance_id}Response: HTML page with embedded instance interface and VNC viewer
Access the main dashboard page (requires authentication).
GET /dashboardResponse: HTML page with dashboard interface and available droplets
Retrieve system status and statistics (requires perm_admin_panel).
GET /api/admin/system_infoResponse:
{
"success": true,
"system": {
"hostname": "flowcase-host",
"os": "Linux 5.4.0"
},
"version": {
"flowcase": "develop",
"python": "3.11.2",
"docker": "24.0.7",
"nginx": "1.28.1"
}
}Check system health and status.
GET /healthWarning
Planned Feature: The /health endpoint is not yet implemented in the current version. System health information is available through the Admin Panel → System Information instead.
Response:
{
"status": "healthy",
"version": "develop",
"timestamp": "2024-01-15T10:30:00Z",
"services": {
"database": "ok",
"docker": "ok",
"storage": "ok"
}
}Retrieve all users (requires perm_view_users).
GET /api/admin/usersResponse:
{
"success": true,
"users": [
{
"id": "user-uuid",
"username": "admin",
"created_at": "2024-01-15T10:30:00.000000",
"groups": ["admin-group-uuid", "user-group-uuid"]
}
]
}Create or modify a user account (requires perm_edit_users).
POST /api/admin/user
Content-Type: application/json
{
"username": "newuser",
"password": "secure_password",
"groups": "user-group-uuid,admin-group-uuid"
}For updates, include:
{
"user_id": "existing-user-uuid",
"username": "updated_username",
"groups": "user-group-uuid",
"new_password": "new_password"
}Response:
{
"success": true,
"message": "User created/updated successfully"
}Remove a user account (requires perm_edit_users).
DELETE /api/admin/user
Content-Type: application/json
{
"user_id": "user-uuid"
}Response:
{
"success": true,
"message": "User deleted successfully"
}Retrieve all droplets in the system (requires perm_view_droplets).
GET /api/admin/dropletsResponse:
{
"success": true,
"droplets": [
{
"id": "droplet-uuid",
"display_name": "Ubuntu Desktop",
"description": "Full Ubuntu desktop environment",
"image_path": "/static/img/ubuntu.jpg",
"droplet_type": "container",
"container_docker_image": "ubuntu:20.04-desktop",
"container_docker_registry": "https://index.docker.io/v1/",
"container_cores": 2,
"container_memory": 2048,
"container_persistent_profile_path": "/home/user",
"server_ip": null,
"server_port": null,
"server_username": null,
"server_password": "********************************"
}
]
}Add or modify a droplet (requires perm_edit_droplets).
POST /api/admin/droplet
Content-Type: application/json
{
"display_name": "New Application",
"description": "Application description",
"droplet_type": "container",
"container_docker_image": "myapp:latest",
"container_docker_registry": "https://registry.company.com",
"container_cores": 1,
"container_memory": 1024,
"container_persistent_profile_path": "/home/user"
}Response:
{
"success": true,
"message": "Droplet created/updated successfully"
}Remove a droplet from the system (requires perm_edit_droplets).
DELETE /api/admin/droplet
Content-Type: application/json
{
"droplet_id": "droplet-uuid"
}Response:
{
"success": true,
"message": "Droplet deleted successfully"
}Retrieve all instances in the system (requires perm_view_instances).
GET /api/admin/instancesResponse:
{
"success": true,
"instances": [
{
"id": "instance-uuid",
"user": {
"username": "user1"
},
"droplet": {
"display_name": "Ubuntu Desktop"
},
"created_at": "2024-01-15T10:30:00.000000",
"updated_at": "2024-01-15T10:35:00.000000"
}
]
}Forcefully terminate any instance (requires perm_edit_instances).
DELETE /api/admin/instance
Content-Type: application/json
{
"instance_id": "instance-uuid"
}Response:
{
"success": true,
"message": "Instance destroyed successfully"
}Retrieve all user groups (requires perm_view_groups).
GET /api/admin/groupsResponse:
{
"success": true,
"groups": [
{
"id": "group-uuid",
"display_name": "Admin",
"created_at": "2024-01-15T10:30:00.000000",
"protected": true,
"perm_admin_panel": true,
"perm_view_users": true,
"perm_edit_users": true,
"perm_view_droplets": true,
"perm_edit_droplets": true,
"perm_view_registry": true,
"perm_edit_registry": true,
"perm_view_groups": true,
"perm_edit_groups": true,
"perm_view_instances": true,
"perm_edit_instances": true
}
]
}Add or modify a user group (requires perm_edit_groups).
POST /api/admin/group
Content-Type: application/json
{
"display_name": "Developer",
"protected": false,
"perm_admin_panel": false,
"perm_view_instances": true,
"perm_edit_instances": false,
"perm_view_users": false,
"perm_edit_users": false,
"perm_view_droplets": true,
"perm_edit_droplets": true,
"perm_view_registry": true,
"perm_edit_registry": false,
"perm_view_groups": false,
"perm_edit_groups": false
}Response:
{
"success": true,
"message": "Group created/updated successfully"
}Remove a user group (requires perm_edit_groups).
DELETE /api/admin/group
Content-Type: application/json
{
"group_id": "group-uuid"
}Response:
{
"success": true,
"message": "Group deleted successfully"
}Retrieve all configured registries (requires perm_view_registry).
GET /api/admin/registryResponse:
{
"success": true,
"flowcase_version": "develop",
"registry": [
{
"id": 1,
"url": "https://registry.flowcase.org",
"info": {
"name": "Flowcase Registry",
"description": "Official Flowcase droplet registry"
},
"droplets": [
{
"name": "Ubuntu Desktop",
"image": "ubuntu:20.04-desktop",
"description": "Ubuntu desktop environment"
}
]
}
]
}Manage container registries (requires perm_edit_registry).
POST /api/admin/registry
Content-Type: application/json
{
"url": "https://registry.company.com"
}DELETE /api/admin/registry
Content-Type: application/json
{
"registry_id": 3
}Response:
{
"success": true,
"message": "Registry added/deleted successfully"
}Retrieve application logs (requires perm_admin_panel).
GET /api/admin/logs?level=ERROR&page=1&per_page=50Query Parameters:
-
level- Filter by log level (ERROR, WARNING, INFO, DEBUG) -
page- Page number for pagination -
per_page- Number of logs per page
Response:
{
"success": true,
"logs": [
{
"id": 1,
"level": "ERROR",
"message": "Failed to connect to Docker daemon",
"created_at": "2024-01-15T10:30:00.000000"
}
],
"pagination": {
"current_page": 1,
"total_pages": 5,
"total_items": 250,
"per_page": 50
}
}| Endpoint | Required Permission |
|---|---|
/api/droplets |
User login |
/api/instances |
User login |
/api/instance/request |
User login |
/api/instance/{id}/destroy |
Owner or perm_edit_instances
|
/api/admin/users |
perm_view_users |
/api/admin/user (POST) |
perm_edit_users |
/api/admin/user (DELETE) |
perm_edit_users |
/api/admin/droplets |
perm_view_droplets |
/api/admin/droplet (POST) |
perm_edit_droplets |
/api/admin/droplet (DELETE) |
perm_edit_droplets |
/api/admin/groups |
perm_view_groups |
/api/admin/group (POST) |
perm_edit_groups |
/api/admin/group (DELETE) |
perm_edit_groups |
/api/admin/instances |
perm_view_instances |
/api/admin/instance (DELETE) |
perm_edit_instances |
/api/admin/registry |
perm_view_registry / perm_edit_registry
|
/api/admin/system_info |
perm_admin_panel |
/api/admin/logs |
perm_admin_panel |
Connect to a running droplet instance via WebSocket.
// WebSocket connection for VNC/desktop streaming
const ws = new WebSocket('ws://your-instance/desktop/{instance_id}/vnc/websockify');
// Connection events
ws.onopen = function(event) {
console.log('Connected to instance');
};
ws.onmessage = function(event) {
// Handle VNC data
handleVNCData(event.data);
};
ws.onclose = function(event) {
console.log('Disconnected from instance');
};[!INFO] Implementation Note: WebSocket connections are handled by the Guacamole streaming containers, not directly by the Flowcase API. The actual WebSocket endpoint depends on instance configuration.
Upload files to running instances.
// WebSocket for file uploads
const uploadWs = new WebSocket('ws://your-instance/desktop/{instance_id}/upload');
// Send file data
uploadWs.send(JSON.stringify({
'action': 'upload',
'filename': 'document.pdf',
'data': base64Data
}));Warning
Planned Feature: Dedicated file upload WebSocket endpoints are planned but not yet implemented. File uploads currently use standard HTTP endpoints through the container's web interface.
| HTTP Code | Description | Example Response |
|---|---|---|
| 200 | Success | {"success": true, "data": {}} |
| 400 | Bad Request | {"success": false, "error": "Invalid parameters"} |
| 401 | Unauthorized | {"success": false, "error": "Authentication required"} |
| 403 | Forbidden | {"success": false, "error": "Permission denied"} |
| 404 | Not Found | {"success": false, "error": "Resource not found"} |
| 500 | Server Error | {"success": false, "error": "Internal server error"} |
Authentication Error:
{
"success": false,
"error": "Authentication required",
"redirect": "/login"
}Permission Error:
{
"success": false,
"error": "Permission denied: perm_edit_users required"
}Validation Error:
{
"success": false,
"error": "Validation failed",
"details": {
"username": "Username is required",
"password": "Password must be at least 8 characters"
}
}import requests
import json
# Login
login_data = {
'username': 'admin',
'password': 'your_password',
'remember': 'on'
}
session = requests.Session()
response = session.post('http://flowcase.example.com/login', data=login_data)
if response.json()['success']:
# Get available droplets
droplets = session.get('http://flowcase.example.com/api/droplets')
print(json.dumps(droplets.json(), indent=2))
# Request new instance
instance_data = {
'droplet_id': 'droplet-uuid',
'resolution': '1920x1080'
}
new_instance = session.post(
'http://flowcase.example.com/api/instance/request',
json=instance_data
)
if new_instance.json()['success']:
instance_id = new_instance.json()['instance_id']
print(f"Instance created: {instance_id}")// Login function
async function login(username, password, remember = false) {
const formData = new FormData();
formData.append('username', username);
formData.append('password', password);
if (remember) formData.append('remember', 'on');
const response = await fetch('/login', {
method: 'POST',
body: formData,
credentials: 'include'
});
// Login returns a redirect, check if successful
return response.redirected && response.url.includes('dashboard');
}
// Get droplets function
async function getDroplets() {
const response = await fetch('/api/droplets', {
credentials: 'include'
});
return response.json();
}
// Create instance function
async function createInstance(dropletId, resolution = '1920x1080') {
const response = await fetch('/api/instance/request', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
droplet_id: dropletId,
resolution: resolution
}),
credentials: 'include'
});
return response.json();
}
// Usage
(async () => {
await login('admin', 'password');
const droplets = await getDroplets();
if (droplets.success && droplets.droplets.length > 0) {
const instance = await createInstance(droplets.droplets[0].id);
console.log('Instance created:', instance);
}
})();Login:
curl -X POST http://flowcase.example.com/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'username=admin&password=your_password&remember=on' \
-c cookies.txtGet Droplets:
curl -X GET http://flowcase.example.com/api/droplets \
-b cookies.txtCreate Instance:
curl -X POST http://flowcase.example.com/api/instance/request \
-H "Content-Type: application/json" \
-d '{"droplet_id":"droplet-uuid","resolution":"1920x1080"}' \
-b cookies.txtCreate User (Admin):
curl -X POST http://flowcase.example.com/api/admin/user \
-H "Content-Type: application/json" \
-d '{"username":"newuser","password":"password","groups":["user-group-uuid"]}' \
-b cookies.txt- Authentication: 5 requests per minute per IP
- Instance Creation: 10 requests per hour per user
- General API: 100 requests per minute per user
- File Upload: 1GB per hour per user
Warning
Planned Feature: Rate limiting is not currently enforced in the API implementation. These limits represent planned functionality for future releases.
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1642261800[!INFO] Future Implementation: Rate limit headers will be added when rate limiting is implemented.
GET /healthResponse:
{
"status": "healthy",
"version": "develop",
"timestamp": "2024-01-15T10:30:00Z",
"services": {
"database": "ok",
"docker": "ok",
"storage": "ok"
}
}GET /api/admin/metrics[!INFO] Planned Feature: The metrics endpoint is planned for future releases. Current system information is available through
/api/admin/system_info.
Response:
{
"success": true,
"metrics": {
"requests_per_minute": 45,
"active_sessions": 12,
"instances_running": 8,
"cpu_usage": 25.5,
"memory_usage": 60.2,
"disk_usage": 45.1
}
}For API-related questions or issues:
- Check the Troubleshooting Guide
- Review the FAQ
- Create an issue on GitHub
- Join the developer community discussions
Remember: Always test API calls in a development environment before implementing in production.