> ## Documentation Index
> Fetch the complete documentation index at: https://foreverbetter.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect your agent

> Let an AI agent sign you in, create its own scoped key, and connect your wearables. No code required.

You do not need to write code to use this API. Point your agent at the service
and it can sign you in, create a personal API key, upload your data, and
connect your WHOOP. You read one 8-digit code from your email; the agent does
the rest.

## Paste this into your agent

```text theme={null}
Help me analyze and connect my longevity data.
1. Read https://api.foreverbetter.xyz/SKILL.md and follow its onboarding.
2. Ask whether I want local or cloud mode. If I choose cloud, sign me in,
   ask me for the 8-digit email code, and create my personal API key.
3. Store the key securely. Call GET /capabilities, tell me what you can
   do, and offer to connect WHOOP or ForeverBetter Connect on Android.
```

Works with Claude and any agent that can call an HTTP API or speak MCP.

## What the agent does

Three calls. First it requests a sign-in code for your email:

```bash theme={null}
curl -s -X POST "https://api.foreverbetter.xyz/auth/otp/start" \
  -H "content-type: application/json" \
  -d '{"email":"you@example.com","should_create_user":true}'
```

You receive an email with a sign-in link and an 8-digit code. Give the code to
your agent, which exchanges it for a session:

```bash theme={null}
curl -s -X POST "https://api.foreverbetter.xyz/auth/otp/verify" \
  -H "content-type: application/json" \
  -d '{"email":"you@example.com","token":"12345678"}'
# → { "access_token": "...", "user": { "id": "..." } }
```

Then it mints a durable personal key with that session token:

```bash theme={null}
curl -s -X POST "https://api.foreverbetter.xyz/api-keys" \
  -H "authorization: Bearer $ACCESS_TOKEN" \
  -H "content-type: application/json" -d '{}'
# → { "api_key": "...", "created": { "user_id": "...", "organization_id": "..." } }
```

The key is shown once, lasts 365 days, and acts only for you: it is scoped to
your user and your personal workspace, with grants for imports, analyses,
trends, goals, questions, health context, and wearable connections. No
credit card.

## Add the API to Claude over MCP

With the key in hand, the API can also be attached as an MCP server:

```bash theme={null}
claude mcp add --transport http foreverbetter \
  https://api.foreverbetter.xyz/mcp \
  --header "Authorization: Bearer <api key>"
```

Or in any client that reads an `mcpServers` config:

```json theme={null}
{
  "mcpServers": {
    "foreverbetter": {
      "type": "http",
      "url": "https://api.foreverbetter.xyz/mcp",
      "headers": { "Authorization": "Bearer <api key>" }
    }
  }
}
```

`tools/list` returns only the tools your key grants. See
[Agents & MCP](/agents-and-mcp) for the tool catalog and error format.

## Connect your WHOOP from chat

The same key authorizes wearable connections. Your agent starts the flow with
no OAuth credentials on first-party deployments (check `first_party_oauth`
under `wearables.whoop` in `GET /capabilities`):

```bash theme={null}
curl -s -X POST "https://api.foreverbetter.xyz/connections/wearables/start" \
  -H "authorization: Bearer $FB_KEY" -H "content-type: application/json" \
  -d '{"user_id":"'$UID'","organization_id":"'$ORG'","source_provider":"whoop"}'
# → { "authorization_url": "https://api.prod.whoop.com/oauth/oauth2/auth?..." }
```

Open the `authorization_url` your agent gives you and approve access. WHOOP
sends you back to the ForeverBetter dashboard, which displays a connection
code. Copy that code back to your agent, and it completes the link:

```bash theme={null}
curl -s -X POST "https://api.foreverbetter.xyz/connections/wearables/callback" \
  -H "authorization: Bearer $FB_KEY" -H "content-type: application/json" \
  -d '{"user_id":"'$UID'","organization_id":"'$ORG'","source_provider":"whoop","code":"'$CODE'"}'
```

From there the agent can sync and analyze on demand:

```bash theme={null}
curl -s -X POST "https://api.foreverbetter.xyz/connections/wearables/sync" \
  -H "authorization: Bearer $FB_KEY" -H "content-type: application/json" \
  -d '{"user_id":"'$UID'","organization_id":"'$ORG'","source_provider":"whoop"}'
```

The full WHOOP walkthrough is at [Connect a WHOOP](/use-cases/connect-whoop).

## Google Health Connect through ForeverBetter Connect

On Android, install and open the **ForeverBetter Connect** consumer app. Sign
in with the same ForeverBetter account, choose **Google Health Connect**, grant
the read permissions you want, and start background sync. Health Connect can
aggregate Fitbit, Samsung Health, Google Fit, and other Android sources before
ForeverBetter Connect uploads normalized records to your account.

On Android 14 and newer, Health Connect is built into Settings. On Android 13
and lower, install [Google Health Connect](https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata)
from Google Play first. Installing Google's app alone does not upload data to
ForeverBetter; ForeverBetter Connect performs the authenticated sync. See
[Wearable onboarding](/wearable-onboarding) for the consumer and embedded
flows.

## Prefer the dashboard?

Sign in at the [dashboard](https://api.foreverbetter.xyz/dashboard) with an
email magic link or your 8-digit code, create the key there, and paste it into
your agent. Both paths produce the same key.

## Boundaries

A free personal key covers you and your own agent. Building an app, platform,
or service for other users requires a Builder key or higher; see
[pricing](https://api.foreverbetter.xyz/pricing). You can export or delete
everything the API holds about you at any time with
`GET /users/{user_id}/data/export` and `POST /users/{user_id}/data/delete`.
