OnePath Connect
OnePath Connect
OnePath Connect Documentation
SDKsTypeScript / JavaScript SDKPython SDK
SDKs

TypeScript / JavaScript SDK

Official TypeScript and JavaScript client for OnePath Connect.

The @onepathhealth/connect package is the official TypeScript SDK. It wraps every API endpoint with full type safety, typed errors, and IDE autocomplete.

Access: The SDK is distributed through GitHub Packages. After your BAA is executed, you'll receive an invitation to the onepath-health GitHub organization that grants install access.

Setup

Create an .npmrc file in your project root with your GitHub token:

# .npmrc
@onepathhealth:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

Then install:

npm install @onepathhealth/connect

Quick Start

import { OnepathClient } from "@onepathhealth/connect";

const onepath = new OnepathClient({
  apiKey: process.env.ONEPATH_API_KEY,
  // baseUrl defaults to https://api.onepath.health
  // use https://api-sandbox.onepath.health for testing
});

// Onboard a user
const user = await onepath.users.onboard({
  externalId: "your-internal-user-id",
  consentScopeId: "full-health",
  consentToken: await generateConsentToken(userId),
});

// Submit health data
await onepath.users.updateHealthData(user.userId, {
  observations: [
    {
      code: "8867-4",
      system: "http://loinc.org",
      display: "Heart rate",
      valueQuantity: { value: 72, unit: "beats/min" },
      effectiveDateTime: new Date().toISOString(),
    },
  ],
});

// Get AI insights
const insights = await onepath.insights.get(user.userId);
console.log(insights.summary);

Client Options

const onepath = new OnepathClient({
  apiKey: "onepath_production_...",     // defaults to process.env.ONEPATH_API_KEY
  baseUrl: "https://api.onepath.health", // override for sandbox
  timeout: 30_000,                // request timeout in ms (default: 30s)
});

All Resources

onepath.users

// Register a user — idempotent on externalId
const user = await onepath.users.onboard({
  externalId: "user-123",
  consentScopeId: "full-health",
  consentToken: "...",
});

// Submit FHIR health data
await onepath.users.updateHealthData(userId, {
  observations: [...],
  conditions: [...],
  medications: [...],
});

// Retrieve all health data on file
const data = await onepath.users.getHealthData(userId);

onepath.insights

const insights = await onepath.insights.get(userId);
// { summary, insights: [...], healthScore, generatedAt }

onepath.lab

const result = await onepath.lab.analyze(userId, {
  documentBase64: pdfBuffer.toString("base64"),
  fhirResourceId: "optional-doc-id",
});
// { findings: [{ testName, value, status, loincCode }], summary }

onepath.coaching

// Start a session
const response = await onepath.coaching.chat(userId, {
  message: "What does my latest lab work say about my cholesterol?",
  includeHealthContext: true,
});

// Continue the session
const follow = await onepath.coaching.chat(userId, {
  sessionId: response.sessionId,
  message: "What can I do to improve it?",
});

onepath.goals

const goals = await onepath.goals.list(userId);

const goal = await onepath.goals.create(userId, {
  title: "Reduce resting heart rate to under 70 bpm",
  category: "cardiovascular",
  targetDate: "2027-01-01",
});

await onepath.goals.update(userId, goal.goalId, { progress: 40 });

onepath.healthScore

const score = await onepath.healthScore.get(userId);
// { overallScore: 78, domains: { cardiovascular: 82, metabolic: 74, ... } }

onepath.medications

Medication order/refill lifecycle — see the medication refill lifecycle guide for the full end-to-end flow.

const order = await onepath.medications.createOrder(
  userId,
  {
    externalOrderReference: "wellvi_order_9182",
    medicationName: "Semaglutide",
    medicationCategory: "peptide",
    expectedSupplyDurationDays: 28,
    startDate: "2026-08-18",
    tebraPracticeConfigId: "5f2c1e3a-...",
  },
  "wellvi_order_9182" // idempotency key
);

const due = await onepath.medications.getRefillsDue({ withinDays: 5 });

await onepath.medications.submitProgressCheckin(userId, order.medicationRequestId, {
  answers: [{ code: "wellvi-side-effects", value: "None reported" }],
});

// Refilled: call createOrder() again with renewsOrderReference set.
// Not refilled: close the loop instead —
await onepath.medications.discontinueOrder(userId, order.medicationRequestId, {
  reason: "patient-discontinued",
});

Error Handling

import {
  OnepathAuthError,
  OnepathRateLimitError,
  OnepathValidationError,
  OnepathNotFoundError,
} from "@onepathhealth/connect";

try {
  const user = await onepath.users.onboard({ ... });
} catch (err) {
  if (err instanceof OnepathAuthError) {
    // 401 — API key invalid or expired
  }
  if (err instanceof OnepathValidationError) {
    console.error(err.details); // field-level errors: { externalId: ["required"] }
  }
  if (err instanceof OnepathRateLimitError) {
    await sleep(err.retryAfter * 1000);
    // then retry
  }
  if (err instanceof OnepathNotFoundError) {
    // user doesn't exist
  }
}

Idempotent Requests

The onboarding endpoint is idempotent by design — calling it twice with the same externalId returns the existing user. For other write operations, pass an idempotency key:

const key = `onboard-${userId}-${Date.now()}`;
const user = await onepath.users.onboard(params, key);

TypeScript

The SDK ships .d.ts declaration files and is fully typed. All request and response shapes are exported:

import type {
  OnboardUserParams,
  GetInsightsResponse,
  HealthInsight,
  FhirObservation,
} from "@onepathhealth/connect";

SDKs

Official client libraries for OnePath Connect.

Python SDK

Official Python client for OnePath Connect.

On this page

SetupQuick StartClient OptionsAll Resourcesonepath.usersonepath.insightsonepath.labonepath.coachingonepath.goalsonepath.healthScoreonepath.medicationsError HandlingIdempotent RequestsTypeScript