# Quickstart

{% embed url="<https://www.youtube.com/watch?v=rkvKe4xefwY>" %}
2 minute video walkthrough of Quickstart
{% endembed %}

## Key steps to setup Health & Fitness API

Follow this short tutorial to set up event-based health data delivery via Webhooks. Learn how Terra manages user authentication and can automatically send new user data, simplifying your integration. (Other methods, like requesting historical data, are covered in the detailed guides.

{% stepper %}
{% step %}

#### Integration Setup

**A. Add Data Sources from your Terra Dashboard**

* First you need to select your data sources on your Terra dashboard. This determines:
  * (a) What data sources are available for end-users to chose on the Terra auth widget.
  * What data sources are automatically synced to your data destination via events.

<figure><img src="/files/tkRcrBcYVE0eNyoyf3Wz" alt=""><figcaption></figcaption></figure>

**B. Add a Data Destination in your Terra Dashboard**

* The Health & Fitness API is **event**-**based**, so the **Data** **Destinations** are where you will receive **payload events:**
  * (a) New health data updates
  * (b) Authentication events, de-auth events, etc.

<figure><img src="/files/5zkVGlQvNQc81wmvW3Hg" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}

### How to setup a Webhook destination?

**Webhook.site**

* Using [**webhook.site**](https://webhook.site/) you can generate a temporary webhook destinations for testing.
* Copy *Your unique URL* that is automatically generated when you enter the site.

<img src="/files/jZUXaQmFJBI2ySL5hWVt" alt="" data-size="original">

***

**Your own Webhook endpoint on your local machine**

* First create a web server that runs locally on your computer (see code block).
* Then, expose your server to the internet with a tool such as [ngrok](https://ngrok.com/) and start receiving payloads.
* If you are using ngrok, running `ngrok http {PORT_NUMBER}` will expose your server to the internet and return its URL.

{% code fullWidth="true" %}

```python
import flask

app = flask.Flask(__name__)
if __name__ == "__main__":
    app.run(host="localhost", port=8080)
```

{% endcode %}
{% endhint %}

**C. Obtain your API Key & Dev-ID from your Terra Dashboard**

<figure><img src="/files/CWg03J4HMwVacOdZ0sKb" alt=""><figcaption><p>Screenshot of the Terra dashboard with a red box highlighting the button to obtain API credentials</p></figcaption></figure>

{% hint style="info" %}
**Core concept: \`user\_id\`**

All data is linked back to a `user_id` on Terra's side. This uniquely identifies a wearable account connection through the API and allows you to retrieve data for that wearable account. This is what Terra calls a [Core concepts](/introduction/core-concepts.md#user-terra-user).

**You will use this `user_id` in all your data-related interactions with Terra**
{% endhint %}

{% hint style="info" %}
**Core concept: \`reference\_id\`**

You can link a `user_id` to an entity on your end using a `reference_id`. This is a custom identifying metadata you can define on the Terra User object to link them back to a user on your app.
{% endhint %}
{% endstep %}

{% step %}

#### **User Authentication**

* Next you need to authenticate a user via the API to a data source (e.g. to Oura, Fitbit, Withings).
* Terra simplifies this by allowing you to generate a pre-built authentication widget session (by running the following code).
* Copy/Paste the widget session `url` into web browser. To test the authentication flow, you can choose a data sources (e.g. Fitbit), and complete the flow.

{% tabs %}
{% tab title="Python" %}

```python
# pip install terra-python
from terra import Terra

client = Terra(
    dev_id="<YOUR-DEV-ID>",
    api_key="<YOUR-API-KEY>",
)

response = client.authentication.generatewidgetsession(
    reference_id="my_first_connection",
    auth_success_redirect_url="https://example.com/success",
    auth_failure_redirect_url="https://example.com/failure",
)

widget_url = response.url  # e.g. "https://widget.tryterra.co/session/344d475f-296a-489a-a88c-54183671dafd"
print(widget_url)
```

{% endtab %}

{% tab title="Node.js" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>// npm i -s terra-api
</strong><strong>import { TerraClient } from "terra-api";
</strong>
const client = new TerraClient({
    apiKey: "YOUR_API_KEY",
    devId: "YOUR_DEV_ID"
});

async function generateWidgetSession() {
    try {
        const response = await client.authentication.generatewidgetsession({
            reference_id: "my_first_connection",
            auth_success_redirect_url: "https://example.com/success",
            auth_failure_redirect_url: "https://example.com/failure"
        });
        console.log("Widget URL:", response.url);
    } catch (error) {
        console.error("Error generating widget session:", error.response?.data || error.message);
    }
}

generateWidgetSession();
</code></pre>

{% endtab %}

{% tab title="cURL" %}
{% code title="CLI" %}

```bash
curl --request POST --url https://api.tryterra.co/v2/auth/generateWidgetSession \
  --header 'dev-id: <YOUR-DEV-ID>' \
  --header 'x-api-key: <YOUR-API-KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
      "language": "en",
      "reference_id": "my_first_connection",
      "auth_success_redirect_url": "https://example.com/success",
      "auth_failure_redirect_url": "https://example.com/failure",
  }'
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### **Receive data updates**

* Terra automatically sends new data to your **server (e.g. webhook endpoint)** when it becomes available from your users' wearables.
* If you're using your own Webhook destination, the following code is an example of how you can handle Webhooks.

{% tabs %}
{% tab title="Python" %}
{% code title="python" %}

```python
import logging

import flask
from flask import request

logging.basicConfig(level=logging.INFO)
_LOGGER = logging.getLogger("app")

app = flask.Flask(__name__)


@app.route("/consumeTerraWebhook", methods=["POST"])
def consume_terra_webhook() -> flask.Response:
    data = request.get_json()
    _LOGGER.info(
        "Received webhook for user %s of type %s",
        data.get("user", {}).get("user_id"),
        data["type"]
    )
    # you can now use the incoming data in your app
    # handleData(data)


if __name__ == "__main__":
    app.run(host="localhost", port=8000)
```

{% endcode %}
{% endtab %}

{% tab title="Node.js" %}
{% code title="javascript" %}

```javascript
const express = require("express");
const bodyParser = require("body-parser");

const app = express();

// Parse raw JSON bodies
app.use(
    bodyParser.raw({
        inflate: true,
        limit: "4000kb",
        type: "application/json",
    })
);

// Webhook endpoint
app.post("/consumeTerraWebhook", (req, res) => {
    res.sendStatus(200); // Respond to Terra immediately

    try {
        const data = JSON.parse(req.body.toString("utf8"));
        console.log("Received Terra Webhook Data:");
        console.log(JSON.stringify(data, null, 2));
    } catch (err) {
        console.error("Failed to parse webhook payload:", err.message);
    }
});

// Start server
const port = 3000;
app.listen(port, () => {
    console.log(`Server started on port ${port}`);
})
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

{% endstep %}
{% endstepper %}

## Example payloads

{% tabs %}
{% tab title="Activity" %}

```json

{
  "calories_data": {
    "total_burned_calories": 201.64948069082567,
    "net_activity_calories": 699.1220687609259,
    "calorie_samples": [],
    "net_intake_calories": 36.29916049628912,
    "BMR_calories": 1185.749074044957
  },
  "data_enrichment": {
    "total_stress_score": null,
    "cardiovascular_contributors": null,
    "respiratory_contributors": null,
    "respiratory_score": null,
    "stress_contributors": null,
    "start_time": null,
    "immune_index": null,
    "immune_contributors": null,
    "readiness_score": null,
    "cardiovascular_score": null,
    "readiness_contributors": null
  },
  "metadata": {
    "timestamp_localization": 1,
    "start_time": "2026-01-12T15:15:33.569000+00:00",
    "upload_type": 0,
    "end_time": "2026-01-12T15:58:33.569000+00:00"
  },
  "stress_data": {
    "medium_stress_duration_seconds": 6.349667550340612,
    "max_stress_level": 9.210017873757996,
    "stress_duration_seconds": 9.188461255789646,
    "stress_rating": null,
    "rest_stress_duration_seconds": 19.087716697774244,
    "activity_stress_duration_seconds": 17.692276279869738,
    "avg_stress_level": 5.423064674407496,
    "body_battery_samples": [],
    "low_stress_duration_seconds": 9.16660083749294,
    "high_stress_duration_seconds": 16.284780394560798,
    "samples": [
      {
        "level": 9.722553038898797,
        "timestamp": "2026-01-12T15:15:33.569000+00:00"
      },
      {
        "level": 5.607069716919538,
        "timestamp": "2026-01-12T15:27:33.569000+00:00"
      },
      {
        "level": 10.18828379497692,
        "timestamp": "2026-01-12T15:39:33.569000+00:00"
      },
      {
        "level": 11.682798631709282,
        "timestamp": "2026-01-12T15:51:33.569000+00:00"
      }
    ]
  },
  "scores": {
    "biological_age": null,
    "recovery": null,
    "activity": null,
    "sleep": null
  },
  "device_data": {
    "manufacturer": null,
    "hardware_version": null,
    "other_devices": [],
    "software_version": null,
    "name": null,
    "activation_timestamp": null,
    "serial_number": null,
    "data_provided": [],
    "last_upload_date": null
  },
  "strain_data": {
    "strain_level": null
  },
  "MET_data": {
    "avg_level": null,
    "num_low_intensity_minutes": null,
    "MET_samples": [],
    "num_high_intensity_minutes": null,
    "num_inactive_minutes": null,
    "num_moderate_intensity_minutes": null
  },
  "tag_data": {
    "tags": []
  },
  "active_durations_data": {
    "standing_hours_count": null,
    "vigorous_intensity_seconds": 2146.912371935673,
    "activity_levels_samples": [],
    "rest_seconds": null,
    "standing_seconds": null,
    "low_intensity_seconds": null,
    "moderate_intensity_seconds": 2425.139891985638,
    "num_continuous_inactive_periods": null,
    "inactivity_seconds": 941.5119531235803,
    "activity_seconds": 1372.8110512769454
  },
  "oxygen_data": {
    "saturation_samples": [
      {
        "percentage": 80.01528099248304,
        "type": 0,
        "timestamp": "2026-01-12T15:15:33.569000+00:00"
      },
      {
        "percentage": 89.02423522918154,
        "type": 0,
        "timestamp": "2026-01-12T15:27:33.569000+00:00"
      },
      {
        "percentage": 97.62789203583579,
        "type": 0,
        "timestamp": "2026-01-12T15:39:33.569000+00:00"
      },
      {
        "percentage": 88.66506651767715,
        "type": 0,
        "timestamp": "2026-01-12T15:51:33.569000+00:00"
      }
    ],
    "vo2_samples": [],
    "avg_saturation_percentage": 89.09072682796142,
    "vo2max_ml_per_min_per_kg": null
  },
  "distance_data": {
    "distance_meters": 16885.341964876527,
    "elevation": {
      "gain_planned_meters": null,
      "min_meters": null,
      "avg_meters": null,
      "gain_actual_meters": null,
      "loss_actual_meters": null,
      "max_meters": null
    },
    "floors_climbed": 45,
    "steps": 19906,
    "swimming": {
      "num_strokes": null,
      "num_laps": null,
      "pool_length_meters": null
    },
    "detailed": {
      "floors_climbed_samples": [],
      "step_samples": [
        {
          "timer_duration_seconds": 0,
          "timestamp": "2026-01-12T15:15:33.569000+00:00",
          "steps": 69
        },
        {
          "timer_duration_seconds": 12,
          "timestamp": "2026-01-12T15:27:33.569000+00:00",
          "steps": 252
        },
        {
          "timer_duration_seconds": 24,
          "timestamp": "2026-01-12T15:39:33.569000+00:00",
          "steps": 581
        },
        {
          "timer_duration_seconds": 36,
          "timestamp": "2026-01-12T15:51:33.569000+00:00",
          "steps": 1073
        }
      ],
      "distance_samples": [
        {
          "distance_meters": 11.596938389705349,
          "timer_duration_seconds": 0,
          "timestamp": "2026-01-12T15:15:33.569000+00:00"
        },
        {
          "distance_meters": 38.1556198632113,
          "timer_duration_seconds": 12,
          "timestamp": "2026-01-12T15:27:33.569000+00:00"
        },
        {
          "distance_meters": 79.80821244048354,
          "timer_duration_seconds": 24,
          "timestamp": "2026-01-12T15:39:33.569000+00:00"
        },
        {
          "distance_meters": 90.70677061556792,
          "timer_duration_seconds": 36,
          "timestamp": "2026-01-12T15:51:33.569000+00:00"
        }
      ],
      "elevation_samples": []
    }
  },
  "heart_rate_data": {
    "summary": {
      "resting_hr_bpm": 61.36617472975378,
      "avg_hrv_rmssd": null,
      "hr_zone_data": [],
      "avg_hr_bpm": 104.67539173542949,
      "min_hr_bpm": 109.02337832771033,
      "avg_hrv_sdnn": null,
      "max_hr_bpm": 52.89773898819859,
      "user_max_hr_bpm": null
    },
    "detailed": {
      "hrv_samples_rmssd": [],
      "hrv_samples_sdnn": [],
      "hr_samples": [
        {
          "bpm": 94,
          "context": 0,
          "timer_duration_seconds": null,
          "timestamp": "2026-01-12T15:15:33.569000+00:00"
        },
        {
          "bpm": 82,
          "context": 0,
          "timer_duration_seconds": null,
          "timestamp": "2026-01-12T15:27:33.569000+00:00"
        },
        {
          "bpm": 133,
          "context": 0,
          "timer_duration_seconds": null,
          "timestamp": "2026-01-12T15:39:33.569000+00:00"
        },
        {
          "bpm": 111,
          "context": 0,
          "timer_duration_seconds": null,
          "timestamp": "2026-01-12T15:51:33.569000+00:00"
        }
      ]
    }
  }
}
```

{% endtab %}

{% tab title="Daily" %}

```json
{
    "MET_data":
    {
        "num_high_intensity_minutes": null,
        "num_inactive_minutes": null,
        "avg_level": null,
        "num_low_intensity_minutes": null,
        "MET_samples": [],
        "num_moderate_intensity_minutes": null
    },
    "oxygen_data":
    {
        "saturation_samples": [
        {
            "type": 0,
            "percentage": 92.71897169968557,
            "timestamp": "2026-01-12T15:17:24.946000+00:00"
        },
        {
            "type": 0,
            "percentage": 93.48002536123029,
            "timestamp": "2026-01-12T15:28:24.946000+00:00"
        },
        {
            "type": 0,
            "percentage": 91.1865484069052,
            "timestamp": "2026-01-12T15:39:24.946000+00:00"
        },
        {
            "type": 0,
            "percentage": 98.56181571992339,
            "timestamp": "2026-01-12T15:50:24.946000+00:00"
        },
        {
            "type": 0,
            "percentage": 96.73982424934387,
            "timestamp": "2026-01-12T16:01:24.946000+00:00"
        }],
        "vo2max_ml_per_min_per_kg": null,
        "avg_saturation_percentage": 85.74075219533049,
        "vo2_samples": []
    },
    "scores":
    {
        "sleep": null,
        "activity": null,
        "biological_age": null,
        "recovery": null
    },
    "device_data":
    {
        "hardware_version": null,
        "serial_number": null,
        "activation_timestamp": null,
        "other_devices": [],
        "software_version": null,
        "data_provided": [],
        "last_upload_date": null,
        "name": null,
        "manufacturer": null
    },
    "heart_rate_data":
    {
        "summary":
        {
            "resting_hr_bpm": 40.27773380616422,
            "avg_hr_bpm": 145.57619562270028,
            "hr_zone_data": [],
            "max_hr_bpm": 62.76590801535406,
            "user_max_hr_bpm": null,
            "avg_hrv_rmssd": null,
            "avg_hrv_sdnn": null,
            "min_hr_bpm": 88.04361787772406
        },
        "detailed":
        {
            "hrv_samples_sdnn": [],
            "hrv_samples_rmssd": [],
            "hr_samples": [
            {
                "context": 0,
                "timer_duration_seconds": null,
                "bpm": 88,
                "timestamp": "2026-01-12T15:17:24.946000+00:00"
            },
            {
                "context": 0,
                "timer_duration_seconds": null,
                "bpm": 161,
                "timestamp": "2026-01-12T15:28:24.946000+00:00"
            },
            {
                "context": 0,
                "timer_duration_seconds": null,
                "bpm": 145,
                "timestamp": "2026-01-12T15:39:24.946000+00:00"
            },
            {
                "context": 0,
                "timer_duration_seconds": null,
                "bpm": 114,
                "timestamp": "2026-01-12T15:50:24.946000+00:00"
            },
            {
                "context": 0,
                "timer_duration_seconds": null,
                "bpm": 148,
                "timestamp": "2026-01-12T16:01:24.946000+00:00"
            }]
        }
    },
    "strain_data":
    {
        "strain_level": null
    },
    "active_durations_data":
    {
        "low_intensity_seconds": null,
        "activity_seconds": 292.1944505275938,
        "standing_hours_count": null,
        "vigorous_intensity_seconds": 1629.9213866369444,
        "num_continuous_inactive_periods": null,
        "activity_levels_samples": [],
        "standing_seconds": null,
        "inactivity_seconds": 356.94645537788244,
        "moderate_intensity_seconds": 2549.030844567316,
        "rest_seconds": null
    },
    "data_enrichment":
    {
        "total_stress_score": null,
        "immune_contributors": null,
        "stress_contributors": null,
        "respiratory_contributors": null,
        "respiratory_score": null,
        "cardiovascular_contributors": null,
        "immune_index": null,
        "readiness_score": null,
        "cardiovascular_score": null,
        "start_time": null,
        "readiness_contributors": null
    },
    "metadata":
    {
        "timestamp_localization": 1,
        "upload_type": 0,
        "end_time": "2026-01-12T16:06:24.946000+00:00",
        "start_time": "2026-01-12T15:17:24.946000+00:00"
    },
    "stress_data":
    {
        "low_stress_duration_seconds": 19.313615693723424,
        "max_stress_level": 0.4783574112515465,
        "body_battery_samples": [],
        "medium_stress_duration_seconds": 27.176295626275646,
        "high_stress_duration_seconds": 1.253318481875761,
        "rest_stress_duration_seconds": 30.944456595746683,
        "samples": [
        {
            "level": 0.8367534906275448,
            "timestamp": "2026-01-12T15:17:24.946000+00:00"
        },
        {
            "level": 9.015457752116914,
            "timestamp": "2026-01-12T15:28:24.946000+00:00"
        },
        {
            "level": 7.542179332824672,
            "timestamp": "2026-01-12T15:39:24.946000+00:00"
        },
        {
            "level": 0.7267409467304642,
            "timestamp": "2026-01-12T15:50:24.946000+00:00"
        },
        {
            "level": 13.339626251306429,
            "timestamp": "2026-01-12T16:01:24.946000+00:00"
        }],
        "stress_rating": null,
        "stress_duration_seconds": 30.171079973169284,
        "avg_stress_level": 0.9281102170234745,
        "activity_stress_duration_seconds": 5.485342085200179
    },
    "tag_data":
    {
        "tags": []
    },
    "calories_data":
    {
        "BMR_calories": 1801.1426192553054,
        "total_burned_calories": 265.51092094691603,
        "net_activity_calories": 481.3419040726358,
        "calorie_samples": [],
        "net_intake_calories": 145.58311256774806
    },
    "distance_data":
    {
        "steps": 7708,
        "floors_climbed": 20,
        "detailed":
        {
            "step_samples": [
            {
                "steps": 297,
                "timer_duration_seconds": 0,
                "timestamp": "2026-01-12T15:17:24.946000+00:00"
            },
            {
                "steps": 726,
                "timer_duration_seconds": 11,
                "timestamp": "2026-01-12T15:28:24.946000+00:00"
            },
            {
                "steps": 1091,
                "timer_duration_seconds": 22,
                "timestamp": "2026-01-12T15:39:24.946000+00:00"
            },
            {
                "steps": 1305,
                "timer_duration_seconds": 33,
                "timestamp": "2026-01-12T15:50:24.946000+00:00"
            },
            {
                "steps": 1659,
                "timer_duration_seconds": 44,
                "timestamp": "2026-01-12T16:01:24.946000+00:00"
            }],
            "elevation_samples": [],
            "floors_climbed_samples": [],
            "distance_samples": [
            {
                "distance_meters": 32.233222569064836,
                "timer_duration_seconds": 0,
                "timestamp": "2026-01-12T15:17:24.946000+00:00"
            },
            {
                "distance_meters": 87.88385373215999,
                "timer_duration_seconds": 11,
                "timestamp": "2026-01-12T15:28:24.946000+00:00"
            },
            {
                "distance_meters": 113.28706293967684,
                "timer_duration_seconds": 22,
                "timestamp": "2026-01-12T15:39:24.946000+00:00"
            },
            {
                "distance_meters": 136.35507455273805,
                "timer_duration_seconds": 33,
                "timestamp": "2026-01-12T15:50:24.946000+00:00"
            },
            {
                "distance_meters": 175.40270599823873,
                "timer_duration_seconds": 44,
                "timestamp": "2026-01-12T16:01:24.946000+00:00"
            }]
        },
        "distance_meters": 14034.070754043652,
        "elevation":
        {
            "avg_meters": null,
            "min_meters": null,
            "gain_planned_meters": null,
            "gain_actual_meters": null,
            "max_meters": null,
            "loss_actual_meters": null
        },
        "swimming":
        {
            "num_laps": null,
            "pool_length_meters": null,
            "num_strokes": null
        }
    }
}
```

{% endtab %}

{% tab title="Sleep" %}

```json
{
    "data_enrichment":
    {
        "sleep_score": null,
        "sleep_contributors": null
    },
    "heart_rate_data":
    {
        "summary":
        {
            "user_max_hr_bpm": null,
            "avg_hr_bpm": 41,
            "max_hr_bpm": 71,
            "avg_hrv_rmssd": 116,
            "min_hr_bpm": 60,
            "resting_hr_bpm": 65,
            "avg_hrv_sdnn": null
        },
        "detailed":
        {
            "hrv_samples_rmssd": [
            {
                "timestamp": "2026-01-12T15:18:04.316000+00:00",
                "hrv_rmssd": 57
            },
            {
                "timestamp": "2026-01-12T15:30:04.316000+00:00",
                "hrv_rmssd": 71
            },
            {
                "timestamp": "2026-01-12T15:42:04.316000+00:00",
                "hrv_rmssd": 54
            },
            {
                "timestamp": "2026-01-12T15:54:04.316000+00:00",
                "hrv_rmssd": 101
            },
            {
                "timestamp": "2026-01-12T16:06:04.316000+00:00",
                "hrv_rmssd": 43
            },
            {
                "timestamp": "2026-01-12T16:18:04.316000+00:00",
                "hrv_rmssd": 78
            },
            {
                "timestamp": "2026-01-12T16:30:04.316000+00:00",
                "hrv_rmssd": 91
            },
            {
                "timestamp": "2026-01-12T16:42:04.316000+00:00",
                "hrv_rmssd": 77
            },
            {
                "timestamp": "2026-01-12T16:54:04.316000+00:00",
                "hrv_rmssd": 89
            }],
            "hrv_samples_sdnn": [],
            "hr_samples": [
            {
                "context": 0,
                "timestamp": "2026-01-12T15:18:04.316000+00:00",
                "bpm": 87,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T15:30:04.316000+00:00",
                "bpm": 84,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T15:42:04.316000+00:00",
                "bpm": 135,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T15:54:04.316000+00:00",
                "bpm": 163,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T16:06:04.316000+00:00",
                "bpm": 168,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T16:18:04.316000+00:00",
                "bpm": 159,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T16:30:04.316000+00:00",
                "bpm": 170,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T16:42:04.316000+00:00",
                "bpm": 119,
                "timer_duration_seconds": null
            },
            {
                "context": 0,
                "timestamp": "2026-01-12T16:54:04.316000+00:00",
                "bpm": 163,
                "timer_duration_seconds": null
            }]
        }
    },
    "device_data":
    {
        "activation_timestamp": null,
        "last_upload_date": null,
        "software_version": null,
        "serial_number": null,
        "data_provided": [],
        "hardware_version": null,
        "other_devices": [],
        "manufacturer": null,
        "name": null
    },
    "sleep_durations_data":
    {
        "awake":
        {
            "num_wakeup_events": null,
            "duration_long_interruption_seconds": null,
            "duration_awake_state_seconds": 422.440743038517,
            "sleep_latency_seconds": 75.3128264600394,
            "duration_short_interruption_seconds": null,
            "wake_up_latency_seconds": 409.7986863235109,
            "num_out_of_bed_events": null
        },
        "hypnogram_samples": [
        {
            "level": 4,
            "timestamp": "2026-01-12T15:18:04.316000+00:00"
        },
        {
            "level": 5,
            "timestamp": "2026-01-12T15:30:04.316000+00:00"
        },
        {
            "level": 2,
            "timestamp": "2026-01-12T15:42:04.316000+00:00"
        },
        {
            "level": 6,
            "timestamp": "2026-01-12T15:54:04.316000+00:00"
        },
        {
            "level": 0,
            "timestamp": "2026-01-12T16:06:04.316000+00:00"
        },
        {
            "level": 4,
            "timestamp": "2026-01-12T16:18:04.316000+00:00"
        },
        {
            "level": 6,
            "timestamp": "2026-01-12T16:30:04.316000+00:00"
        },
        {
            "level": 6,
            "timestamp": "2026-01-12T16:42:04.316000+00:00"
        },
        {
            "level": 6,
            "timestamp": "2026-01-12T16:54:04.316000+00:00"
        }],
        "asleep":
        {
            "num_REM_events": null,
            "duration_deep_sleep_state_seconds": 235.6767638816588,
            "duration_REM_sleep_state_seconds": 366.2891680639711,
            "duration_light_sleep_state_seconds": 79.73794929949709,
            "duration_asleep_state_seconds": 154.94272052544733
        },
        "sleep_efficiency": 20.45276477924687,
        "other":
        {
            "duration_in_bed_seconds": 372.64335780777157,
            "duration_unmeasurable_sleep_seconds": null
        }
    },
    "respiration_data":
    {
        "oxygen_saturation_data":
        {
            "avg_saturation_percentage": 90,
            "start_time": "2026-01-12T16:54:04.316000+00:00",
            "end_time": "2026-01-12T16:54:04.316000+00:00",
            "samples": [
            {
                "timestamp": "2026-01-12T15:18:04.316000+00:00",
                "percentage": 91,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T15:30:04.316000+00:00",
                "percentage": 93,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T15:42:04.316000+00:00",
                "percentage": 92,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T15:54:04.316000+00:00",
                "percentage": 98,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T16:06:04.316000+00:00",
                "percentage": 99,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T16:18:04.316000+00:00",
                "percentage": 94,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T16:30:04.316000+00:00",
                "percentage": 93,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T16:42:04.316000+00:00",
                "percentage": 92,
                "type": 0
            },
            {
                "timestamp": "2026-01-12T16:54:04.316000+00:00",
                "percentage": 94,
                "type": 0
            }]
        },
        "breaths_data":
        {
            "avg_breaths_per_min": 15,
            "start_time": "2026-01-12T16:54:04.316000+00:00",
            "on_demand_reading": null,
            "end_time": "2026-01-12T16:54:04.316000+00:00",
            "samples": [
            {
                "breaths_per_min": 13,
                "timestamp": "2026-01-12T15:18:04.316000+00:00"
            },
            {
                "breaths_per_min": 12,
                "timestamp": "2026-01-12T15:30:04.316000+00:00"
            },
            {
                "breaths_per_min": 12,
                "timestamp": "2026-01-12T15:42:04.316000+00:00"
            },
            {
                "breaths_per_min": 12,
                "timestamp": "2026-01-12T15:54:04.316000+00:00"
            },
            {
                "breaths_per_min": 12,
                "timestamp": "2026-01-12T16:06:04.316000+00:00"
            },
            {
                "breaths_per_min": 12,
                "timestamp": "2026-01-12T16:18:04.316000+00:00"
            },
            {
                "breaths_per_min": 10,
                "timestamp": "2026-01-12T16:30:04.316000+00:00"
            },
            {
                "breaths_per_min": 12,
                "timestamp": "2026-01-12T16:42:04.316000+00:00"
            },
            {
                "breaths_per_min": 15,
                "timestamp": "2026-01-12T16:54:04.316000+00:00"
            }],
            "max_breaths_per_min": 17,
            "min_breaths_per_min": 18
        },
        "snoring_data":
        {
            "num_snoring_events": null,
            "total_snoring_duration_seconds": null,
            "start_time": "2026-01-12T16:54:04.316000+00:00",
            "end_time": "2026-01-12T16:54:04.316000+00:00",
            "samples": [
            {
                "timestamp": "2026-01-12T15:18:04.316000+00:00",
                "duration_seconds": 43
            },
            {
                "timestamp": "2026-01-12T15:30:04.316000+00:00",
                "duration_seconds": 3
            },
            {
                "timestamp": "2026-01-12T15:42:04.316000+00:00",
                "duration_seconds": 84
            },
            {
                "timestamp": "2026-01-12T15:54:04.316000+00:00",
                "duration_seconds": 98
            },
            {
                "timestamp": "2026-01-12T16:06:04.316000+00:00",
                "duration_seconds": 95
            },
            {
                "timestamp": "2026-01-12T16:18:04.316000+00:00",
                "duration_seconds": 34
            },
            {
                "timestamp": "2026-01-12T16:30:04.316000+00:00",
                "duration_seconds": 83
            },
            {
                "timestamp": "2026-01-12T16:42:04.316000+00:00",
                "duration_seconds": 34
            },
            {
                "timestamp": "2026-01-12T16:54:04.316000+00:00",
                "duration_seconds": 63
            }]
        }
    },
    "scores":
    {
        "sleep": null
    },
    "temperature_data":
    {
        "delta": null
    },
    "metadata":
    {
        "is_nap": false,
        "summary_id": null,
        "start_time": "2026-01-12T15:18:04.316000+00:00",
        "timestamp_localization": 1,
        "end_time": "2026-01-12T22:59:04.316000+00:00",
        "upload_type": 0
    },
    "readiness_data":
    {
        "recovery_level": 0,
        "readiness": null
    }
}
```

{% endtab %}
{% endtabs %}

## Next steps

Now that you understand the basics, move onto onto our [**guides**](https://docs.tryterra.co/health-and-fitness-api/integration-setup) for detailed documentation on the Health & Fitness API


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tryterra.co/health-and-fitness-api/quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
