Skip to content

Choosing how athletes connect

This page explains the ways an app gets athletes' data into SweatStack, and who owns the athlete's account in each.

The ways differ in two things: who talks to the wearable platform, and who signs the athlete in.

Way Who talks to the platform Who signs the athlete in Whose user the athlete is
Hosted SweatStack, on its own keys SweatStack A SweatStack account that grants your app access
Self-hosted integration Your app, on its own keys SweatStack, through your app's OpenID Provider Your app's
Own keys SweatStack, on your app's keys SweatStack Your app's
Bring your own data Your app Your app Your app's

Hosted is the default for the platforms that offer it: nothing to obtain, one consent screen, and the athlete gets a SweatStack account they can use with other apps too. A self-hosted integration is for a platform your app connects to on its own keys, when athletes sign in through SweatStack's sign-in screen. Bring your own data is for an app that already collects the data itself and has its own sign-in: from a platform it has its own agreement with, from a platform SweatStack does not integrate with, or from its own device.

Which way each platform allows is on the Integrations page.

Your app can mix the ways per platform: hosted Wahoo for some athletes, and Garmin Connect through a self-hosted integration for the users your app manages. If your app runs a platform itself, its sign-in screen has no email sign-up: see What athletes see on your sign-in screen. To bring your own data, create the athlete with the management API, get a token for them, and relay their files and dailies.

Use Garmin Connect data

Your app connects Garmin Connect on its own Garmin keys: through a self-hosted integration, which we recommend, or with your own sign-in as bring your own data. Tell Garmin that SweatStack processes the data on your behalf. See Garmin Connect.

Send Garmin data only for users your app manages. A SweatStack account can share its data with other apps, and data from your own Garmin connection must stay with your app.

Who owns the athlete

With Hosted, the athlete owns their account. It is a SweatStack account: they can sign in at sweatstack.no, connect other apps to it, and delete it. Your app receives a copy of the data they grant it, and you are an independent controller of that copy (the developer terms).

With every other way, the athlete's account belongs to your app. SweatStack manages it completely on your behalf: identity, email, sign-in, recovery, data, deletion, so you never build an account system around it. Such a user:

  • belongs to exactly one app and is deleted with it;
  • signs in to that app only, never to sweatstack.no;
  • cannot authorize another app or a team and is never shared;
  • connects only the platforms your app runs itself, never a platform that SweatStack hosts;
  • has the same sub, tokens, data endpoints, webhooks, account status and Portal as a SweatStack account.

A token for such a user holds what you tick under Data your app uses on the Consent screen tab, and never more. If you change what you tick, every token issued from then on follows, for all your app's users. If an authorize request asks for more, the token holds the part you ticked, and scope in the token response says what was issued.

You are the controller of these accounts and SweatStack your processor, under the Data Processing Agreement. Their email, if your app gives one, is unverified until the person confirms it through the message SweatStack sends, co-branded with your app.

What is the same everywhere

Tokens and their sub, the data endpoints, webhooks, the account status and Portal links: your code reads a user the same way whichever layer they came through. What differs is how the user came into existence and who talks to the platform, and that is exactly the table above.

The management API (beta)

Beta

The management API is in beta and is subject to breaking changes. If you plan to use it in production, email [email protected] before you integrate, so we can tell you about changes in advance and help you migrate.

The management API is how your app creates, finds and deletes the users that belong to it, and how it gets a token for one without the athlete present. Your client_secret is your app's credential for the client credentials grant, and that grant gives your app a token for itself. No user token works here, and your app's token works nowhere else.

curl -u "$CLIENT_ID:$CLIENT_SECRET" \
  -X POST https://app.sweatstack.no/api/v1/oauth/token \
  -d "grant_type=client_credentials"

The access_token in the response is what you send on every call below. It holds no scopes and comes without a refresh token: when expires_in runs out, ask for a new one. It counts no one as active for billing.

Before your app can create users, you accept the developer terms and the Data Processing Agreement for it on its Consent screen tab (see Going live); until then the create call answers 403 and says where.

Create a user, with your own reference for them:

curl -H "Authorization: Bearer $APP_TOKEN" \
  -X POST https://app.sweatstack.no/api/v1/applications/$CLIENT_ID/users \
  -H "Content-Type: application/json" \
  -d '{"first_name": "Kari", "last_name": "Nordmann", "email": "[email protected]", "external_reference": "kari-42"}'

The response is the user: id (their sub from now on), the name, email, email_verified, external_reference and registered_at. This call finds or creates: when external_reference is already taken in your app, it answers 200 with that user, unchanged, so you need no read before the write. A new user answers 201, and a second user with the same email answers 409. The same email may belong to a SweatStack account at the same time; that is a different person as far as SweatStack is concerned.

Find your users (GET .../users, filtered with ?email= or ?external_reference=), read one (GET .../users/{user_id}), change a name (PATCH .../users/{user_id}; an email address is changed through support) or delete one and all their data (DELETE .../users/{user_id}, irreversible).

Get a token for one of them:

curl -H "Authorization: Bearer $APP_TOKEN" \
  -X POST https://app.sweatstack.no/api/v1/applications/$CLIENT_ID/users/$USER_ID/token

The response is an access token that holds what you ticked under Data your app uses, as it is when you ask. You can ask from the moment the user exists. Use the token on the data API as any other token. There is no refresh token: when expires_in runs out, ask for another. Every token minted this way counts the user as active for billing, like any token.

To get a token that holds only a part of that, send scope:

curl -H "Authorization: Bearer $APP_TOKEN" \
  -X POST https://app.sweatstack.no/api/v1/applications/$CLIENT_ID/users/$USER_ID/token \
  -H "Content-Type: application/json" \
  -d '{"scope": "activities:write"}'

Separate several scopes with spaces. A scope you did not tick answers 400.

If your app runs a platform on its own infrastructure, tell SweatStack when one of your users connects to it, so the account status and the Portal tell the truth before their first file arrives:

curl -H "Authorization: Bearer $APP_TOKEN" \
  -X PUT https://app.sweatstack.no/api/v1/applications/$CLIENT_ID/users/$USER_ID/connections/garmin_connect \
  -H "Content-Type: application/json" \
  -d '{"capabilities": {"activities": "ready", "activity_history": "syncing", "wellness": "unavailable", "workouts": "unavailable"}}'

The values are the ones the account status uses: ready, syncing, action_required and unavailable. A capability you leave out reads unavailable, and a syncing older than a day reads ready. Send it again whenever something changes; DELETE the same URL when the connection ends. SweatStack stores what you state and holds no credential or platform id. The platform must be set to Self-hosted on your app's Data sources tab. Otherwise the call answers 409.

If your integration signs athletes in as an OpenID Provider, it knows a person by its own sub, not by a SweatStack user id. State the connection by that sub instead: see Tell SweatStack what a connection provides.

Deleting your app deletes its users and all their data. The Settings tab says how many go with it and asks for the app's name before it does.

A Portal link for one of these users signs them in: it works once, for a few minutes. The profile destination opens their name and email; manage-teams is not available to them.

The endpoint reference is under App users.

Naming

"Bring your own data" is always written in full, so it is not read as "bring your own device". "Client credentials" means your app's own SweatStack client_id and client_secret.