coach_agent feature enabled on the organization’s plan.
Generate a training plan draft
Produces a human-readable multi-week training plan draft in text form. The coach can review and edit the text before passing it to the generate-plan step.coach_agent feature required)
Duration of the training plan in weeks. Must be between 1 and 52.
Athlete experience level. One of
"beginner", "intermediate", or "advanced".Organization ID used to resolve the training principle for the plan.
Free-text instructions to guide the AI (e.g.
"Include two track sessions per week").Per-request training principle override. When set and non-empty, takes priority over the organization’s stored principle.
ISO 8601 date string for when the plan begins (e.g.
"2025-05-05").How to source workout content:
"ai_generate"— always generate new workouts"prefer_existing"— reuse existing organization workouts when available"strict_existing"— only use existing workouts; skip AI generation for gaps
200 OK
Full text of the AI-generated plan draft. Coaches can freely edit this before submitting to generate-plan.
The training principle that was used, resolved from the organization or per-request override.
Request parameters echoed back alongside a server-side
generated_at timestamp.Generate structured plan content
Converts a coach-approved draft into an array of structured workout objects, one per training day. Requires the same fields as generate-draft plus therefined_draft the coach approved or edited.
coach_agent feature required)
Number of weeks. Must match the draft that was generated.
"beginner", "intermediate", or "advanced".Organization ID.
The coach-edited draft text. Minimum 10 characters.
Additional guidance for the structured output phase.
Per-request principle override.
200 OK
Array of workout objects, one per training day across all weeks.
Week number within the plan (1-based).
Training phase label (e.g.
"base", "build", "peak", "taper").Workout sub-type (e.g.
"easy-run", "tempo", "long-run", "intervals").Target workout duration in seconds.
Target distance in meters.
Structured breakdown of the workout into segments (warmup, main, cooldown).
Per-week metadata keyed by week number string:
phase, focus, and total distance.Stream draft generation (SSE)
Same behavior asPOST /generate-draft but delivers real-time progress updates over a Server-Sent Events connection. The connection stays open until the done event is received.
coach_agent feature required)
Request body: Identical to POST /generate-draft.
Response: text/event-stream
| Type | Description |
|---|---|
progress | Intermediate status update. Fields: status, message, progress (0–100). |
result | Final payload. data field mirrors the synchronous 200 response body. |
error | Generation failed. Field: error (string). |
done | Stream finished. Always the last event. |
Stream plan content — incremental (SSE)
Streams structured workout objects one at a time as the AI generates them. Workouts appear progressively in the UI without waiting for the full plan to complete. This endpoint is the preferred streaming variant for the plan editor.coach_agent feature required)
Request body: Identical to POST /generate-plan (requires refined_draft).
Response: text/event-stream
| Type | Description |
|---|---|
workout | A single generated workout object. data field matches the content[] item schema. |
progress | Count-based progress update. Fields: status, message, count, total, progress. |
weekly_info | Emitted once all workouts for a given week are generated. data is a week-keyed object. |
result | Final summary. Fields: total_workouts (integer), weekly_info (full object). |
error | Generation failed. Field: error (string). |
done | Stream complete. Always the last event. |
Stream plan content — batch (SSE)
Alternative SSE endpoint that accumulates all workouts before emitting a singleresult event. Use this when progressive display is not needed and you prefer a simpler client implementation.
coach_agent feature required)
Request body: Identical to POST /generate-plan.
SSE event types: Same as the draft stream — progress, result, error, done. The result event data contains the full content array.
Get training principle
Returns the training principle configured for an organization. Coaches can use this to preview what the AI will use before generating a plan.coach_agent feature required)
The organization whose training principle to retrieve.
200 OK
The training principle text. Resolved from the coach’s personal settings first, then the organization’s settings.
Error codes
| Status | Meaning |
|---|---|
400 | Validation error — missing/invalid fields, refined_draft too short |
401 | Missing or invalid authentication |
403 | Coach role or coach_agent feature not present on the organization |
404 | Organization not found |
500 | Internal server error during AI generation |