For the complete documentation index, see llms.txt. This page is also available as Markdown.

Writing data

Learn how to write data back to providers, and create a bi-directional data stream between your app and the various integrations you connect to

Terra allows you to write data back to a user's account, wherever supported by the respective Provider.

Writing Planned Workouts

Overview

Writing planned workouts allows you to create a workout plan for the user (such as those commonly used with Zwift)

This will typically look like the following example:

Planned workouts consist of a series of steps. Each step has:

  • Completion criteria (called duration for all intents and purposes). For example:

    • distance (keep going until you cover 500m),

    • energy expenditure (keep going until you burn 200 kcal)

    • heart rate threshold (keep going until your heart rate reaches above 150 bpm)

    • etc..

  • One or more targets to be maintained

    • heart rate (maintain heart rate between certain bounds)

    • speed (maintain speed between certain bounds)

    • grade (inclination above a certain threshold)

    • etc...

  • An associated intensity label

    • Warmup

    • Active

    • Cooldown

    • etc..

  • An exercise type

    • Running

    • Cycling

    • Deadlifting

    • etc...

  • A series of sub-steps

These modalities allow any workout to be described in a series of defined steps for each of its segments.

Once written, a planned workout will be available in the user's library of workouts on the respective platform, and the user will then be able to follow the workout step by step on their wearable device

Writing Planned Workouts

Supported providers

Currently supported providers are:

  • Garmin

  • Hammerhead

  • Coros

  • TodaysPlan

See the https://app.gitbook.com/s/eJJpVMsUARUJq9lYmL6t/unified-api/supported-integrations page for a full list of supported data types per Provider

Usage

In order to write a planned workout to the user's device, you may use the following endpoint

The response will include log_ids which will be a list of the identifiers for the uploaded workout plans. You may use those identifiers to identify the workout plan later on in the https://app.gitbook.com/s/eJJpVMsUARUJq9lYmL6t/unified-api/readme#get-plannedworkoutendpoint, or to delete them using the https://app.gitbook.com/s/eJJpVMsUARUJq9lYmL6t/unified-api/readme#delete-plannedworkout

Enum values

The steps, durations, and targets objects use integer enums. The accepted values are below. Not every provider supports every value. Garmin accepts target_type values 0, 1, 2, 3, 4, 8, 11, 13, 14 and 15 only; a step whose targets fall entirely outside that set is rejected.

Step type

Value
Meaning

0

Step

1

Repeat step

Step intensity

Value
Meaning

0

Rest

1

Warm up

2

Cool down

3

Recovery

4

Interval

5

Active

duration_type

Value
Meaning

0

Time

1

Distance (metres)

2

Heart rate below

3

Heart rate above

4

Calories

5

Open

6

Power below

7

Power above

8

Repetition time

9

Reps

10

Fixed rest

11

Time at valid CdA

12

Steps

target_type

Value
Meaning

0

Speed

1

Heart rate

2

Open

3

Cadence

4

Power

5

Grade

6

Resistance

7

Power lap

8

Swim stroke

9

Speed lap

10

Heart rate lap

11

Pace

12

Heart rate threshold %

13

Heart rate max %

14

Speed %

15

Power %

16

Repetition

17

TSS

18

IF

19

RPE

Examples

Aerobic fitness test

The aerobic fitness test begins with a 5 minute warm-up.

After warming up, the intensity will ramp up over the duration of 5 minutes, reaching a 91% max HR intensity.

Once you are done with the all out effort, you will spend 2 minutes in a recovery step, before spending 5 minutes cooling down

Last updated

Was this helpful?