> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/planned-workouts-api/overview.md).

# Overview

> ⚠️ **Pre-Release / Under Construction**
>
> This page is currently **under active development** and is provided in a **pre-release state**.
>
> Content may be **incomplete, outdated, or inaccurate**, and details may changewithout notice as the implementation evolves.
>
> Please use this documentation for **early reference only**, and avoid relying on it for production-critical decisions until the page is marked as stable.

## Terra Planned Workouts API

Push structured workouts directly to your users' fitness devices.

### Documentation

1. Introduction & Quick Start - Get started in 5 minutes
2. Core Concepts - Workout structure, blocks, steps, targets
3. Athlete Parameters - Personalizing workouts per user
4. Sport-Specific Examples - Running, cycling, swimming, strength
5. Provider Compatibility - What works where
6. Coercion Warnings - Handling feature limitations
7. Exercise Reference - Garmin exercise names

### Quick Links

* OpenAPI Specification (to be added soon)
* Garmin Exercise Names reference

### API Endpoints

| Method | Endpoint                          | Description                                                         |
| ------ | --------------------------------- | ------------------------------------------------------------------- |
| POST   | `/workouts`                       | Create workout template                                             |
| GET    | `/workouts`                       | List all templates                                                  |
| GET    | `/workouts/{id}`                  | Get template details                                                |
| DELETE | `/workouts/{id}`                  | Delete template                                                     |
| POST   | `/workouts/{id}/plan?user_id=X`   | Schedule workout to user                                            |
| GET    | `/plannedWorkouts/{id}`           | Get a planned workout created through Terra                         |
| GET    | `/plannedWorkouts?user_id=X`      | List user's scheduled workouts (optional: `start_date`, `end_date`) |
| PATCH  | `/plannedWorkouts/{id}?user_id=X` | Update scheduled date (only `planned_date`, not athlete params)     |
| DELETE | `/plannedWorkouts/{id}?user_id=X` | Remove scheduled workout                                            |

{% hint style="warning" %}

#### Deleting a workout template cascades to all scheduled workouts

When you call `DELETE /workouts/{id}`, Terra automatically removes all planned workouts linked to that template from every connected provider (e.g. Garmin, Suunto, Wahoo) before deleting the template itself. This cannot be undone. If you only want to unschedule a workout for a specific user, use `DELETE /plannedWorkouts/{id}` instead.
{% endhint %}

### Reading scheduled workouts

`GET /plannedWorkouts?user_id=X` returns everything on the user's calendar, from both origins:

* **Workouts you scheduled through Terra** — identified by a `planned_workout_id`. Use it with the `GET`/`PATCH`/`DELETE /plannedWorkouts/{id}` endpoints; the full workout definition lives on the template (`GET /workouts/{workout_id}`).
* **Workouts created on the provider's side** (e.g. by a coach on TrainingPeaks) — marked `is_external: true`. These are fetched live from the provider and are read-only: they have no `planned_workout_id` and cannot be addressed by id. Instead, each one carries its full body inline under `details` — title, description, planned TSS and Intensity Factor, planned duration/distance, and the structured steps with targets. Use `provider_workout_id` as their stable identifier; a completed workout's activity carries the same id in `summary_id`.

External workouts appear only for providers whose API supports retrieving them — see the **Retrieve** row in [Provider Compatibility](/planned-workouts-api/provider-compatibility.md). For providers without retrieve support, only Terra-scheduled workouts are listed.

```json
{
  "planned_date": "2026-07-15",
  "provider_workout_id": "3841172642",
  "is_external": true,
  "details": {
    "metadata": {
      "name": "threshold",
      "planned_date": "2026-07-15",
      "estimated_tss": 65.4,
      "estimated_if": 0.75,
      "estimated_duration_seconds": 3816
    },
    "steps": [
      {
        "order": 0,
        "description": "Warm up",
        "intensity": 1,
        "durations": [{ "duration_type": 0, "seconds": 900 }],
        "targets": [{ "target_type": 13, "hr_percentage_low": 40, "hr_percentage_high": 50 }]
      }
    ]
  }
}
```

{% hint style="info" %}

#### Pass a date window to see upcoming workouts

Without `start_date`/`end_date`, provider-side workouts default to the **trailing 30 days** — so upcoming workouts won't appear. Pass an explicit window (e.g. today through next week) to list what's ahead. Providers also limit how far ahead they expose planned workouts (TrainingPeaks: about 7 days).

A planned workout the user has **completed** leaves this list and is delivered as a completed activity instead.
{% endhint %}
