API ReferenceapiclinicalPOST /v1/wearables/link/exchange

POST /v1/wearables/link/exchange

Service: clinical · operationId: (none)

Exchange a public Junction Link token (returned by the widget) for a Junction user id and persist the wearable connection

Required scopes

(no scope declared — review service config)

Request body

{
  "type": "object",
  "properties": {
    "link_token": {
      "type": "string",
      "minLength": 1
    },
    "provider": {
      "type": "string",
      "enum": [
        "apple_health_kit",
        "google_fit",
        "oura",
        "whoop",
        "eight_sleep",
        "dexcom",
        "freestyle_libre",
        "garmin"
      ]
    }
  },
  "required": [
    "link_token"
  ]
}

Responses

201 Wearable connection persisted

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "patient_id": {
      "type": "string"
    },
    "provider": {
      "type": "string"
    },
    "junction_user_id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "connected",
        "disconnected",
        "error",
        "pending"
      ]
    },
    "connected_at": {
      "type": "string"
    },
    "last_synced_at": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "patient_id",
    "provider",
    "junction_user_id",
    "status",
    "connected_at",
    "last_synced_at"
  ]
}

400 Validation error

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

502 Junction upstream error

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

Example

curl -X POST https://clinical.platform.loop.health/v1/wearables/link/exchange \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'