# SwollStep Agent API Create workouts and Programs for an account owner using an app-generated bearer token. Docs are public; account requests require authentication. - [Developer portal](https://swollstep.app/docs) - [Agent guide](https://swollstep.app/docs/agent-guide.md) - [OpenAPI 3.1](https://swollstep.app/docs/openapi.json) - [Full text](https://swollstep.app/llms-full.txt) API base: https://fvgemdcvjuknvzdqkurt.supabase.co/functions/v1/agent-api Read the catalog first. Tokens are definition-read/create-only; no history access or edits/deletes. Use durable idempotency keys. Never share or log tokens. Send tokens only to the API base above. # Creating a SwollStep Program Use this guide alongside the public specification at https://fvgemdcvjuknvzdqkurt.supabase.co/functions/v1/agent-api/openapi.json. The account owner provides the API base URL and an opaque bearer token. Treat the token as a secret: keep it out of prompts intended for sharing, source control, tool output, and logs. 1. Call `GET /v1/catalog` with the token. Reuse existing exercise/workout UUIDs where appropriate. Catalogue fields are native Codable names (`enabledFields`, `distanceUnit`, `paceUnit`); request fields use the OpenAPI names (`fields`, `distance_unit`, `pace_unit`). Do not guess an exercise's attached fields from its name. 2. Build one `CreateProgram` document. Declare any new exercise definitions and new workout prescriptions, referencing them by request-local keys. Use optional labels and optional names. Put meaningful work in targets, and reserve instructions for technique/context. 3. Place direct exercises in block `items` when they need no grouping. For repeated identical bench sets, put one exercise in a group with `fields.rounds: 3`. Keep different ramp-up weights as individual exercise entries. For a timed repeated sequence, attach `duration_seconds`, `repetition: "untilDuration"`, and optional `tracks_rounds`. For intervals, attach duration and interval seconds. No category label is mandatory. 4. Choose inclusive floating start/end dates and weekly rules (Sunday=1, Saturday=7). Match dates, quantities, and training intent to the owner's request. If essential targets are unknown, obtain them from the owner; do not claim these are based on workout history, because this API does not expose it. 5. For progression, give the working prescription an optional step `key` and attach dated `changes` to each intended weekly rule. Use partial target patches (`weight_lb`, `reps`, etc.); they accumulate chronologically. Repeated identical working sets still use one group with rounds. Keep distinct ramp-up targets untouched unless requested. See `example-progression.json`. 6. Submit `POST /v1/programs` with a unique, durable `Idempotency-Key`. Save the exact body and key for retries. A successful 201/status created is immediately saved in normalized tables. A 422 response identifies invalid fields; fix them and use a new key if changing a previously accepted document. A 409 means a key was already used with different content. 7. Save returned workout/Program IDs and the operation receipt ID. Retrieve actual definitions immediately through GET /v1/workouts/{workout-id} or /v1/programs/{program-id}, or the receipt through /v1/operations/{receipt-id}. The owner opens/syncs the app to download these records; no app import/acknowledgement gates creation. For unscheduled Programs omit both start_date/end_date and use week-based changes. Never schedule a draft without the owner's instruction. Do not try to edit recorded results, change another account, update/delete existing Programs, or start/end a workout. Those actions are outside this token's scope. V1.1 supports weekly schedules with explicit dated target changes; it does not infer progressive overload from actual performance or edit existing Programs via token. Use dated patches for requested progression and preserve the other targets. The complete example in `example-program.json` illustrates direct warm-up, different ramp-up steps, and three identical working sets. Its dates are illustrative; choose dates for the actual request. ## Relative Programs and recording-only fields supply `program.week_count` (1–52) and seven `relative_days` with `day` 1–7, workout references, optional week-based target `changes`, `optional`, `rest_alternative`, and notes. Omit weekday rules and dates. The API expands stable week/day IDs and independent prescription snapshots. A rest-only day omits workout and sets rest_alternative=true; a workout with rest as an alternative must be optional. The app anchors Day 1 to an explicitly chosen start date only when scheduling. RRULE parsing is future work and independent of relative plans. See `return-to-training.json` for a complete unscheduled example. Steps can use `record_only_fields` for attached reps/duration/distance/pace/effort/stroke measurements without prescribing a target. These are still logged only when performed. Other attached fields keep required-target validation. ## API details # SwollStep Agent API Authoritative storage is normalized Postgres tables. JSON is HTTP transport and local app caching; the snapshot/inbox backend has been removed. See [backend architecture](../backend/NORMALIZED.md). Base: `https://fvgemdcvjuknvzdqkurt.supabase.co/functions/v1/agent-api` [Public OpenAPI](https://fvgemdcvjuknvzdqkurt.supabase.co/functions/v1/agent-api/openapi.json) is readable without a token. Create tokens in Settings → Agent API. Tokens expire after 90 days by default, are revocable/hashed/shown once, and grant catalogue reads and new-workout/Program creation only. They cannot edit existing records or results. Auth/API tokens and email settings survive the training reset. | Method | Route | Purpose | |---|---|---| | GET | `/v1/catalog` | Owned exercise/workout/recipe/Program definitions and schedule-entry count; no results. `include_archived=true` includes archived definitions. | | POST | `/v1/workouts` | Create library definitions only, without Program/dates/entries. | | POST | `/v1/programs` | Create a complete Program with existing/new definitions. Omit both dates for an unscheduled draft. | | GET | `/v1/workouts/{id}` | Read the actual workout definition by its UUID. | | GET | `/v1/programs/{id}` | Read the actual Program by UUID. | | GET | `/v1/operations/{id}` | Creation receipt and linked definitions. | POST requires `Authorization: Bearer swollstep_...`, `Content-Type: application/json`, and a durable `Idempotency-Key`. It returns **201 / created**, after all normalized rows commit. Records are immediately retrievable through the API, even with the app closed. The app downloads them on its next sync. Retry the same token/key/body to keep IDs. Different content with the same key returns 409. Duplicate names (including archived records) are checked transactionally; reuse owned UUIDs rather than creating duplicates. Input prescription format is unchanged: workouts contain ordered blocks with direct exercise items or groups, explicit attached execution fields, and structured targets. Unknown owner/result fields are rejected. Loads are pounds. Per-side reps and per-dumbbell loads use explicit scope/basis. Each attached reps/duration/distance/pace/effort/stroke field needs its target; load requires load_type and externalWeight requires weight_lb. Optional names default when omitted. Labels are metadata only. Programs accept weekday rules (Sunday=1 through Saturday=7) referencing workout keys/owned UUIDs. Optional changes use either relative `week` (1–52) or `effective_date`, plus partial step-target patches; reference an optional new step key or existing step UUID. Changes accumulate chronologically, and each scheduled occurrence has a frozen independent prescription. Absolute changes require scheduling dates; relative changes work in drafts and anchor when later scheduled. Both dates must be supplied together for scheduling, with an inclusive range of at most 366 days. No automatic performance-based progression is inferred. Library duration_progression_seconds is deprecated compatibility metadata; progression belongs in Program rules. See [fixed example](example-program.json), [progression example](example-progression.json), and [agent guide](AGENT_GUIDE.md). Recipe, exercise, target, actual-session, and history semantics are retained by normalized storage. No automatic re-creation of cleared user data is performed. Limits: 1 MiB request, 5 MiB expanded prescription bundle, 30 new operations/minute/token, 200 new exercises, 50 new workouts, 1,000 prescribed steps, 2,000 scheduled entries. Statuses: 401 invalid/expired token; 404 missing owned definition/receipt; 409 duplicate name/ID or idempotency conflict; 415 content type; 422 invalid prescription; 429 rate limit; 503 backend unavailable. Local validation: run Supabase locally, `supabase migration up --local`, `supabase functions serve agent-api`, then `python3 scripts/check-normalized-api.py`. The script refuses hosted URLs, creates/removes temporary accounts, and checks real database writes/readability, native graph decoding, owner isolation/FKs, idempotency, record conflicts, API appends alongside offline edits, and reset fencing. Deno schema tests and native domain/persistence checks remain available. The hosted check is read-only. Relative plans: supply `program.week_count` (1–52) and seven `relative_days` with `day` 1–7, workout references, optional week-based target `changes`, `optional`, `rest_alternative`, and notes. Omit weekday rules and dates. The API expands stable week/day IDs and independent prescription snapshots. A rest-only day omits workout and sets rest_alternative=true; a workout with rest as an alternative must be optional. The app anchors Day 1 to an explicitly chosen start date only when scheduling. RRULE parsing is future work and independent of relative plans. See `return-to-training.json` for a complete unscheduled example. Steps can use `record_only_fields` for attached reps/duration/distance/pace/effort/stroke measurements without prescribing a target. These are still logged only when performed. Other attached fields keep required-target validation. ## OpenAPI { "openapi": "3.1.0", "info": { "title": "SwollStep Agent API", "version": "1.0.0", "description": "Creation-only Program API. Bearer tokens are created in the SwollStep app under Settings → Agent API. Read /v1/catalog to resolve owned exercise/workout UUIDs. POST /v1/programs requires Idempotency-Key and creates normalized database rows transactionally; 201 means created and immediately readable. The app downloads changes on sync. GET /v1/programs/{id} accepts a native Program ID. Use /v1/operations/{id} for creation receipts. Unknown/result/owner fields are rejected. Dates are floating and inclusive, with Sunday=1; the maximum range is 366 days. Every attached reps/duration/distance/pace/effort/stroke field requires its target. Load requires load_type, and externalWeight requires weight_lb (pounds). Rounds cannot combine with duration; repetition cannot combine with rounds or intervals; untilDuration and intervals require duration. Interval duration must be evenly divisible by interval_seconds, with at most 1,000 intervals. Rest between rounds requires rounds or untilDuration. Weekly rules accept changes with effective_date and per-step target patches. Patches accumulate chronologically, retaining previous targets when omitted. A step reference is an optional key declared on a new step or an existing catalogue step UUID. Changes apply only to that rule from their date onward; the library base remains unchanged. No automatic performance-based progression is inferred. Request limit 1 MiB; expanded schedule limit 5 MiB; 30 creations/minute/token. Retry the identical request with the same token/key to retain IDs. Public specification: /openapi.json. POST /v1/workouts creates workout definitions only, with no Program or dates. It uses the same Idempotency-Key and direct database creation flow. GET /v1/workouts/{workout-id} returns the saved definition; GET /v1/operations/{receipt-id} returns the creation receipt. Workout duration_progression_seconds is a reference plan, not an automatic schedule. Programs may be unscheduled: omit both start_date/end_date to save a draft and generate no entries. Draft changes use week (1–52) instead of effective_date; scheduling later anchors weeks to start_date. Weekly progression belongs to Program rules, not exercise definitions or library workouts. Training data is authoritative in typed normalized tables. Account snapshot and import-queue tables have been removed. Tokens remain read-catalogue/create-only; they cannot edit results. Relative plans use week_count and seven relative_days (day 1–7), without rules or dates. Each expanded week and day has a stable ID and independent prescription. Changes must use week within week_count. Optional workouts may declare rest_alternative; rest-only days omit workout and require rest_alternative=true. No dates or entries are created for these drafts. RRULE parsing is not implemented." }, "servers": [ { "url": "https://fvgemdcvjuknvzdqkurt.supabase.co/functions/v1/agent-api", "description": "Hosted Supabase" }, { "url": "http://127.0.0.1:55321/functions/v1/agent-api", "description": "Local development" } ], "security": [ { "agentToken": [] } ], "paths": { "/v1/catalog": { "get": { "operationId": "getCatalog", "responses": { "200": { "description": "Latest uploaded catalogue; excludes history", "content": { "application/json": { "schema": { "type": "object" } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "503": { "description": "Unavailable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "parameters": [ { "name": "include_archived", "in": "query", "schema": { "type": "boolean", "default": false }, "description": "Include owned archived definitions for inspection/reuse." } ] } }, "/v1/programs": { "post": { "operationId": "createProgram", "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": true, "schema": { "type": "string", "pattern": "^[A-Za-z0-9._:-]{1,128}$" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateProgram" }, "examples": { "fixed": { "summary": "Fixed targets", "value": { "exercises": [ { "key": "bench", "name": "Bench press", "fields": [ "load", "reps", "rest" ] }, { "key": "walk", "name": "Brisk walk", "fields": [ "duration" ] } ], "workouts": [ { "key": "strength", "title": "Strength day", "color": "blue", "blocks": [ { "title": "Warm-up", "items": [ { "exercise": "walk", "targets": { "duration_seconds": 300 } } ] }, { "title": "Bench press", "items": [ { "title": "Ramp-up", "exercises": [ { "exercise": "bench", "targets": { "load_type": "externalWeight", "weight_lb": 45, "reps": 10, "rest_seconds": 60 } }, { "exercise": "bench", "targets": { "load_type": "externalWeight", "weight_lb": 95, "reps": 5, "rest_seconds": 60 } } ] }, { "title": "Working sets", "fields": { "rounds": 3 }, "exercises": [ { "exercise": "bench", "targets": { "load_type": "externalWeight", "weight_lb": 140, "reps": 8, "rest_seconds": 90 } } ] } ] } ] } ], "program": { "title": "Three-day strength", "start_date": "2026-10-13", "end_date": "2026-11-13", "rules": [ { "weekday": 2, "workout": "strength" }, { "weekday": 4, "workout": "strength" }, { "weekday": 6, "workout": "strength" } ] } } }, "progression": { "summary": "One workout with dated bench progression", "value": { "exercises": [ { "key": "bench", "name": "Bench press", "fields": [ "load", "reps", "rest" ] }, { "key": "walk", "name": "Brisk walk", "fields": [ "duration" ] } ], "workouts": [ { "key": "strength", "title": "Strength day", "color": "blue", "blocks": [ { "title": "Warm-up", "items": [ { "exercise": "walk", "targets": { "duration_seconds": 300 } } ] }, { "title": "Bench press", "items": [ { "title": "Ramp-up", "exercises": [ { "exercise": "bench", "targets": { "load_type": "externalWeight", "weight_lb": 45, "reps": 10, "rest_seconds": 60 } }, { "exercise": "bench", "targets": { "load_type": "externalWeight", "weight_lb": 95, "reps": 5, "rest_seconds": 60 } } ] }, { "title": "Working sets", "fields": { "rounds": 3 }, "exercises": [ { "exercise": "bench", "targets": { "load_type": "externalWeight", "weight_lb": 140, "reps": 8, "rest_seconds": 90 }, "key": "working_bench" } ] } ] } ] } ], "program": { "title": "Progressive strength", "start_date": "2026-10-12", "end_date": "2026-11-08", "rules": [ { "weekday": 2, "workout": "strength", "changes": [ { "effective_date": "2026-10-19", "targets": [ { "step": "working_bench", "targets": { "weight_lb": 145 } } ] }, { "effective_date": "2026-11-02", "targets": [ { "step": "working_bench", "targets": { "weight_lb": 150 } } ] } ] }, { "weekday": 4, "workout": "strength", "changes": [ { "effective_date": "2026-10-19", "targets": [ { "step": "working_bench", "targets": { "weight_lb": 145 } } ] }, { "effective_date": "2026-11-02", "targets": [ { "step": "working_bench", "targets": { "weight_lb": 150 } } ] } ] }, { "weekday": 6, "workout": "strength", "changes": [ { "effective_date": "2026-10-19", "targets": [ { "step": "working_bench", "targets": { "weight_lb": 145 } } ] }, { "effective_date": "2026-11-02", "targets": [ { "step": "working_bench", "targets": { "weight_lb": 150 } } ] } ] } ] } } } } } } }, "responses": { "201": { "description": "Created atomically in normalized tables; immediately readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Receipt" } } } }, "400": { "description": "Missing/invalid idempotency key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Idempotency conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "415": { "description": "Unsupported content type", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Invalid prescription", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "429": { "description": "Limit reached", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "503": { "description": "Unavailable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/v1/programs/{id}": { "get": { "operationId": "getProgram", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Native Program UUID" } ], "responses": { "200": { "description": "Import receipt", "content": { "application/json": { "schema": { "type": "object", "description": "Native Program definition with ordered rules and progression." } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "503": { "description": "Unavailable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/openapi.json": { "get": { "operationId": "getOpenAPISpec", "security": [], "summary": "Public OpenAPI specification; no token required", "responses": { "200": { "description": "OpenAPI 3.1 document", "content": { "application/json": { "schema": { "type": "object" } } } } } } }, "/v1/workouts": { "post": { "operationId": "createWorkouts", "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": true, "schema": { "type": "string", "pattern": "^[A-Za-z0-9._:-]{1,128}$" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateWorkouts" } } } }, "responses": { "201": { "description": "Created atomically in normalized tables; immediately readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Receipt" } } } }, "400": { "description": "Missing/invalid idempotency key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Idempotency conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "415": { "description": "Unsupported content type", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Invalid prescription", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "429": { "description": "Limit reached", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "503": { "description": "Unavailable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/v1/operations/{id}": { "get": { "operationId": "getCreationOperation", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Import receipt ID returned by POST, not the native Program ID." } ], "responses": { "200": { "description": "Import receipt plus canonical workouts and exercise definitions", "content": { "application/json": { "schema": { "allOf": [ { "$ref": "#/components/schemas/Receipt" }, { "type": "object", "properties": { "workouts": { "type": "array", "items": { "type": "object" } }, "exercises": { "type": "array", "items": { "type": "object" } } } } ] } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "503": { "description": "Unavailable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/v1/workouts/{id}": { "get": { "operationId": "getWorkout", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Native workout UUID" } ], "responses": { "200": { "description": "Import receipt", "content": { "application/json": { "schema": { "type": "object", "description": "Native Codable workout prescription with ordered blocks/groups/steps." } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "503": { "description": "Unavailable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } } }, "components": { "securitySchemes": { "agentToken": { "type": "http", "scheme": "bearer", "bearerFormat": "swollstep_ + 64 lowercase hex characters" } }, "schemas": { "CreateProgram": { "type": "object", "additionalProperties": false, "properties": { "exercises": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "key": { "type": "string", "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$", "maxLength": 80 }, "name": { "type": "string", "maxLength": 200, "minLength": 1 }, "fields": { "type": "array", "items": { "type": "string", "enum": [ "load", "reps", "duration", "distance", "pace", "effort", "stroke", "rest", "repsInReserve", "equipment" ] }, "minItems": 1, "maxItems": 10, "uniqueItems": true }, "distance_unit": { "type": "string", "enum": [ "meters", "kilometers", "miles", "yards" ] }, "pace_unit": { "type": "string", "enum": [ "perKilometer", "perMile", "per100Meters", "per100Yards" ] } }, "required": [ "key", "name", "fields" ] }, "minItems": 0, "maxItems": 200 }, "workouts": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "key": { "type": "string", "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$", "maxLength": 80 }, "title": { "type": "string", "maxLength": 200 }, "color": { "type": "string", "enum": [ "indigo", "blue", "green", "orange", "pink", "purple" ] }, "blocks": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "title": { "type": "string", "maxLength": 200 }, "labels": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 80 }, "minItems": 0, "maxItems": 20 }, "items": { "type": "array", "items": { "oneOf": [ { "$ref": "#/components/schemas/Step" }, { "$ref": "#/components/schemas/Group" } ] }, "minItems": 1, "maxItems": 100 } }, "required": [ "items" ] }, "minItems": 1, "maxItems": 50 }, "description": { "type": "string", "maxLength": 4000 }, "labels": { "type": "array", "items": { "type": "string", "maxLength": 80 }, "maxItems": 20 }, "estimated_duration_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "duration_progression_seconds": { "type": "array", "minItems": 1, "maxItems": 52, "items": { "type": "integer", "minimum": 1, "maximum": 86400 }, "description": "Ordered reference duration targets, typically one per week. Does not create dates, Programs or schedule entries." } }, "required": [ "key", "blocks" ] }, "minItems": 0, "maxItems": 50 }, "program": { "type": "object", "additionalProperties": false, "properties": { "title": { "type": "string", "maxLength": 200 }, "start_date": { "type": "string", "format": "date", "description": "Optional. Provide both start_date and end_date only when scheduling." }, "end_date": { "type": "string", "format": "date", "description": "Optional. Omit both dates for an unscheduled Program." }, "rules": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "weekday": { "type": "integer", "minimum": 1, "maximum": 7, "description": "Sunday=1 through Saturday=7" }, "workout": { "type": "string", "maxLength": 80, "description": "New workout key or available catalogue UUID" }, "changes": { "type": "array", "maxItems": 100, "items": { "type": "object", "additionalProperties": false, "required": [ "targets" ], "properties": { "effective_date": { "type": "string", "format": "date", "description": "Unique effective date within the Program range. Changes accumulate in chronological order." }, "targets": { "type": "array", "minItems": 1, "maxItems": 1000, "items": { "type": "object", "additionalProperties": false, "required": [ "step", "targets" ], "properties": { "step": { "type": "string", "maxLength": 80, "description": "Step key declared on this workout or existing catalogue step UUID." }, "targets": { "$ref": "#/components/schemas/TargetPatch" } } } }, "week": { "type": "integer", "minimum": 1, "maximum": 52, "description": "Program-relative week. Works without calendar dates." } }, "oneOf": [ { "required": [ "week" ], "not": { "required": [ "effective_date" ] } }, { "required": [ "effective_date" ], "not": { "required": [ "week" ] } } ] } } }, "required": [ "weekday", "workout" ] }, "minItems": 1, "maxItems": 40 }, "description": { "type": "string", "maxLength": 4000 }, "week_count": { "type": "integer", "minimum": 1, "maximum": 52 }, "relative_days": { "type": "array", "minItems": 7, "maxItems": 7, "description": "Unscheduled relative plan: each Day 1–7 exactly once. Expands into week_count weeks with independent prescriptions. Mutually exclusive with rules and dates.", "items": { "type": "object", "additionalProperties": false, "required": [ "day" ], "properties": { "day": { "type": "integer", "minimum": 1, "maximum": 7 }, "workout": { "type": "string", "maxLength": 80 }, "optional": { "type": "boolean" }, "rest_alternative": { "type": "boolean" }, "notes": { "type": "string", "maxLength": 4000 }, "changes": { "type": "array", "maxItems": 100, "items": { "type": "object", "additionalProperties": false, "required": [ "targets" ], "properties": { "effective_date": { "type": "string", "format": "date", "description": "Unique effective date within the Program range. Changes accumulate in chronological order." }, "targets": { "type": "array", "minItems": 1, "maxItems": 1000, "items": { "type": "object", "additionalProperties": false, "required": [ "step", "targets" ], "properties": { "step": { "type": "string", "maxLength": 80, "description": "Step key declared on this workout or existing catalogue step UUID." }, "targets": { "$ref": "#/components/schemas/TargetPatch" } } } }, "week": { "type": "integer", "minimum": 1, "maximum": 52, "description": "Program-relative week. Works without calendar dates." } }, "oneOf": [ { "required": [ "week" ], "not": { "required": [ "effective_date" ] } }, { "required": [ "effective_date" ], "not": { "required": [ "week" ] } } ] } } } } } }, "required": [], "oneOf": [ { "required": [ "rules" ], "not": { "required": [ "relative_days" ] } }, { "required": [ "relative_days", "week_count" ], "not": { "anyOf": [ { "required": [ "rules" ] }, { "required": [ "start_date" ] }, { "required": [ "end_date" ] } ] } } ] } }, "required": [ "program" ] }, "Targets": { "type": "object", "additionalProperties": false, "properties": { "load_type": { "type": "string", "enum": [ "bodyweight", "externalWeight", "none" ] }, "weight_lb": { "type": "number", "minimum": 0, "maximum": 10000 }, "reps": { "type": "integer", "minimum": 1, "maximum": 100000 }, "rep_scope": { "type": "string", "enum": [ "total", "perSide", "perDirection" ] }, "weight_basis": { "type": "string", "enum": [ "total", "perDumbbell" ] }, "duration_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "distance": { "type": "number", "minimum": 0.000001, "maximum": 1000000 }, "pace_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "effort": { "type": "string", "enum": [ "easy", "moderate", "hard", "maximal" ] }, "stroke": { "type": "string", "enum": [ "freestyle", "backstroke", "breaststroke", "butterfly", "mixed" ] }, "rest_seconds": { "type": "integer", "minimum": 0, "maximum": 86400 }, "reps_in_reserve": { "type": "integer", "minimum": 0, "maximum": 100 }, "equipment": { "type": "string", "maxLength": 200 } } }, "Step": { "type": "object", "additionalProperties": false, "properties": { "exercise": { "type": "string", "maxLength": 80, "description": "New exercise key or available catalogue UUID." }, "title": { "type": "string", "maxLength": 200 }, "labels": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 80 }, "minItems": 0, "maxItems": 20 }, "instructions": { "type": "string", "maxLength": 2000 }, "targets": { "$ref": "#/components/schemas/Targets" }, "key": { "type": "string", "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$", "maxLength": 80, "description": "Optional unique step key within a workout, used by dated target changes." }, "record_only_fields": { "type": "array", "maxItems": 6, "uniqueItems": true, "items": { "type": "string", "enum": [ "reps", "duration", "distance", "pace", "effort", "stroke" ] }, "description": "Attached measurements to record without requiring a prescribed target. Actual results remain empty until performed." } }, "required": [ "exercise", "targets" ] }, "Group": { "type": "object", "additionalProperties": false, "properties": { "title": { "type": "string", "maxLength": 200 }, "labels": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 80 }, "minItems": 0, "maxItems": 20 }, "fields": { "type": "object", "additionalProperties": false, "properties": { "rounds": { "type": "integer", "minimum": 1, "maximum": 100 }, "duration_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "interval_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "rest_between_rounds_seconds": { "type": "integer", "minimum": 0, "maximum": 86400 }, "repetition": { "type": "string", "enum": [ "once", "untilDuration" ] }, "tracks_rounds": { "type": "boolean" } } }, "exercises": { "type": "array", "items": { "$ref": "#/components/schemas/Step" }, "minItems": 1, "maxItems": 100 } }, "required": [ "exercises" ] }, "Receipt": { "type": "object", "additionalProperties": false, "properties": { "id": { "type": "string", "format": "uuid", "description": "Creation operation ID; use /v1/operations/{id} for its receipt." }, "status": { "type": "string", "enum": [ "created" ] }, "created_at": { "type": "string", "format": "date-time" }, "programs": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "id": { "type": "string", "format": "uuid" }, "title": { "type": "string" } }, "required": [ "id", "title" ] }, "minItems": 0, "maxItems": 100 }, "workout_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "minItems": 0, "maxItems": 100 } }, "required": [ "id", "status", "created_at", "programs", "workout_ids" ] }, "Error": { "type": "object", "additionalProperties": false, "properties": { "error": { "type": "string" } }, "required": [ "error" ] }, "TargetPatch": { "type": "object", "additionalProperties": false, "properties": { "load_type": { "type": "string", "enum": [ "bodyweight", "externalWeight", "none" ] }, "weight_lb": { "type": "number", "minimum": 0, "maximum": 10000 }, "reps": { "type": "integer", "minimum": 1, "maximum": 100000 }, "rep_scope": { "type": "string", "enum": [ "total", "perSide", "perDirection" ] }, "weight_basis": { "type": "string", "enum": [ "total", "perDumbbell" ] }, "duration_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "distance": { "type": "number", "minimum": 0.000001, "maximum": 1000000 }, "pace_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "effort": { "type": "string", "enum": [ "easy", "moderate", "hard", "maximal" ] }, "stroke": { "type": "string", "enum": [ "freestyle", "backstroke", "breaststroke", "butterfly", "mixed" ] }, "rest_seconds": { "type": "integer", "minimum": 0, "maximum": 86400 }, "reps_in_reserve": { "type": "integer", "minimum": 0, "maximum": 100 }, "equipment": { "type": "string", "maxLength": 200 } }, "minProperties": 1, "description": "Partial target changes; omitted targets retain their previous value. Only attached fields may change. load_type=bodyweight/none clears an omitted external weight." }, "CreateWorkouts": { "type": "object", "additionalProperties": false, "required": [ "workouts" ], "properties": { "exercises": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "key": { "type": "string", "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$", "maxLength": 80 }, "name": { "type": "string", "maxLength": 200, "minLength": 1 }, "fields": { "type": "array", "items": { "type": "string", "enum": [ "load", "reps", "duration", "distance", "pace", "effort", "stroke", "rest", "repsInReserve", "equipment" ] }, "minItems": 1, "maxItems": 10, "uniqueItems": true }, "distance_unit": { "type": "string", "enum": [ "meters", "kilometers", "miles", "yards" ] }, "pace_unit": { "type": "string", "enum": [ "perKilometer", "perMile", "per100Meters", "per100Yards" ] } }, "required": [ "key", "name", "fields" ] }, "minItems": 0, "maxItems": 200 }, "workouts": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "key": { "type": "string", "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$", "maxLength": 80 }, "title": { "type": "string", "maxLength": 200 }, "color": { "type": "string", "enum": [ "indigo", "blue", "green", "orange", "pink", "purple" ] }, "blocks": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "title": { "type": "string", "maxLength": 200 }, "labels": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 80 }, "minItems": 0, "maxItems": 20 }, "items": { "type": "array", "items": { "oneOf": [ { "$ref": "#/components/schemas/Step" }, { "$ref": "#/components/schemas/Group" } ] }, "minItems": 1, "maxItems": 100 } }, "required": [ "items" ] }, "minItems": 1, "maxItems": 50 }, "description": { "type": "string", "maxLength": 4000 }, "labels": { "type": "array", "items": { "type": "string", "maxLength": 80 }, "maxItems": 20 }, "estimated_duration_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 }, "duration_progression_seconds": { "type": "array", "minItems": 1, "maxItems": 52, "items": { "type": "integer", "minimum": 1, "maximum": 86400 }, "description": "Ordered reference duration targets, typically one per week. Does not create dates, Programs or schedule entries.", "deprecated": true } }, "required": [ "key", "blocks" ] }, "minItems": 1, "maxItems": 50 } } } } } }