Apple Health setup

Post workouts from Apple Watch to Second Line via an iOS Shortcut. Not Strava — direct HealthKit → your server.

Endpoint: https://coach.wagner.band/api/health/workout

Method: POST · JSON body · Authorization: Bearer <Google ID token>

  1. Open Shortcuts on iPhone

    Install the Shortcuts app if needed. You will run this after each workout (or automate it).

  2. Create shortcut: “Second Line Workout”

    Add actions in order:

    • Find Workouts — filter: most recent, workout type Run (or All)
    • Get Details of Workout — start date, duration, distance, heart rate (optional)
    • Get Contents of URL — POST to endpoint above
  3. Build JSON body

    Use Text action with placeholders, then pass to URL action as Request Body (JSON).

  4. Set headers

    • Content-Type: application/json
    • Authorization: Bearer YOUR_ID_TOKEN

    Copy your token from this app after Google Sign-In (index page), or use a stored Shortcut variable.

  5. Automation (optional)

    Shortcuts → Automation → Workout → When workout ends → Run “Second Line Workout”.

  6. Verify

    Finish a short walk/run on Watch. Check Today page — RUN status should update when the API ingests the workout.

Sample JSON payload

{
  "workout_type": "Running",
  "start_time": "2026-10-20T07:00:00Z",
  "duration_seconds": 1500,
  "distance_meters": 3218.0,
  "avg_heart_rate": 142,
  "source": "apple_health"
}

Field reference

workout_type
Run, Walk, etc. (from Health)
start_time
ISO 8601 UTC, e.g. 2025-06-23T06:15:00Z
duration_sec
Moving time in seconds
distance_m
Distance in meters (optional for off days)
source
apple_health_shortcut
heart_rate_avg
Optional average BPM