Quickstart

Learn how to receive data events in just 3 steps

2 minute video walkthrough of Quickstart

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.

1

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.

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.

circle-info

How to setup a Webhook destination?

Webhook.site

  • Using webhook.sitearrow-up-right you can generate a temporary webhook destinations for testing.

  • Copy Your unique URL that is automatically generated when you enter the site.


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 ngrokarrow-up-right 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.

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

Screenshot of the Terra dashboard with a red box highlighting the button to obtain API credentials
circle-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 User (Terra user).

You will use this user_id in all your data-related interactions with Terra

circle-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.

2

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.

3

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.

4

Example payloads

Next steps

Now that you understand the basics, move onto onto our guides for detailed documentation on the Health & Fitness API

Last updated

Was this helpful?