} */ $data = readJsonBody(); $botName = trim($data['BotName'] ?? ''); $title = trim($data['Title'] ?? ''); $channel = trim($data['Channel'] ?? ''); $notes = trim($data['Notes'] ?? ''); $assignedBy = trim($data['AssignedBy'] ?? ''); // Validate required fields if ($botName === '' || $title === '') { http_response_code(400); apiAbort(['OK' => false, 'ERROR' => 'BotName and Title are required']); } // Length guards if (strlen($botName) > 50) { http_response_code(400); apiAbort(['OK' => false, 'ERROR' => 'BotName max 50 characters']); } if (strlen($title) > 255) { http_response_code(400); apiAbort(['OK' => false, 'ERROR' => 'Title max 255 characters']); } try { queryTimed(" INSERT INTO TeamTasks (BotName, Title, Status, Channel, StartedOn, Notes, AssignedBy) VALUES (?, ?, 'active', ?, NOW(), ?, ?) ", [ $botName, $title, $channel ?: null, $notes ?: null, $assignedBy ?: null, ]); $id = (int) lastInsertId(); jsonResponse(['OK' => true, 'ID' => $id]); } catch (Throwable $e) { http_response_code(500); apiAbort(['OK' => false, 'ERROR' => 'Failed to create task: ' . $e->getMessage()]); }