---
title: "Save a workout recorded by the app's live workout screen"
method: POST
path: "/api/health/workouts"
tags: ["Health"]
---

# Save a workout recorded by the app's live workout screen

`POST /api/health/workouts`

## Request

- Base URL: `https://api.hiyd.ai`
- URL: `https://api.hiyd.ai/api/health/workouts`
- Auth: HTTP bearer

Idempotent by the client-generated `id`: the app keeps an ended
workout on the phone and retries until this accepts it, so a replay
of a save that already landed answers 200 with `created: false`.
Heart-rate samples are stored with the row and drive the workout's
detail chart; avg and max heart rate are computed from them here.

## Request body

- object
  - `id` string, uuid, required
  - `workout_type` 'running' | 'walking' | 'cycling' | 'swimming' | 'strength' | 'yoga' | 'hiit' | 'other', required
  - `sport` string: Name shown in the app, e.g. Tennis
  - `start_time` string, date-time, required
  - `end_time` string, date-time, required
  - `active_seconds` integer: Elapsed time excluding pauses
  - `heart_rate_samples` object[]
    - `t` string, date-time
    - `bpm` integer
  - `pauses` object[]: When the workout was paused; the detail leaves the band's readings from these out
    - `start` string, date-time, required
    - `end` string, date-time, required

## Response `200`

Already saved under this id or for this session

## Other responses

- `201`: Saved
- `400`: The body failed validation
- `409`: The id belongs to another user's workout

---

[API](https://skmtc.dev/hiyd/apis/hiyd-backend-api.md) - [All operations](https://skmtc.dev/hiyd/apis/hiyd-backend-api/llms.txt) - [OpenAPI document](https://skmtc.dev/hiyd/apis/hiyd-backend-api/revisions/23598d347e1b?raw)
