{"openapi":"3.1.0","info":{"title":"The Split API","version":"1.0.0","description":"The Split edits cycling, running and swimming recordings: merge a heart-rate strap into a watch file, fix heart-rate glitches, crop, split, join, relabel the sport and re-lap. This is the same engine the website uses.\n\nWorkflow: POST /activities to upload a FIT, TCX or GPX file and get an activityId; call operations with that id (each operation that changes the data stages a NEW activity and returns its id, leaving the input untouched); GET /activities/{id}/export?format=fit to download the result; DELETE every activity you are done with.\n\nStorage and lifetime: files are held in memory only on one server and are never written to disk. Every activity expires: by default 30 minutes after the last request that used it (a sliding window) and in any case 2 hours after it was created. Every 2xx JSON response about a staged activity carries expiresAt (epoch milliseconds) for the activity it concerns; a split states it on partA and partB. The binary export states it in the X-Activity-Expires-At header. An expired or deleted id is 404 activity_not_found; an id removed by the per-client limit below is 404 activity_evicted, so re-upload it. Clients SHOULD DELETE an activity when they are done with it, including intermediate results, instead of leaving it to expire.\n\nLimits: uploads up to 15 MB (413 file_too_large) and 80,000 records by default (422 activity_too_large; joins too), JSON request bodies up to 64 KB (413 request_too_large). Each client address can hold only a few activities at once (12 by default, results of operations included); staging one more evicts that client's oldest derived result first, then its least recently used upload, so DELETE what you no longer need; a later call with an evicted id is 404 activity_evicted (not activity_not_found), shown only to the client it happened to. Requests are rate limited per client address and call class; over the limit is 429 rate_limited with a Retry-After header, a full service is 503 capacity_exceeded with Retry-After, and a service already running as many heavy operations as it allows is 503 server_busy with Retry-After. Honour Retry-After.\n\nWorkflows: for a whole job (clean up a recording, combine two recordings of one workout, fix a multisport file, join an interrupted workout) POST /workflows/<name>/analyze, show the user the proposed steps, then POST /workflows/plans/{planId}/apply with the confirmed step ids. The same workflows are tools of the MCP server at /mcp.\n\nAccess: no authentication, no API key and no account. Anonymous use is the intended mode.\n\nErrors: every non-2xx JSON response is { error: { code, message, details? } }; branch on code."},"servers":[{"url":"https://thesplit.fit","description":"Production"}],"tags":[{"name":"activities","description":"Upload, inspect, chart, export and delete staged activities."},{"name":"merge","description":"Merge a heart-rate strap, or a second recording of the same ride, into an activity."},{"name":"operations","description":"Crop, split, concatenate, relabel, re-lap and repair activities."},{"name":"hr-glitches","description":"Find and repair heart-rate sensor spikes."},{"name":"workflows","description":"Whole jobs in two calls: analyze (propose a plan) and apply (run the steps the user confirmed)."},{"name":"service","description":"Health and this description."}],"paths":{"/api/v1/activities":{"post":{"operationId":"uploadActivity","summary":"Upload a FIT, TCX or GPX file and stage it as an activity","description":"Send one file as multipart/form-data in the field named `file`. The file extension (.fit, .tcx, .gpx, case-insensitive) selects the parser. Maximum upload size is 15 MB (413 file_too_large), and a file holding more records than the service accepts (80,000 by default, about 22 hours at one record per second; details.maxRecords states the limit in force) is refused (422 activity_too_large), counted from the file before it is decoded. The file is parsed once and held in memory only: nothing is written to disk and it is discarded when it expires (see expiresAt) or when you DELETE it. Returns the activityId every other call needs. 201 on success. A .fit file the decoder cannot read is not an error: it is staged as an empty activity (sessionsCount 0, no streams) with a warning whose code is decode_error, so check warnings before using the id. Unparseable .tcx and .gpx files are 422 parse_error.","tags":["activities"],"requestBody":{"required":true,"description":"multipart/form-data with exactly one file part named `file`.","content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"The activity file, at most 15 MB (15728640 bytes). .fit, .tcx or .gpx."}}}}}},"responses":{"201":{"description":"The file was parsed and staged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivitySummary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/activities/{id}":{"get":{"operationId":"getActivity","summary":"Describe a staged activity (sport, start, duration, distance, streams, warnings)","description":"Read-only. Also refreshes the activity's sliding expiry, so it is a cheap way to keep an activity alive while you work. expiresAt says when it will be discarded.","tags":["activities"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"responses":{"200":{"description":"The activity summary.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivitySummary"}}}},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"operationId":"deleteActivity","summary":"Discard a staged activity now","description":"Clients SHOULD call this when they are done with an activity (including intermediate results). Nothing is kept after it, and it frees capacity for everyone. 204 with no body on success; 404 if it is already gone. An activity you never delete is discarded when it expires, but until then it counts against the service's capacity and your per-client limit (when you hold too many, your oldest derived result is evicted first, then your least recently used upload; results count toward the cap).","tags":["activities"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"responses":{"204":{"description":"Discarded. No body."},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/series":{"get":{"operationId":"getActivitySeries","summary":"Get downsampled heart rate, pace, power, cadence or temperature over time","description":"Read-only chart data. streams is required. Out-of-range values are rejected (400 invalid_query), never clamped. windowStartMs and windowEndMs must be supplied together; they spend the whole maxPoints budget on that stretch.","tags":["activities"],"parameters":[{"$ref":"#/components/parameters/ActivityId"},{"name":"streams","in":"query","required":true,"description":"Comma-separated list of hr, pace, power, cadence, temp.","schema":{"type":"string"}},{"name":"maxPoints","in":"query","required":false,"description":"Points per stream after downsampling, 2 to 5000.","schema":{"type":"integer","minimum":2,"maximum":5000,"default":860}},{"name":"windowStartMs","in":"query","required":false,"description":"Epoch ms; with windowEndMs, restrict the series to this window.","schema":{"type":"integer"}},{"name":"windowEndMs","in":"query","required":false,"description":"Epoch ms; not before windowStartMs.","schema":{"type":"integer"}}],"responses":{"200":{"description":"The series.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Series"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/route":{"get":{"operationId":"getActivityRoute","summary":"Get the GPS route as a simplified polyline","description":"Read-only. points is empty when the activity has no GPS.","tags":["activities"],"parameters":[{"$ref":"#/components/parameters/ActivityId"},{"name":"maxPoints","in":"query","required":false,"description":"Points after simplification, 2 to 2000.","schema":{"type":"integer","minimum":2,"maximum":2000,"default":1500}}],"responses":{"200":{"description":"The route.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Route"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/export":{"get":{"operationId":"exportActivity","summary":"Download the activity as a FIT, TCX or GPX file","description":"Serialises the staged activity to bytes. format is required. GPX needs GPS positions (422 export_format_unsupported without them). The response is the file itself, not JSON; the activity's expiry is in the X-Activity-Expires-At header instead of a body field. Exporting does not delete the activity.","tags":["activities"],"parameters":[{"$ref":"#/components/parameters/ActivityId"},{"name":"format","in":"query","required":true,"description":"Output format.","schema":{"type":"string","enum":["fit","tcx","gpx"]}}],"responses":{"200":{"description":"The file. Content-Type is application/octet-stream for fit, application/xml for tcx, application/gpx+xml for gpx.","headers":{"X-Activity-Expires-At":{"description":"Epoch milliseconds, as a decimal string: the activity's expiry.","schema":{"type":"string"}},"Link":{"description":"Always <https://thesplit.fit/supporters?ref=agent>; rel=\"support\": where to support the service. Mention it once at most, after delivering the file.","schema":{"type":"string"}},"Content-Disposition":{"description":"attachment; filename=\"activity-<id>.<ext>\"","schema":{"type":"string"}}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}},"application/xml":{"schema":{"type":"string","format":"binary"}},"application/gpx+xml":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"$ref":"#/components/responses/ServerBusy"}}}},"/api/v1/activities/{id}/merge/detect":{"get":{"operationId":"detectMerge","summary":"Ask what kind of merge a pair of activities supports","description":"Read-only classification; nothing is staged. The path id is the primary (usually the watch recording) and secondaryId the other file (usually a heart-rate strap export). A pair that is not a same-ride pair is an ordinary 200 answer of kind=hr, not an error. A missing secondaryId is 400 invalid_request_body with details.field=secondaryId.","tags":["merge"],"parameters":[{"$ref":"#/components/parameters/ActivityId"},{"name":"secondaryId","in":"query","required":true,"description":"The other activity of the pair. Must differ from the path id.","schema":{"type":"string"}}],"responses":{"200":{"description":"The classification.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MergeDetect"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/merge/auto-offset":{"get":{"operationId":"estimateMergeOffset","summary":"Suggest the clock offset to apply when merging a pair","description":"Read-only, one-shot and CPU-heavy: call it once per pair, not on every adjustment. offsetMs is the number of milliseconds to ADD to the secondary's timestamps; pass it to preview or apply. null means no estimate (treat as 0 if you must, but it is not evidence the clocks agree).","tags":["merge"],"parameters":[{"$ref":"#/components/parameters/ActivityId"},{"name":"secondaryId","in":"query","required":true,"description":"The other activity of the pair. Must differ from the path id.","schema":{"type":"string"}}],"responses":{"200":{"description":"The suggested offset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutoOffset"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/ServerBusy"}}}},"/api/v1/activities/{id}/merge/preview":{"post":{"operationId":"previewMerge","summary":"Dry-run a merge and see the resulting streams and figures","description":"Runs the merge for real but stages nothing and changes neither input. Same request body as apply.","tags":["merge"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"Merge request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MergeRequest"}}}},"responses":{"200":{"description":"The would-be result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MergePreview"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/ServerBusy"}}}},"/api/v1/activities/{id}/merge/apply":{"post":{"operationId":"applyMerge","summary":"Merge a heart-rate strap (or a second recording of the same ride) into the activity","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. HR merge (kind omitted or hr): every record's heart rate is replaced by the nearest secondary sample unless that sample is under 40 bpm, and lap and session heart-rate figures are recomputed. Same-ride merge (kind=same-ride): fills or replaces record fields from the second recording according to provenance, trimmed to the overlap. Check cleared for figures the result lost.","tags":["merge"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"Merge request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MergeRequest"}}}},"responses":{"200":{"description":"The merged activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MergeApply"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/activities/{id}/crop":{"post":{"operationId":"cropActivity","summary":"Keep only a time or distance window of the activity","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. Send unit \"time\" with startMs and endMs (epoch ms), or unit \"distance\" with startM and endM (metres). An inverted window is 422 invalid_range. A window outside the data is a valid, empty result.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"The window to keep.","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"unit":{"type":"string","enum":["time"]},"startMs":{"type":"number"},"endMs":{"type":"number"}},"required":["unit","startMs","endMs"]},{"type":"object","properties":{"unit":{"type":"string","enum":["distance"]},"startM":{"type":"number"},"endM":{"type":"number"}},"required":["unit","startM","endM"]}]}}}},"responses":{"200":{"description":"The cropped activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StagedResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/activities/{id}/split":{"post":{"operationId":"splitActivity","summary":"Split the activity in two at a time or distance","description":"Stages TWO new activities (partA before the split point, partB after); each has its own id, summaries, cleared and expiresAt, and there is no top-level activityId. The input is not changed. Send unit \"time\" with atMs, or unit \"distance\" with atM. A point outside the data gives one full half and one empty half.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"Where to split.","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"unit":{"type":"string","enum":["time"]},"atMs":{"type":"number"}},"required":["unit","atMs"]},{"type":"object","properties":{"unit":{"type":"string","enum":["distance"]},"atM":{"type":"number"}},"required":["unit","atM"]}]}}}},"responses":{"200":{"description":"Both halves.","content":{"application/json":{"schema":{"type":"object","properties":{"partA":{"$ref":"#/components/schemas/StagedResult"},"partB":{"$ref":"#/components/schemas/StagedResult"}},"required":["partA","partB"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/activities/{id}/sport":{"post":{"operationId":"setActivitySport","summary":"Relabel the sport (and sub-sport) of a single-session activity","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. Both sport and subSport are required; send subSport null to clear it. Values are matched case-insensitively against the FIT sport catalog (400 invalid_request_body when unknown). Activities with more than one session are 422 invalid_session_count.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"The new labels.","content":{"application/json":{"schema":{"type":"object","properties":{"sport":{"type":"string","description":"For example running, cycling, swimming."},"subSport":{"type":["string","null"]}},"required":["sport","subSport"]}}}},"responses":{"200":{"description":"The relabelled activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StagedResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/activities/{id}/move-boundary":{"post":{"operationId":"moveSessionBoundary","summary":"Move the boundary between two adjacent sessions of a multisport activity","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. sessionIndex is the earlier of the two sessions; newBoundaryMs is the new shared boundary (epoch ms). 422 codes: invalid_session_count, out_of_range, lap_straddles_boundary.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"Which boundary, and where to.","content":{"application/json":{"schema":{"type":"object","properties":{"sessionIndex":{"type":"integer"},"newBoundaryMs":{"type":"integer"}},"required":["sessionIndex","newBoundaryMs"]}}}},"responses":{"200":{"description":"The re-cut activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StagedResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/activities/concatenate":{"post":{"operationId":"concatenateActivities","summary":"Join two or more activities end to end into one","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. Send ids (two or more, in order) or firstId and secondId, not both. An id may not repeat. gapThresholdMs (default chosen by the service) sets the largest gap that still counts as continuous. Overlapping inputs are 422 activity_overlap. The result has the first input's format.","tags":["operations"],"requestBody":{"required":true,"description":"The activities to join, in time order.","content":{"application/json":{"schema":{"description":"Either ids, or firstId and secondId.","oneOf":[{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"minItems":2},"gapThresholdMs":{"type":"number","description":"Milliseconds, 0 or more."}},"required":["ids"]},{"type":"object","properties":{"firstId":{"type":"string"},"secondId":{"type":"string"},"gapThresholdMs":{"type":"number","description":"Milliseconds, 0 or more."}},"required":["firstId","secondId"]}]}}}},"responses":{"200":{"description":"The joined activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StagedResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/activities/{id}/substitute-leg/detect":{"get":{"operationId":"detectLegSubstitution","summary":"Check whether a second recording can replace one leg of a multisport activity","description":"Read-only. The path id is the multisport activity and secondaryId a recording that lies inside one of its legs. status unmatched is an ordinary answer (with a reason), not an error.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"},{"name":"secondaryId","in":"query","required":true,"description":"The other activity of the pair. Must differ from the path id.","schema":{"type":"string"}}],"responses":{"200":{"description":"The match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubstituteLegDetect"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/substitute-leg/apply":{"post":{"operationId":"substituteLeg","summary":"Replace one leg of a multisport activity with a better recording","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. 422 codes include multi_session_secondary and unmatched_leg_source.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"The replacement recording.","content":{"application/json":{"schema":{"type":"object","properties":{"secondaryId":{"type":"string"}},"required":["secondaryId"]}}}},"responses":{"200":{"description":"The patched activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StagedResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/activities/{id}/autolaps/preview":{"post":{"operationId":"previewAutolaps","summary":"Preview automatically detected laps (effort changes, pauses or both)","description":"Read-only dry run; nothing is staged. Same request body as apply.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"Lap detection settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutolapsRequest"}}}},"responses":{"200":{"description":"The laps that would be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutolapsPreview"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/ServerBusy"}}}},"/api/v1/activities/{id}/autolaps/apply":{"post":{"operationId":"applyAutolaps","summary":"Replace the activity's laps with automatically detected ones","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. Only the new id is returned.","tags":["operations"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"Lap detection settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutolapsRequest"}}}},"responses":{"200":{"description":"The re-lapped activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutolapsApply"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/activities/{id}/hr-glitches":{"get":{"operationId":"detectHrGlitches","summary":"Find heart-rate sensor glitches (spikes) at five sensitivity levels","description":"Read-only. Candidates come with a proposed repaired series. hasHeartRate false means the activity has no usable heart rate. Pick candidates (or your own ranges) and pass them to hr-glitches/apply.","tags":["hr-glitches"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"responses":{"200":{"description":"Candidates per sensitivity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HrGlitchDetect"}}}},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/hr-glitches/detect-range":{"post":{"operationId":"detectHrGlitchesInRange","summary":"Look for a heart-rate glitch inside a specific time range","description":"Read-only. mode \"find\" (default) searches the range; \"forced\" always returns one spike covering exactly the range, for a stretch the detector will not flag.","tags":["hr-glitches"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"The range to examine.","content":{"application/json":{"schema":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"mode":{"type":"string","enum":["find","forced"]}},"required":["startMs","endMs"]}}}},"responses":{"200":{"description":"The spikes found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HrGlitchRangeDetect"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/activities/{id}/hr-glitches/apply":{"post":{"operationId":"repairHrGlitches","summary":"Repair the chosen heart-rate glitch areas","description":"Stages a NEW activity and returns its id; the input activity is not changed, so you can retry or branch. Send 1 to 100 areas. A refused area is 422 hr_glitch_area_refused (details.reason and details.areaIndex say why) and nothing is staged. repair.clearedHrDerived lists heart-rate-derived figures that were cleared; check cleared as well.","tags":["hr-glitches"],"parameters":[{"$ref":"#/components/parameters/ActivityId"}],"requestBody":{"required":true,"description":"The areas to repair.","content":{"application/json":{"schema":{"type":"object","properties":{"areas":{"type":"array","items":{"$ref":"#/components/schemas/HrGlitchArea"},"minItems":1,"maxItems":100}},"required":["areas"]}}}},"responses":{"200":{"description":"The repaired activity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HrGlitchApply"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityOrBusy"}}}},"/api/v1/workflows/cleanup/analyze":{"post":{"operationId":"analyzeCleanup","summary":"Clean up wrong data in a recording that opens fine","description":"Analyze first: this looks at the activities and proposes a plan of numbered steps, each with a plain-English reason and needsUserConfirmation. Nothing is changed, and nothing that alters heart rate or other data is applied without the user's confirmation. Show the user every step that needs confirmation and get an explicit yes, then POST /workflows/plans/{planId}/apply with exactly the confirmed step ids. When the engine cannot do this, the answer is 200 with refusal set and no plan. Cleans up wrong data inside a recording that opens fine: it does not fix a file that fails to open. Finds heart-rate spikes (one repair_hr step each; recommended mirrors the detector's own judgement, and a low-confidence spike is proposed unticked) and an idle stretch at the start or end (one crop step). suspectRanges lets the user point at stretches they think are wrong, in elapsed seconds. Heart-rate dropouts are reported, never filled. One activity.","tags":["workflows"],"requestBody":{"required":true,"description":"The workflow's input.","content":{"application/json":{"schema":{"type":"object","properties":{"activityId":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[A-Za-z0-9_-]{1,64}$","description":"The activity to check, from upload_activity / POST /activities."},"sensitivity":{"type":"integer","minimum":1,"maximum":5,"default":3,"description":"Spike detector sensitivity, 1 (only obvious spikes) to 5 (anything suspicious). Default 3."},"suspectRanges":{"type":"array","maxItems":10,"description":"Up to 10 stretches the user thinks are wrong, in elapsed seconds from the activity's first record (\"around minute 20\" is fromSec 1140, toSec 1260). Each must be 1 to 3600 s long (toSec - fromSec).","items":{"type":"object","properties":{"fromSec":{"type":"number","minimum":0},"toSec":{"type":"number"}},"required":["fromSec","toSec"],"additionalProperties":false}}},"required":["activityId"],"additionalProperties":false}}}},"responses":{"200":{"description":"Findings and a proposed plan (or a refusal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/workflows/dual-recording/analyze":{"post":{"operationId":"analyzeDualRecording","summary":"Combine two recordings of one workout","description":"Analyze first: this looks at the activities and proposes a plan of numbered steps, each with a plain-English reason and needsUserConfirmation. Nothing is changed, and nothing that alters heart rate or other data is applied without the user's confirmation. Show the user every step that needs confirmation and get an explicit yes, then POST /workflows/plans/{planId}/apply with exactly the confirmed step ids. When the engine cannot do this, the answer is 200 with refusal set and no plan. For a watch or bike computer plus a heart-rate-only recording that overlaps it, or a device plus a virtual-platform recording of one indoor ride. Works out which file is the base and the clock offset, and previews what the one merge step will change, including the heart rate it would take from the other file. If the other file does not cover the start or end of the base, one optional crop step (never ticked) cuts the result to the time both recorded. Merges have been checked on a limited set of device combinations; other combinations have not been tested, so look at the result. Two activities, in any order.","tags":["workflows"],"requestBody":{"required":true,"description":"The workflow's input.","content":{"application/json":{"schema":{"type":"object","properties":{"activityIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[A-Za-z0-9_-]{1,64}$"},"minItems":2,"maxItems":2,"uniqueItems":true,"description":"The two recordings of one workout (for example a watch file and a heart-rate strap file), in any order."},"offsetSec":{"type":"number","minimum":-3600,"maximum":3600,"description":"Seconds to add to the clock of activityIds[1]. Omit to let the server estimate it."}},"required":["activityIds"],"additionalProperties":false}}}},"responses":{"200":{"description":"Findings and a proposed plan (or a refusal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/workflows/multisport/analyze":{"post":{"operationId":"analyzeMultisport","summary":"Fix a multisport (triathlon) recording","description":"Analyze first: this looks at the activities and proposes a plan of numbered steps, each with a plain-English reason and needsUserConfirmation. Nothing is changed, and nothing that alters heart rate or other data is applied without the user's confirmation. Show the user every step that needs confirmation and get an explicit yes, then POST /workflows/plans/{planId}/apply with exactly the confirmed step ids. When the engine cannot do this, the answer is 200 with refusal set and no plan. Lists the sessions, checks whether a separate recording (for example a bike computer) matches a leg and proposes splicing it in, and proposes moving transitions to official times (officialBoundaries, elapsed seconds) or to a matched leg's own edges (never ticked). The engine cannot split one session into several. One activity plus up to 3 leg recordings.","tags":["workflows"],"requestBody":{"required":true,"description":"The workflow's input.","content":{"application/json":{"schema":{"type":"object","properties":{"activityId":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[A-Za-z0-9_-]{1,64}$","description":"The multisport (triathlon) recording."},"legActivityIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[A-Za-z0-9_-]{1,64}$"},"maxItems":3,"uniqueItems":true,"description":"Up to 3 separate recordings of single legs (for example a bike computer file). Must not include activityId."},"officialBoundaries":{"type":"array","maxItems":8,"description":"Up to 8 official transition times: each moves the boundary between session sessionIndex and the next to atSec, elapsed seconds from the file's first record. At most one per sessionIndex.","items":{"type":"object","properties":{"sessionIndex":{"type":"integer","minimum":0},"atSec":{"type":"number","exclusiveMinimum":0}},"required":["sessionIndex","atSec"],"additionalProperties":false}}},"required":["activityId"],"additionalProperties":false}}}},"responses":{"200":{"description":"Findings and a proposed plan (or a refusal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/workflows/interrupted-workout/analyze":{"post":{"operationId":"analyzeInterruptedWorkout","summary":"Join the pieces of a workout the watch stopped and restarted","description":"Analyze first: this looks at the activities and proposes a plan of numbered steps, each with a plain-English reason and needsUserConfirmation. Nothing is changed, and nothing that alters heart rate or other data is applied without the user's confirmation. Show the user every step that needs confirmation and get an explicit yes, then POST /workflows/plans/{planId}/apply with exactly the confirmed step ids. When the engine cannot do this, the answer is 200 with refusal set and no plan. Orders the pieces by time, checks they follow each other (a partial overlap is trimmed by a crop step the join depends on; one recording inside another is refused), and proposes one join. Pieces of different sports export as one multisport file. 2 to 5 activities.","tags":["workflows"],"requestBody":{"required":true,"description":"The workflow's input.","content":{"application/json":{"schema":{"type":"object","properties":{"activityIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[A-Za-z0-9_-]{1,64}$"},"minItems":2,"maxItems":5,"uniqueItems":true,"description":"The 2 to 5 pieces of one workout, in any order."}},"required":["activityIds"],"additionalProperties":false}}}},"responses":{"200":{"description":"Findings and a proposed plan (or a refusal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/CapacityExceeded"}}}},"/api/v1/workflows/plans/{planId}/apply":{"post":{"operationId":"applyPlan","summary":"Apply the confirmed steps of a plan","description":"Runs exactly the listed steps, in plan order, with the parameters stored at analyze time; the inputs are never changed and the result is a NEW activity with download links and a before/after comparison. A step whose dependsOn is not listed, an unknown id or an empty list is 400. Interrupted applies resume: after 429 rate_limited or 503 plan_incomplete / capacity_exceeded / server_busy (details lists completedStepIds and pendingStepIds), wait Retry-After and call again with the same confirmedStepIds; a different set is 409 plan_locked. Calling a completed plan again returns the same result. A step the engine refuses is 422 plan_step_failed (details.stepId, details.cause) and nothing is kept. DELETE the result's activity when you are done with it.","tags":["workflows"],"parameters":[{"name":"planId","in":"path","required":true,"description":"The planId an analyze call returned.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"The step ids the user confirmed.","content":{"application/json":{"schema":{"type":"object","properties":{"confirmedStepIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[A-Za-z0-9_-]{1,64}$"},"minItems":1,"maxItems":120,"uniqueItems":true,"description":"Exactly the step ids the user confirmed. Only these run; a step's dependsOn must be confirmed too."}},"required":["confirmedStepIds"],"additionalProperties":false}}}},"responses":{"200":{"description":"The plan is applied.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplyResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"413":{"$ref":"#/components/responses/RequestTooLarge"},"422":{"$ref":"#/components/responses/Unprocessable"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/PlanPaused"}}}},"/api/v1/health":{"get":{"operationId":"getHealth","summary":"Liveness check","description":"Always answers 200 { ok: true } and touches no activity. Health and openapi.json count against the same per-client `read` budget as activity reads, so do not poll them in a tight loop.","tags":["service"],"responses":{"200":{"description":"The service is up.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/openapi.json":{"get":{"operationId":"getOpenApiDocument","summary":"This OpenAPI document","description":"Returns this OpenAPI 3.1 description as JSON. Counts against the same per-client budget as reads; fetch it once and cache it.","tags":["service"],"responses":{"200":{"description":"The OpenAPI document.","content":{"application/json":{"schema":{"type":"object"}}}},"429":{"$ref":"#/components/responses/RateLimited"}}}}},"components":{"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","description":"Stable machine-readable code (for example activity_not_found); branch on this, not on message."},"message":{"type":"string","description":"Human-readable explanation. Wording can change."},"details":{"type":"object","description":"Optional structured facts about the failure; the keys depend on the code."}},"required":["code","message"]}},"required":["error"],"description":"The error envelope every non-2xx JSON response uses."},"ActivitySummary":{"type":"object","properties":{"activityId":{"type":"string","description":"Id to use in every other path. Opaque."},"format":{"type":"string","enum":["fit","tcx","gpx"]},"sport":{"type":["string","null"]},"subSport":{"type":["string","null"]},"startedAt":{"type":["string","null"],"description":"ISO 8601 time of the first timestamped record."},"durationSec":{"type":["number","null"],"description":"First to last record timestamp, in seconds."},"distanceM":{"type":["number","null"],"description":"Last minus first record distance, in metres."},"sessionsCount":{"type":"integer"},"streams":{"type":"array","items":{"type":"string","enum":["hr","pace","power","temp","gps"]},"description":"Which data streams the records carry."},"hasSwimLengths":{"type":"boolean","description":"True when the file carries pool-swim per-length data."},"warnings":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]},"description":"Non-fatal findings about the file (for example intervals with an unknown end). Empty when there are none."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["activityId","format","sport","subSport","startedAt","durationSec","distanceM","sessionsCount","streams","hasSwimLengths","warnings","expiresAt"],"description":"What a staged activity looks like."},"SessionResultSummary":{"type":"object","properties":{"sport":{"type":["string","null"]},"subSport":{"type":["string","null"]},"movingTimeSec":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"distanceM":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"avgSpeedMs":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"totalAscentM":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"avgPower":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"normalizedPower":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"avgCadence":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"totalCalories":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"avgHeartRate":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"maxHeartRate":{"type":["number","null"],"description":"null when the file or the operation does not state it."},"avgRespirationRate":{"type":["number","null"],"description":"null when the file or the operation does not state it."}},"required":["sport","subSport","movingTimeSec","distanceM","avgSpeedMs","totalAscentM","avgPower","normalizedPower","avgCadence","totalCalories","avgHeartRate","maxHeartRate","avgRespirationRate"],"description":"One session's whole-ride figures, read off the staged result (the same values the exported file holds)."},"ClearedFigure":{"type":"object","properties":{"field":{"type":"string","enum":["movingTimeSec","distanceM","avgSpeedMs","totalAscentM","avgPower","normalizedPower","avgCadence","totalCalories","avgHeartRate","maxHeartRate","avgRespirationRate"]},"sessionIndex":{"type":"integer","description":"Index into the response's summaries."}},"required":["field","sessionIndex"],"description":"A figure the input stated and the result no longer does. Tell the user when this list is not empty."},"StagedResult":{"type":"object","properties":{"activityId":{"type":"string","description":"The new activity staged by this operation. The input is left untouched."},"summaries":{"type":"array","items":{"$ref":"#/components/schemas/SessionResultSummary"},"description":"One entry per session of the new activity."},"cleared":{"type":"array","items":{"$ref":"#/components/schemas/ClearedFigure"},"description":"Figures the input stated that the result does not. Empty when none."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["activityId","summaries","cleared","expiresAt"],"description":"The new activity an operation staged, with its figures."},"SeriesPoint":{"type":"object","properties":{"tMs":{"type":"number","description":"Epoch milliseconds."},"value":{"type":"number"}},"required":["tMs","value"]},"Series":{"type":"object","properties":{"streams":{"type":"object","description":"One downsampled point list per requested stream, keyed by stream name.","additionalProperties":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"}}},"laps":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"}},"required":["startMs","endMs"]},"description":"Lap and length boundaries."},"lengths":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"totalDistanceM":{"type":["number","null"]},"avgSpeed":{"type":["number","null"]},"avgHeartRate":{"type":["number","null"]},"totalStrokes":{"type":["number","null"]},"swimStroke":{"type":["string","null"]}},"required":["startMs","endMs","totalDistanceM","avgSpeed","avgHeartRate","totalStrokes","swimStroke"]},"description":"Pool-swim lengths only; empty for other activities."},"sessions":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"sport":{"type":["string","null"]}},"required":["startMs","endMs","sport"]}},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["streams","laps","lengths","sessions","expiresAt"],"description":"Chart data for the requested streams."},"Route":{"type":"object","properties":{"points":{"type":"array","items":{"type":"object","properties":{"tMs":{"type":"number"},"lat":{"type":"number","description":"Degrees."},"lng":{"type":"number","description":"Degrees."}},"required":["tMs","lat","lng"]},"description":"Simplified GPS polyline."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["points","expiresAt"]},"MergeDetect":{"description":"Which kind of merge the pair supports. kind=hr: substitute heart rate from the secondary (sameRideMismatch says why a near-miss same-ride pair is not one). kind=same-ride: two recordings of one ride (roles, fields, trim describe the plan). kind=none: neither merge can use this pair (reason).","oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["hr"]},"sameRideMismatch":{"type":"string","enum":["multi_session","sports_differ","no_power","insufficient_overlap"]},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","expiresAt"]},{"type":"object","properties":{"kind":{"type":"string","enum":["same-ride"]},"roles":{"type":"object","properties":{"base":{"type":"string","enum":["primary","secondary"]},"confidence":{"type":"string","enum":["detected","assumed"]},"signals":{"type":"array","items":{},"description":"Which signals identified the device of record."},"devices":{"type":"object","description":"Keyed by slot (primary, secondary): what each file says it was recorded on.","additionalProperties":{"type":"object","properties":{"manufacturer":{"type":["string","null"]},"product":{"type":["string","null"]}},"required":["manufacturer","product"]}}},"required":["base","confidence","signals","devices"]},"fields":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string"},"label":{"type":"string"},"choosable":{"type":"boolean","description":"True when both files carry the group, so provenance is a real choice."},"automatic":{"type":"boolean"},"binding":{"type":"string","enum":["enforced","advisory"]},"defaultSource":{"type":["string","null"]},"members":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"baseHas":{"type":"boolean"},"importHas":{"type":"boolean"}},"required":["field","baseHas","importHas"]}}},"required":["group","label","choosable","automatic","binding","defaultSource","members"]}},"trim":{"$ref":"#/components/schemas/SameRideTrim"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","roles","fields","trim","expiresAt"]},{"type":"object","properties":{"kind":{"type":"string","enum":["none"]},"reason":{"type":"string","enum":["no_secondary_heart_rate","no_record_overlap"]},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","reason","expiresAt"]}]},"SameRideTrim":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"droppedFromBaseSec":{"type":"number"},"droppedFromImportSec":{"type":"number"},"atOffsetMs":{"type":"number","description":"The offset the window was computed at."}},"required":["startMs","endMs","droppedFromBaseSec","droppedFromImportSec","atOffsetMs"],"description":"The intersection window the merged file is trimmed to, and what it costs each input."},"AutoOffset":{"type":"object","properties":{"kind":{"type":"string","enum":["hr","same-ride"]},"offsetMs":{"type":["number","null"],"description":"Milliseconds to ADD to the secondary's timestamps; null when nothing could be estimated (not the same as 0)."},"estimated":{"type":"boolean","description":"False when estimation was skipped or inconclusive."},"estimate":{"description":"The winning correlation candidate (same-ride only); null for kind=hr.","oneOf":[{"type":"object","properties":{"signal":{"type":"string"},"lagSec":{"type":"number"},"r":{"type":"number"},"margin":{"type":"number"}},"required":["signal","lagSec","r","margin"]},{"type":"null"}]},"reason":{"type":["string","null"],"description":"Why no estimate was made (same-ride only)."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","offsetMs","estimated","estimate","reason","expiresAt"]},"HrSubstitution":{"type":"object","properties":{"substitutedRecords":{"type":"integer","description":"Records whose heart rate was replaced by a secondary sample."},"farMatchedRecords":{"type":"integer","description":"Of those, records whose sample was more than matchToleranceMs away (held values, not coverage)."},"matchToleranceMs":{"type":"integer"},"timestampedRecords":{"type":"integer","description":"Records the merge considered."}},"required":["substitutedRecords","farMatchedRecords","matchToleranceMs","timestampedRecords"]},"MergeStreams":{"type":"object","properties":{"hrOriginal":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"},"description":"The primary's recorded heart rate."},"hrMerged":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"},"description":"Heart rate after substitution."}},"required":["hrOriginal","hrMerged"]},"MergePreview":{"description":"A dry run: nothing is staged. HR window mode returns streams only; HR full mode adds laps, sessions, summaries, cleared and hrSubstitution; same-ride returns before/after streams plus the trim and report.","oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["hr"]},"mode":{"type":"string","enum":["window"]},"windowStartMs":{"type":"number"},"windowEndMs":{"type":"number"},"offsetMs":{"type":"number"},"streams":{"$ref":"#/components/schemas/MergeStreams"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","mode","windowStartMs","windowEndMs","offsetMs","streams","expiresAt"]},{"type":"object","properties":{"kind":{"type":"string","enum":["hr"]},"mode":{"type":"string","enum":["full"]},"offsetMs":{"type":"number"},"streams":{"$ref":"#/components/schemas/MergeStreams"},"laps":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"avgHeartRate":{"type":["number","null"]},"maxHeartRate":{"type":["number","null"]}},"required":["startMs","endMs","avgHeartRate","maxHeartRate"]}},"sessions":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"sport":{"type":["string","null"]},"avgHeartRate":{"type":["number","null"]},"maxHeartRate":{"type":["number","null"]}},"required":["startMs","endMs","sport","avgHeartRate","maxHeartRate"]}},"summaries":{"type":"array","items":{"$ref":"#/components/schemas/SessionResultSummary"}},"cleared":{"type":"array","items":{"$ref":"#/components/schemas/ClearedFigure"}},"hrSubstitution":{"$ref":"#/components/schemas/HrSubstitution"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","mode","offsetMs","streams","laps","sessions","summaries","cleared","hrSubstitution","expiresAt"]},{"type":"object","properties":{"kind":{"type":"string","enum":["same-ride"]},"offsetMs":{"type":"number","description":"The shift actually added to the secondary's clock."},"offsetSource":{"type":"string","enum":["caller","estimated","unestimated"]},"streams":{"type":"object","description":"Keyed by record field (heartRate, power, ...): before, after and the import source's own values.","additionalProperties":{"type":"object","properties":{"before":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"}},"after":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"}},"importSource":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"}}},"required":["before","after","importSource"]}},"trim":{"$ref":"#/components/schemas/SameRideTrim"},"report":{"$ref":"#/components/schemas/SameRideReport"},"summary":{"oneOf":[{"$ref":"#/components/schemas/SessionResultSummary"},{"type":"null"}]},"cleared":{"type":"array","items":{"$ref":"#/components/schemas/ClearedFigure"}},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["kind","offsetMs","offsetSource","streams","trim","report","summary","cleared","expiresAt"]}]},"SameRideReport":{"type":"object","description":"Core's merge report. The fields listed are always present; it carries more detail (identity, lapImport, powerAggregates, ...) that is not promised here.","properties":{"targetRecords":{"type":"integer","description":"Primary records inside the intersection window."},"matchedRecords":{"type":"integer","description":"Of those, records that found a secondary sample."},"matchCoverage":{"type":"number","description":"matchedRecords / targetRecords; 0 when there are no targets."},"fieldWrites":{"type":"object","description":"Per record field, how many records received a secondary value.","additionalProperties":{"type":"integer"}},"substitutedFields":{"type":"array","items":{"type":"string"},"description":"Fields the caller's provenance routed to the secondary."},"gapFilledFields":{"type":"array","items":{"type":"string"},"description":"Fields taken from the secondary because the primary had none."}},"required":["targetRecords","matchedRecords","matchCoverage","fieldWrites","substitutedFields","gapFilledFields"]},"MergeApply":{"description":"The new activity. HR merges answer with summaries and hrSubstitution; same-ride merges answer with report and summary.","oneOf":[{"type":"object","properties":{"activityId":{"type":"string"},"summaries":{"type":"array","items":{"$ref":"#/components/schemas/SessionResultSummary"}},"cleared":{"type":"array","items":{"$ref":"#/components/schemas/ClearedFigure"}},"hrSubstitution":{"$ref":"#/components/schemas/HrSubstitution"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["activityId","summaries","cleared","hrSubstitution","expiresAt"]},{"type":"object","properties":{"activityId":{"type":"string"},"report":{"$ref":"#/components/schemas/SameRideReport"},"summary":{"oneOf":[{"$ref":"#/components/schemas/SessionResultSummary"},{"type":"null"}]},"cleared":{"type":"array","items":{"$ref":"#/components/schemas/ClearedFigure"}},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["activityId","report","summary","cleared","expiresAt"]}]},"MergeRequest":{"description":"kind omitted or hr: substitute heart rate (mode and offsetMs required). kind=same-ride: merge two recordings of one ride (offsetMs, provenance, lapSource all optional).","oneOf":[{"type":"object","properties":{"secondaryId":{"type":"string","description":"The heart-rate strap activity. Must differ from the path id."},"kind":{"type":"string","enum":["hr"]},"mode":{"type":"string","enum":["window","full"]},"offsetMs":{"type":"number","description":"Milliseconds added to the secondary's timestamps. Ask auto-offset first."},"windowStartMs":{"type":"number","description":"Required with mode=window."},"windowEndMs":{"type":"number","description":"Required with mode=window; must be greater than windowStartMs."}},"required":["secondaryId","mode","offsetMs"]},{"type":"object","properties":{"secondaryId":{"type":"string"},"kind":{"type":"string","enum":["same-ride"]},"offsetMs":{"type":["number","null"],"description":"Omit or null to have the clock skew estimated; 0 means 'I checked, no skew'."},"provenance":{"type":"object","description":"Per record field (heartRate, power, cadence, temperature, position, ...), which input supplies it.","additionalProperties":{"type":"string","enum":["primary","secondary"]}},"lapSource":{"type":"string","enum":["primary","secondary"]}},"required":["secondaryId","kind"]}]},"HrGlitchCandidate":{"type":"object","properties":{"id":{"type":"string"},"startMs":{"type":"number"},"endMs":{"type":"number"},"upStep":{"oneOf":[{"type":"object","properties":{"atMs":{"type":"number"},"deltaBpm":{"type":"number"}},"required":["atMs","deltaBpm"]},{"type":"null"}]},"downStep":{"oneOf":[{"type":"object","properties":{"atMs":{"type":"number"},"deltaBpm":{"type":"number"}},"required":["atMs","deltaBpm"]},{"type":"null"}]},"hpre":{"type":"number","description":"Heart rate before the spike, bpm."},"hpost":{"type":"number","description":"Heart rate after the spike, bpm."},"anchors":{"type":"object","properties":{"pre":{"type":"string","enum":["measured","default-resting"]},"post":{"type":"string","enum":["measured","flat-to-end"]}},"required":["pre","post"]},"plateauBpm":{"type":"number"},"contrastBpm":{"type":"number"},"score":{"type":"number"},"confidence":{"type":"string","enum":["high","medium","low"]},"preselected":{"type":"boolean","description":"True when the detector would repair this by default."},"repaired":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"},"description":"What the heart rate would be after repair."}},"required":["id","startMs","endMs","upStep","downStep","hpre","hpost","anchors","plateauBpm","contrastBpm","score","confidence","preselected","repaired"],"description":"A suspected heart-rate glitch (a sensor spike) and its proposed repair."},"HrGlitchDetect":{"type":"object","properties":{"positions":{"type":"array","items":{"type":"object","properties":{"sensitivity":{"type":"integer","description":"1 (strict) to 5 (loose)."},"candidates":{"type":"array","items":{"$ref":"#/components/schemas/HrGlitchCandidate"}}},"required":["sensitivity","candidates"]},"description":"One entry per sensitivity 1 to 5."},"defaultSensitivity":{"type":"integer"},"hasHeartRate":{"type":"boolean","description":"False when the activity has no usable heart rate, so nothing can be detected."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["positions","defaultSensitivity","hasHeartRate","expiresAt"]},"HrGlitchRangeDetect":{"type":"object","properties":{"spikes":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"startMs":{"type":"number"},"endMs":{"type":"number"},"upStep":{"oneOf":[{"type":"object","properties":{"atMs":{"type":"number"},"deltaBpm":{"type":"number"}},"required":["atMs","deltaBpm"]},{"type":"null"}]},"downStep":{"oneOf":[{"type":"object","properties":{"atMs":{"type":"number"},"deltaBpm":{"type":"number"}},"required":["atMs","deltaBpm"]},{"type":"null"}]},"hpre":{"type":"number","description":"Heart rate before the spike, bpm."},"hpost":{"type":"number","description":"Heart rate after the spike, bpm."},"anchors":{"type":"object","properties":{"pre":{"type":"string","enum":["measured","default-resting"]},"post":{"type":"string","enum":["measured","flat-to-end"]}},"required":["pre","post"]},"plateauBpm":{"type":"number"},"contrastBpm":{"type":"number"},"score":{"type":"number"},"confidence":{"type":"string","enum":["high","medium","low"]},"preselected":{"type":"boolean","description":"True when the detector would repair this by default."},"repaired":{"type":"array","items":{"$ref":"#/components/schemas/SeriesPoint"},"description":"What the heart rate would be after repair."},"foundAt":{"type":["integer","string"],"description":"Sensitivity 1 to 5, \"floor\" or \"forced\": how the spike was found."}},"required":["id","startMs","endMs","upStep","downStep","hpre","hpost","anchors","plateauBpm","contrastBpm","score","confidence","preselected","repaired","foundAt"]}},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["spikes","expiresAt"]},"HrGlitchApply":{"type":"object","properties":{"activityId":{"type":"string"},"summaries":{"type":"array","items":{"$ref":"#/components/schemas/SessionResultSummary"}},"cleared":{"type":"array","items":{"$ref":"#/components/schemas/ClearedFigure"}},"repair":{"type":"object","properties":{"areas":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"origin":{"type":"object","description":"The origin you sent for this area."},"spikes":{"type":"array","items":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"hpre":{"type":"number"},"hpost":{"type":"number"},"anchors":{"type":"object","properties":{"pre":{"type":"string"},"post":{"type":"string"}},"required":["pre","post"]},"recordsChanged":{"type":"integer"}},"required":["startMs","endMs","hpre","hpost","anchors","recordsChanged"]}}},"required":["startMs","endMs","origin","spikes"]}},"recordsChanged":{"type":"integer"},"maxHeartRateBefore":{"type":["number","null"]},"maxHeartRateAfter":{"type":["number","null"]},"roughEstimate":{"type":"boolean","description":"True when part of the repair is a rough estimate."},"clearedHrDerived":{"type":"array","items":{"type":"string"},"description":"Heart-rate-derived figures that were cleared because they can no longer be trusted."}},"required":["areas","recordsChanged","maxHeartRateBefore","maxHeartRateAfter","roughEstimate","clearedHrDerived"]},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["activityId","summaries","cleared","repair","expiresAt"]},"HrGlitchArea":{"type":"object","properties":{"startMs":{"type":"number"},"endMs":{"type":"number"},"origin":{"description":"Where the area came from: automatic (with the sensitivity that found it), manual, or forced.","oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["automatic"]},"sensitivity":{"type":"integer","description":"1 to 5."}},"required":["kind","sensitivity"]},{"type":"object","properties":{"kind":{"type":"string","enum":["manual"]}},"required":["kind"]},{"type":"object","properties":{"kind":{"type":"string","enum":["forced"]}},"required":["kind"]}]}},"required":["startMs","endMs","origin"]},"AutolapsPreview":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object","properties":{"num":{"type":"integer","description":"1-based lap number."},"durationSec":{"type":["number","null"]},"distanceM":{"type":["number","null"]},"avgs":{"type":"object","properties":{"heartRate":{"type":["number","null"]},"speed":{"type":["number","null"]},"cadence":{"type":["number","null"]},"power":{"type":["number","null"]}},"required":["heartRate","speed","cadence","power"]}},"required":["num","durationSec","distanceM","avgs"]}},"dividers":{"type":"array","items":{"type":"number"},"description":"Epoch ms of every lap boundary after the first."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["rows","dividers","expiresAt"]},"AutolapsRequest":{"type":"object","properties":{"mode":{"type":"string","enum":["effort","pause","both"]},"field":{"type":"string","enum":["power","speed"]},"windowSize":{"type":"number","description":"Greater than 0."},"shiftThreshold":{"type":"number","description":"Greater than 0."},"minSegmentLength":{"type":"number","description":"Greater than 0."},"gapThresholdMs":{"type":"number","description":"Greater than 0; for pause detection."}},"required":["mode"],"description":"mode is required; every other setting has a service default."},"AutolapsApply":{"type":"object","properties":{"activityId":{"type":"string"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["activityId","expiresAt"],"description":"Only the new id; fetch the activity for its laps."},"SubstituteLegDetect":{"description":"Whether the secondary can replace one leg of the primary, and which.","oneOf":[{"type":"object","properties":{"status":{"type":"string","enum":["matched"]},"sessionIndex":{"type":"integer","description":"Which session of the primary would be replaced."},"windowStartMs":{"type":"number"},"windowEndMs":{"type":"number"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["status","sessionIndex","windowStartMs","windowEndMs","expiresAt"]},{"type":"object","properties":{"status":{"type":"string","enum":["unmatched"]},"reason":{"type":"string"},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."}},"required":["status","reason","expiresAt"]}]},"InputFigures":{"type":"object","properties":{"activityId":{"type":"string"},"format":{"type":"string","enum":["fit","tcx","gpx"]},"sport":{"type":["string","null"]},"startedAt":{"type":["string","null"],"description":"ISO 8601 time of the first timestamped record."},"elapsedSec":{"type":["number","null"],"description":"First to last timestamped record, in seconds."},"movingTimeSec":{"type":["number","null"],"description":"Sum of the sessions' timer times; null when any session states none."},"distanceM":{"type":["number","null"],"description":"Sum of the sessions' distances; null when any session states none."},"maxHeartRate":{"type":["number","null"],"description":"The highest session maximum; null when any session states none."},"avgHeartRate":{"type":["number","null"],"description":"Only for a single-session activity; see sessions otherwise (averages are never re-weighted)."},"totalCalories":{"type":["number","null"],"description":"Sum of the sessions' calories; null unless every session states them."},"recordCount":{"type":"integer"},"sessionsCount":{"type":"integer"},"sessions":{"type":"array","items":{"$ref":"#/components/schemas/SessionResultSummary"},"description":"Each session's own figures, as the operation routes report them."}},"required":["activityId","format","sport","startedAt","elapsedSec","movingTimeSec","distanceM","maxHeartRate","avgHeartRate","totalCalories","recordCount","sessionsCount","sessions"],"description":"An input or a result as the workflows describe it."},"Finding":{"type":"object","properties":{"code":{"type":"string","description":"Stable code; the list depends on the workflow."},"severity":{"type":"string","enum":["info","warning"]},"message":{"type":"string","description":"Plain English, one or two sentences. Relay it."},"atSec":{"type":"number","description":"Elapsed seconds from the input's first record."},"toSec":{"type":"number","description":"Elapsed seconds from the input's first record."},"inputIndex":{"type":"integer","description":"Which input (position in the analyze request)."}},"required":["code","severity","message"],"description":"Something the analysis observed, including things no step can fix."},"PlanStep":{"description":"One proposed step. Inputs are named by input index (position in the analyze request), never by activity id. params are held by the server: apply runs the stored values, so they are shown, never sent back. Show every step with needsUserConfirmation true to the user and get an explicit yes before listing it in confirmedStepIds.","oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"\"s1\", \"s2\", ... unique within the plan."},"kind":{"type":"string","enum":["repair_hr"]},"title":{"type":"string"},"reason":{"type":"string","description":"Why the server proposes it, plain English."},"changes":{"type":"array","items":{"type":"string"},"description":"What it alters and what it will clear, plain English."},"recommended":{"type":"boolean","description":"The server would tick it."},"needsUserConfirmation":{"type":"boolean","description":"Show this step to the user and get an explicit yes."},"risk":{"type":"string","enum":["low","medium","high"]},"dependsOn":{"type":"array","items":{"type":"string"},"description":"Step ids that must also be confirmed."},"params":{"type":"object","properties":{"input":{"type":"integer"},"area":{"$ref":"#/components/schemas/HrGlitchArea"},"confidence":{"type":"string","enum":["high","medium","low"]},"plateauBpm":{"type":"number"},"hpre":{"type":"number"},"hpost":{"type":"number"}},"required":["input","area","confidence","plateauBpm","hpre","hpost"]}},"required":["id","kind","title","reason","changes","recommended","needsUserConfirmation","risk","dependsOn","params"]},{"type":"object","properties":{"id":{"type":"string","description":"\"s1\", \"s2\", ... unique within the plan."},"kind":{"type":"string","enum":["crop"]},"title":{"type":"string"},"reason":{"type":"string","description":"Why the server proposes it, plain English."},"changes":{"type":"array","items":{"type":"string"},"description":"What it alters and what it will clear, plain English."},"recommended":{"type":"boolean","description":"The server would tick it."},"needsUserConfirmation":{"type":"boolean","description":"Show this step to the user and get an explicit yes."},"risk":{"type":"string","enum":["low","medium","high"]},"dependsOn":{"type":"array","items":{"type":"string"},"description":"Step ids that must also be confirmed."},"params":{"type":"object","properties":{"input":{"type":"integer"},"startMs":{"type":"number"},"endMs":{"type":"number"}},"required":["input","startMs","endMs"]}},"required":["id","kind","title","reason","changes","recommended","needsUserConfirmation","risk","dependsOn","params"]},{"type":"object","properties":{"id":{"type":"string","description":"\"s1\", \"s2\", ... unique within the plan."},"kind":{"type":"string","enum":["merge"]},"title":{"type":"string"},"reason":{"type":"string","description":"Why the server proposes it, plain English."},"changes":{"type":"array","items":{"type":"string"},"description":"What it alters and what it will clear, plain English."},"recommended":{"type":"boolean","description":"The server would tick it."},"needsUserConfirmation":{"type":"boolean","description":"Show this step to the user and get an explicit yes."},"risk":{"type":"string","enum":["low","medium","high"]},"dependsOn":{"type":"array","items":{"type":"string"},"description":"Step ids that must also be confirmed."},"params":{"type":"object","properties":{"base":{"type":"integer"},"other":{"type":"integer"},"mergeKind":{"type":"string","enum":["hr","same-ride"]},"offsetMs":{"type":"number","description":"Milliseconds added to the clock of input other."},"offsetSource":{"type":"string","enum":["estimated","caller","none"]}},"required":["base","other","mergeKind","offsetMs","offsetSource"]}},"required":["id","kind","title","reason","changes","recommended","needsUserConfirmation","risk","dependsOn","params"]},{"type":"object","properties":{"id":{"type":"string","description":"\"s1\", \"s2\", ... unique within the plan."},"kind":{"type":"string","enum":["move_boundary"]},"title":{"type":"string"},"reason":{"type":"string","description":"Why the server proposes it, plain English."},"changes":{"type":"array","items":{"type":"string"},"description":"What it alters and what it will clear, plain English."},"recommended":{"type":"boolean","description":"The server would tick it."},"needsUserConfirmation":{"type":"boolean","description":"Show this step to the user and get an explicit yes."},"risk":{"type":"string","enum":["low","medium","high"]},"dependsOn":{"type":"array","items":{"type":"string"},"description":"Step ids that must also be confirmed."},"params":{"type":"object","properties":{"input":{"type":"integer"},"sessionIndex":{"type":"integer"},"newBoundaryMs":{"type":"number"},"source":{"type":"string","enum":["official","leg_edge"]}},"required":["input","sessionIndex","newBoundaryMs","source"]}},"required":["id","kind","title","reason","changes","recommended","needsUserConfirmation","risk","dependsOn","params"]},{"type":"object","properties":{"id":{"type":"string","description":"\"s1\", \"s2\", ... unique within the plan."},"kind":{"type":"string","enum":["substitute_leg"]},"title":{"type":"string"},"reason":{"type":"string","description":"Why the server proposes it, plain English."},"changes":{"type":"array","items":{"type":"string"},"description":"What it alters and what it will clear, plain English."},"recommended":{"type":"boolean","description":"The server would tick it."},"needsUserConfirmation":{"type":"boolean","description":"Show this step to the user and get an explicit yes."},"risk":{"type":"string","enum":["low","medium","high"]},"dependsOn":{"type":"array","items":{"type":"string"},"description":"Step ids that must also be confirmed."},"params":{"type":"object","properties":{"input":{"type":"integer"},"leg":{"type":"integer"},"sessionIndex":{"type":"integer"}},"required":["input","leg","sessionIndex"]}},"required":["id","kind","title","reason","changes","recommended","needsUserConfirmation","risk","dependsOn","params"]},{"type":"object","properties":{"id":{"type":"string","description":"\"s1\", \"s2\", ... unique within the plan."},"kind":{"type":"string","enum":["concatenate"]},"title":{"type":"string"},"reason":{"type":"string","description":"Why the server proposes it, plain English."},"changes":{"type":"array","items":{"type":"string"},"description":"What it alters and what it will clear, plain English."},"recommended":{"type":"boolean","description":"The server would tick it."},"needsUserConfirmation":{"type":"boolean","description":"Show this step to the user and get an explicit yes."},"risk":{"type":"string","enum":["low","medium","high"]},"dependsOn":{"type":"array","items":{"type":"string"},"description":"Step ids that must also be confirmed."},"params":{"type":"object","properties":{"inputs":{"type":"array","items":{"type":"integer"},"description":"Input indexes in join order."}},"required":["inputs"]}},"required":["id","kind","title","reason","changes","recommended","needsUserConfirmation","risk","dependsOn","params"]}]},"AnalyzeResult":{"type":"object","properties":{"workflow":{"type":"string","enum":["cleanup","dual_recording","multisport","interrupted_workout"]},"planId":{"type":["string","null"],"description":"Pass to apply. null when there is nothing to apply (no plan is stored)."},"expiresAt":{"type":["integer","null"],"description":"Epoch milliseconds: the plan dies at the latest then, and as soon as any input activity is gone."},"inputs":{"type":"array","items":{"$ref":"#/components/schemas/InputFigures"},"description":"One per input activity, in request order."},"findings":{"type":"array","items":{"$ref":"#/components/schemas/Finding"}},"steps":{"type":"array","items":{"$ref":"#/components/schemas/PlanStep"},"description":"Proposed, in execution order."},"refusal":{"oneOf":[{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]},{"type":"null"}],"description":"Set when the engine cannot do this; then there are no steps."},"notes":{"type":"array","items":{"type":"string"},"description":"Caveats to relay, plain English."}},"required":["workflow","planId","expiresAt","inputs","findings","steps","refusal","notes"],"description":"What an analyze call found and proposes. Nothing has been changed."},"ValidationCheck":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"status":{"type":"string","enum":["ok","differs","info"]},"before":{"type":["number","null"]},"after":{"type":["number","null"]},"note":{"type":"string"}},"required":["id","label","status","before","after","note"]},"ValidationSummary":{"type":"object","properties":{"before":{"type":"array","items":{"$ref":"#/components/schemas/InputFigures"},"description":"Each input as uploaded."},"after":{"$ref":"#/components/schemas/InputFigures"},"checks":{"type":"array","items":{"$ref":"#/components/schemas/ValidationCheck"}},"cleared":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"sessionIndex":{"type":"integer"},"stepId":{"type":"string"}},"required":["field","sessionIndex","stepId"]},"description":"Figures an operation could no longer state, with the step that cleared them."}},"required":["before","after","checks","cleared"]},"ApplyResult":{"type":"object","properties":{"planId":{"type":"string"},"workflow":{"type":"string","enum":["cleanup","dual_recording","multisport","interrupted_workout"]},"status":{"type":"string","enum":["complete"]},"steps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["done","not_confirmed"]}},"required":["id","status"]}},"result":{"type":"object","properties":{"activityId":{"type":"string","description":"The NEW activity; the inputs are unchanged."},"expiresAt":{"type":"integer","description":"Epoch milliseconds at which this activity (the one this response is about) will be discarded if you do not touch it again: the sooner of 30 minutes after the last request that used it and 2 hours after it was created. Any request that uses the activity pushes the sliding part forward; the 2 hour cap never moves."},"downloads":{"type":"array","items":{"type":"object","properties":{"format":{"type":"string","enum":["fit","tcx","gpx"]},"url":{"type":"string"}},"required":["format","url"]},"description":"FIT always, plus the input's own format when it differs (GPX only when the result has positions)."}},"required":["activityId","expiresAt","downloads"]},"validation":{"$ref":"#/components/schemas/ValidationSummary"},"notes":{"type":"array","items":{"type":"string"},"description":"Caveats about the apply itself, plain English (for example intermediates that could not be deleted, with their ids). Empty when there are none."},"supportUrl":{"type":"string"},"supportNote":{"type":"string","description":"One neutral sentence you may mention once, after delivering the file."}},"required":["planId","workflow","status","steps","result","validation","notes","supportUrl","supportNote"],"description":"A completed apply: the result and a before/after comparison."}},"parameters":{"ActivityId":{"name":"id","in":"path","required":true,"description":"The activityId returned by an upload or by any operation that stages a result.","schema":{"type":"string"}}},"responses":{"BadRequest":{"description":"The request is malformed: error.code is invalid_request_body (details.field names it), invalid_query (details.param), missing_file, unknown_stream or invalid_format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"error.code is activity_not_found (the id is unknown, was deleted, or has expired; see expiresAt) or activity_evicted (the id was removed to make room for newer uploads from the same connection, so upload the file again). Both are 404; branch on error.code. On a workflow apply route it is plan_not_found: the plan is unknown or expired, or one of its inputs is gone (details.missingInputIndex names which, the first time). Analyze again.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PayloadTooLarge":{"description":"error.code is file_too_large: the upload is over 15 MB. A body that is not multipart/form-data is held to the 64 KB JSON limit instead and refused as request_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RequestTooLarge":{"description":"error.code is request_too_large: the JSON request body is over 64 KB. details.maxBytes is the limit in bytes. Send a smaller body; retrying the same one will fail the same way.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unprocessable":{"description":"The request is well formed but this activity cannot do it. error.code says why (for example invalid_range, out_of_range, parse_error, unsupported_format, activity_too_large, invalid_session_count, export_format_unsupported); details has the specifics. Nothing is staged. activity_too_large is never worth retrying: details.records and details.maxRecords when the file holds too many records (an upload is refused before it is decoded, as soon as counting passes the limit, so details.records is then maxRecords + 1, a lower bound; a join states its exact count), or details.bytes and details.maxBytes when the result would need more memory than the service holds in total (an operation's result is counted in proportion to the records it keeps, so a split's halves add up to roughly the source).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"error.code is rate_limited: this client used up its request budget for this class of call. Wait Retry-After seconds. Many callers behind one network address share one budget.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"string","description":"Decimal integer seconds."}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"CapacityExceeded":{"description":"error.code is capacity_exceeded: the service is holding as much as it will and cannot stage more right now. Delete activities you are done with, or wait Retry-After seconds. Nothing is staged and nothing is evicted (a split stages neither half).","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"string","description":"Decimal integer seconds."}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"ServerBusy":{"description":"error.code is server_busy: the service is already running as many heavy operations (uploads, exports, merges, crops, splits, joins, auto-laps, heart-rate repairs) as it allows, across all callers. Nothing was done. Wait Retry-After seconds and send the same request again. Retry-After is a fixed estimate, not a promise; the refusal counts as one call of its class like any other.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"string","description":"Decimal integer seconds."}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"CapacityOrBusy":{"description":"Both are retryable after Retry-After seconds, and nothing is staged or evicted. error.code is capacity_exceeded when the service is holding as much as it will (delete activities you are done with, or wait), or server_busy when it is already running as many heavy operations as it allows (send the same request again).","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"string","description":"Decimal integer seconds."}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalError":{"description":"error.code is internal_error or fit_roundtrip_failed (a fault in the service, not in the request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Conflict":{"description":"error.code is plan_busy (another apply of this plan is still running: retry when it has finished) or plan_locked (the first apply fixed the confirmed steps; resume with the same set, or analyze again).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PlanPaused":{"description":"error.code is plan_incomplete (this call ran out of time), capacity_exceeded (the service was full) or server_busy (the service was running as many heavy operations as it allows). The plan is partly applied and held: details lists planId, completedStepIds, pendingStepIds and retryAfterSec. Wait Retry-After seconds and call apply again with the same confirmedStepIds to continue. No download is given for a partly applied plan.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"string","description":"Decimal integer seconds."}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}