---
title: "Generate Vital Link Token"
method: POST
path: "/v2/link/token"
tags: ["link"]
---

# Generate Vital Link Token

`POST /v2/link/token`

Endpoint to generate a user link token, to be used throughout the vital
link process. The vital link token is a one time use token, that
expires after 10 minutes. If you would like vital-link widget to launch
with a specific provider, pass in a provider in the body. If you would
like to redirect to a custom url after successful or error connection,
pass in your own custom redirect_url parameter.

## Request body

- LinkTokenExchange
  - `user_id` string, uuid, required — User id returned by vital create user request. This id should be stored in your database against the user and used for all interactions with the vital api.
  - `provider` 'oura' | 'fitbit' | 'garmin' | 'whoop' | 'strava' | 'renpho' | 'peloton' | 'wahoo' | 'zwift' | 'freestyle_libre' | 'abbott_libreview' | 'tandem_source' | 'freestyle_libre_ble' | 'eight_sleep' | 'withings' | 'apple_health_kit' | 'manual' | 'ihealth' | 'google_fit' | 'beurer_api' | 'beurer_ble' | 'omron' | 'omron_ble' | 'onetouch_ble' | 'accuchek_ble' | 'contour_ble' | 'dexcom' | 'dexcom_v3' | 'hammerhead' | 'my_fitness_pal' | 'health_connect' | 'samsung_health' | 'polar' | 'cronometer' | 'kardia' | 'whoop_v2' | 'ultrahuman' | 'my_fitness_pal_v2' | 'map_my_fitness' | 'runkeeper' | 'google_health' — ℹ️ This enum is non-exhaustive.
  - `redirect_url` string, nullable
  - `filter_on_providers` Providers[], nullable — An allowlist of providers dictating what Vital Link Widget should show to the end user. If unspecified, all linkable providers are shown. This has no effect on programmatic Vital Link API usage.
  - `on_error` 'redirect', nullable — By default, Vital Link Widget input forms for password and email providers have in-built error handling. Specifying `on_error=redirect` disables this Vital Link Widget UI behaviour — it would instead redirect to your `redirect_url`, with Link Error parameters injected. This has no effect on OAuth providers — they always redirect to your `redirect_url`. This also has no effect on programmatic Vital Link API usage.
  - `on_close` 'redirect', nullable — By default, Vital Link Widget closes the window or tab when the user taps the Close button. Specifying `on_close=redirect` would change the Close button behaviour to redirect to your `redirect_url` with the `user_cancelled` error specified. This has no effect on programmatic Vital Link API usage.

## Response `200`

Successful Response

- LinkTokenExchangeResponse
  - `link_token` string, required — A short-lived Vital Link token for your Custom Link Widget to communicate with the Vital API.
  - `link_web_url` string, required — The web browser link to launch the default Vital Link experience. If you requested the token for one specific provider, the link would redirect directly to the provider authentication flow. Otherwise, the user would be presented with a list of providers based on your team and token configurations.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/tryvital/apis/junction-api.md) · [All operations](https://skmtc.net/tryvital/apis/junction-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tryvital/junction-api/revisions/1a22b97afb3a/schema)
