Skip to main content

Endpoint

GET /api/v1/pulse/theta/{provider_slug}/link

Overview

Start the OAuth authentication flow to connect a user’s health device account. This endpoint returns an authorization URL that the user must visit to grant permissions.

Request

provider_slug
string
required
The provider slug (e.g., theta_garmin, theta_whoop)
user_id
string
required
The unique identifier for the user linking their account
return_url
string
Optional URL to redirect to after successful linking
curl "http://localhost:18080/api/v1/pulse/theta/theta_garmin/link?user_id=user_123&return_url=https://myapp.com/success"

Response

{
  "link_web_url": "https://connect.garmin.com/oauthConfirm?oauth_token=abc123..."
}

Response Fields

OAuth authorization URL that the user should visit in their browser to grant permissions

OAuth Flow

1

Call the link endpoint

Your application calls this endpoint with the user’s ID
2

Redirect user to authorization URL

Redirect the user to the link_web_url in their browser
3

User grants permissions

User logs in to their health device account and authorizes access
4

Callback processed

Provider redirects back to Mirobody Health, which processes the callback and saves credentials
5

Link complete

User can now sync their health data

Example Implementation

import aiohttp

async def link_provider(user_id: str, provider_slug: str, return_url: str = None):
    params = {"user_id": user_id}
    if return_url:
        params["return_url"] = return_url
    
    url = f"http://localhost:18080/api/v1/pulse/theta/{provider_slug}/link"
    
    async with aiohttp.ClientSession() as session:
        async with session.get(url, params=params) as resp:
            data = await resp.json()
            return data["link_web_url"]

# Get authorization URL
auth_url = await link_provider("user_123", "theta_garmin")

# Redirect user to auth_url in browser
print(f"Please visit: {auth_url}")

Error Responses

{
  "error": {
    "code": "PROVIDER_NOT_FOUND",
    "message": "Provider 'theta_unknown' not found or not supported"
  }
}
{
  "error": {
    "code": "PROVIDER_NOT_CONFIGURED",
    "message": "Provider 'theta_garmin' is not properly configured. Missing OAuth credentials."
  }
}
The authorization URL is time-limited (typically 15 minutes). If the user doesn’t complete authorization within this time, they’ll need to request a new link.
Use the return_url parameter to redirect users back to a specific page in your application after successful linking.