Routes & API
Routes & API
Complete documentation for all API routes.
Route Structure
All routes are prefixed with /api:
/api/agents- Agent management/api/matches- Match operations/api/events- Event queries/api/config- Configuration/api/kestra- Kestra integration/api/oumi- Oumi integration
Route Handlers
Agents Routes
Located in backend/src/routes/agents.ts:
GET /api/agents- List all agentsGET /api/agents/models- Get available modelsGET /api/agents/:id- Get agent by IDPOST /api/agents- Create agentPATCH /api/agents/:id- Update agentDELETE /api/agents/:id- Delete agent
Matches Routes
Located in backend/src/routes/matches.ts:
GET /api/matches- List all matchesGET /api/matches/:id- Get match by IDPOST /api/matches- Create and start matchGET /api/matches/:id/events- Get match eventsGET /api/matches/:id/transcript- Get match transcriptPOST /api/matches/:id/pause- Pause matchPOST /api/matches/:id/resume- Resume matchPOST /api/matches/:id/stop- Stop match
Events Routes
Located in backend/src/routes/events.ts:
GET /api/events- List recent eventsGET /api/events/:id- Get event by ID
Config Routes
Located in backend/src/routes/config.ts:
GET /api/config/config- Get configurationPOST /api/config/keys- Update API keysPOST /api/config/kestra- Update Kestra configDELETE /api/config/keys- Clear API keys
Kestra Routes
Located in backend/src/routes/kestra.ts:
POST /api/kestra/trigger/:flowId- Trigger flowGET /api/kestra/executions- List executionsGET /api/kestra/executions/:id- Get execution
Oumi Routes
Located in backend/src/routes/oumi.ts:
POST /api/oumi/export-dataset- Export datasetPOST /api/oumi/fine-tune- Trigger fine-tuningGET /api/oumi/fine-tune/:jobId- Get job status
Error Handling
All routes use consistent error handling:
try { // Route logic} catch (error) { if (error instanceof ValidationError) { res.status(400).json({ error: error.message }); } else if (error instanceof NotFoundError) { res.status(404).json({ error: error.message }); } else { res.status(500).json({ error: 'Internal server error' }); }}Validation
Routes validate input using Zod schemas:
const createAgentSchema = z.object({ name: z.string().min(1), type: z.enum(['red', 'blue', 'target']), model: z.string(), systemPrompt: z.string(), permissions: z.array(z.string()).optional()});Authentication
Currently, the API has no authentication. For production:
- Add authentication middleware
- Protect sensitive routes
- Implement API key or JWT tokens
CORS
CORS is configured in backend/src/index.ts:
app.use(cors({ origin: CORS_ORIGIN, credentials: true,}));Next Steps
- Agents API - Complete agents API reference
- Matches API - Complete matches API reference
- Events API - Complete events API reference