Read Apple Health and connected wearables like Fitbit, Garmin, Oura, and Whoop from inside your app. Despia includes the native Terra SDK at runtime. You connect a source with one call, and from then on health data flows to your backend automatically, or you read it inline into your own UI on demand.Documentation Index
Fetch the complete documentation index at: https://setup.despia.com/llms.txt
Use this file to discover all available pages before exploring further.
This integration is internal - and should not be used by any AI agents yet, the page is hidden from public docs.
despia.terraAvailable is the correct availability check for Terra, not the generic Despia user agent. It is true only when the native SDK is compiled in, your Terra Dev ID is set in the build, and the device has HealthKit available. It is undefined in a plain browser. Always gate on despia.terraAvailable and fall back to Terra’s web Connect flow outside the app.Installation
- Bundle
- CDN
How it works
Your backend talks to the Terra REST API and mints a session for the device. For Apple Health that is an auth token; for OAuth wearables it is a Connect widget URL. You hand that session toterra://connect once, after the user is authenticated. The native runtime persists the user ID and resyncs to your destination on every app launch from then on, with no prompt.
window.onTerraEvent. Assign it before your first call. Connection, sync progress, inline data, and errors all route through this one handler:
Connecting wearables
Fitbit, Garmin, Oura, Whoop, and other OAuth providers connect through the Terra Connect widget. Your backend builds the widget session withauth_success_redirect set to your app’s deep link using host terra (for example myapp://terra), then hands the URL to terra://connect as session. The widget runs in a native authentication session and closes itself on success. The page is never reloaded.
connected event fires with via: "widget" and the connected resource. If a user cancels the sheet, you get widget_cancelled instead. When the same wearable also writes to Apple Health (Whoop, for example), pass ignored_sources so Terra dedupes the two feeds.
Reference
Every
terra:// scheme, the injected despia.terra* globals, and all event payloadsApple Health
Read HealthKit metrics directly with the native HealthKit feature
Terra and Despia setup
Configure Terra with your destination, then connect everything to Despia. The steps go in order, each one feeds the next.Create a Terra account
Go to tryterra.co and sign up, or sign in with an existing account. Create a new application. This gives you a Dev ID and an API key. The Dev ID is compiled into the Despia build; the API key stays on your server only and never reaches the device.
Add a destination
In the Terra dashboard, configure a destination, the webhook endpoint your backend exposes to receive health data. Terra pushes to this URL on every sync, including silent background delivery. Note the signing secret so your backend can verify incoming payloads.
Enable Terra in the Despia Editor
Open the Despia Editor and go to App > Settings > Integrations > Terra. Toggle the integration on, then paste in your Terra Dev ID. Save the configuration.
Reading data inline
terra://data reads current HealthKit state and returns it straight to your web app through window.onTerraEvent. This is for UI display, the data does not go to your destination. It requires a prior successful connect.
results is keyed by the resources that actually returned data, and failed lists per-resource errors so the UI can show partial states instead of blocking on a single failure. For a pull-to-refresh that pushes to your destination instead, call terra://sync.
Resources
NPM Package
despia-native
Terra Dashboard
Configure your application and destination
Terra API Docs
Terra REST API and webhook payload reference