API-Referenz

REST-API für das KI-Task-Management System.

Base-URL/api/v1/tasks
FormatJSON
AuthentifizierungKeine (lokales Netzwerk)

Endpoints

Tasks

MethodeEndpointBeschreibung
GET/api/v1/tasksListe aller Tasks
GET/api/v1/tasks/{id}Task-Details
POST/api/v1/tasksTask erstellen
PUT/api/v1/tasks/{id}Task aktualisieren
DELETE/api/v1/tasks/{id}Task löschen
GET/api/v1/tasks/statisticsStatistiken

Zuweisungen & Ergebnisse

MethodeEndpointBeschreibung
POST/api/v1/tasks/{id}/assignTask zuweisen
PUT/api/v1/tasks/{id}/statusStatus ändern
GET/api/v1/tasks/{id}/resultsErgebnisse abrufen
POST/api/v1/tasks/{id}/resultsErgebnis speichern
POST/api/v1/tasks/{id}/executeKI-Ausführung

GET /api/v1/tasks

Listet alle Tasks mit optionalen Filtern.

Query-Parameter

ParameterTypBeschreibung
statusstringpending, in_progress, completed, failed, cancelled
typestringhuman_task, ai_task, mixed
searchstringSuche in Titel/Beschreibung
limitintMax. Anzahl (default: 50)
offsetintOffset für Paginierung

Beispiel

curl "http://localhost/api/v1/tasks?status=pending&limit=10"

Response

{
  "success": true,
  "data": [
    {
      "id": 1,
      "uuid": "abc-123-...",
      "title": "Analyse durchführen",
      "type": "ai_task",
      "status": "pending",
      "created_by": "root",
      "created_at": "2025-12-20 10:00:00"
    }
  ],
  "meta": {
    "total": 42,
    "limit": 10,
    "offset": 0
  }
}

POST /api/v1/tasks

Erstellt einen neuen Task.

Request-Body

{
  "title": "Analyse durchführen",        // required
  "description": "Details...",           // optional
  "type": "ai_task",                     // optional: human_task, ai_task, mixed
  "created_by": "user",                  // optional
  "created_by_type": "human",            // optional: human, ai
  "due_date": "2025-12-31 23:59:59",    // optional
  "parent_task_id": 1,                   // optional
  "metadata": {"key": "value"}           // optional
}

Beispiel

curl -X POST http://localhost/api/v1/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Daten analysieren",
    "type": "ai_task"
  }'

Response (201 Created)

{
  "success": true,
  "data": {
    "id": 2,
    "uuid": "def-456-...",
    "title": "Daten analysieren",
    "status": "pending",
    ...
  }
}

GET /api/v1/tasks/{id}

Gibt Task-Details inkl. Zuweisungen, Ergebnisse und Subtasks zurück.

Response

{
  "success": true,
  "data": {
    "task": { ... },
    "assignments": [ ... ],
    "results": [ ... ],
    "subtasks": [ ... ]
  }
}

POST /api/v1/tasks/{id}/assign

Weist einen Task einem Bearbeiter zu.

Request-Body

{
  "assignee": "ollama",                  // required
  "assignee_type": "ollama",             // required: human, ollama, claude, anthropic_api
  "model_name": "mistral",               // optional
  "assigned_by": "user",                 // optional
  "notes": "Bitte priorisieren"          // optional
}

PUT /api/v1/tasks/{id}/status

Ändert den Task-Status.

Request-Body

{
  "status": "in_progress",               // required
  "updated_by": "user",                  // optional
  "updated_by_type": "human"             // optional
}

Erlaubte Übergänge

VonNach
pendingin_progress, cancelled
in_progresscompleted, failed, cancelled
completed/failed/cancelled(keine)

POST /api/v1/tasks/{id}/execute

Führt einen Task mit KI aus.

Request-Body

{
  "executor_type": "ollama",             // optional: ollama, anthropic_api
  "model": "mistral",                    // optional
  "auto_complete": true,                 // optional: Task nach Erfolg abschließen
  "additional_context": "..."            // optional: Zusätzlicher Kontext
}

Response

{
  "success": true,
  "data": {
    "id": 1,
    "task_id": 2,
    "executor": "ollama",
    "model_name": "mistral",
    "response": "Die Analyse ergab...",
    "tokens_input": 150,
    "tokens_output": 420,
    "tokens_total": 570,
    "duration_ms": 12500,
    "status": "success"
  }
}

Error-Responses

// 400 Bad Request
{
  "success": false,
  "error": "Title is required"
}

// 404 Not Found
{
  "success": false,
  "error": "Task not found"
}

// 500 Internal Server Error
{
  "success": false,
  "error": "Database connection failed"
}