This document outlines the available API endpoints and helper scripts for the Azubi Werkzeug application.
All API requests are relative to the application root. When running locally: http://localhost:5000
Most endpoints require a valid user session (login). CSRF tokens are required for POST requests.
Returns a list of tools currently assigned to a specific Azubi.
- Parameters:
azubi_id(path): ID of the Azubi.
- Response: JSON array of objects.
[ {"id": 1, "name": "Hammer"}, {"id": 5, "name": "Zange"} ]
Performs a one-click tool exchange (Return old + Issue new).
- Content-Type:
application/x-www-form-urlencoded - Parameters:
azubi_id: ID of the Azubi.exchange_data: JSON string representing an array of selected tools and their reasons. Example:[{"tool_id": "1", "reason": "Defekt"}, {"tool_id": "5", "reason": "Verloren"}].is_payable: "on" if the Azubi must pay for the replacement (optional).signature_azubi_data: Base64 encoded PNG signature (data:image/png;base64,...).csrf_token: Valid CSRF token.
Fetches a paginated list of check sessions for dynamic "Load More" functionality on the frontend.
- Parameters (Query):
page(int, default: 1): The page number to retrieve.azubi_id(int or "all", default: "all"): Filter history by a specific Azubi.
- Response: JSON
{ "success": true, "sessions": [ ... ], "has_next": true, "next_page": 2, "total": 150 }
Consumes a single-use recovery token to securely log in and prompt the user to reset a forgotten admin PIN.
- Parameters:
token: The emergency recovery token (e.g.,RT-XXXX-XXXX).
Generates a new batch of 5 emergency recovery tokens. Invalidates all previously generated tokens immediately.
Health check endpoint for monitoring (e.g., Docker Healthcheck).
- Response: JSON
{"status": "healthy", "uptime": 123.45} - Status Codes:
200: OK500: Database or App failure
Prometheus metrics endpoint. Exposes application metrics like HTTP request durations (flask_http_request_duration_seconds), check submissions (werkzeug_checks_submitted_total), and scan counts (werkzeug_scans_total).
These commands are executed via the command line from the application root directory.
Manage database schemas seamlessly via Alembic.
flask db upgrade
flask db migrate -m "Description"Create a snapshot of the database, signatures, and config.
python backup.py- Output:
backups/backup_YYYYMMDD_HHMMSS.zip
Restore the application state from a specific backup.
python rollback.py <backup_filename>- Example:
python rollback.py backup_20260213_120000.zip - Warning: This overwrites the current database and signatures!