Upvio SDK
@upvio/sdk-node is the official server-side SDK for the Upvio API. It provides typed methods for managing patients, vitals scans, and magic link authentication.
Requirements
Section titled “Requirements”- Node.js 22 or later
- ESM project (
"type": "module"inpackage.json)
Installation
Section titled “Installation”pnpm add @upvio/sdk-nodenpm install @upvio/sdk-nodeyarn add @upvio/sdk-nodeCreate a client
Section titled “Create a client”Create a client instance with your API key and Business ID:
import { UpvioApiClient } from '@upvio/sdk-node'
const client = new UpvioApiClient({ apiKey: process.env.UPVIO_API_KEY, businessId: process.env.UPVIO_BUSINESS_ID,})Configure credentials
Section titled “Configure credentials”Store your credentials in .env.local (and add it to .gitignore):
UPVIO_API_KEY=your-api-keyUPVIO_BUSINESS_ID=your-business-idUPVIO_BUSINESS_ALIAS=your-business-aliasUPVIO_API_KEYandUPVIO_BUSINESS_ID— found on the API Keys page in the Vitals dashboard.UPVIO_BUSINESS_ALIAS— your workspace slug, used to build scan URLs:https://scan.upvio.com/{alias}/links/{slug}.
Send API requests
Section titled “Send API requests”All methods are accessed through the client.v1 namespace and return typed promises.
List vitals templates
Section titled “List vitals templates”const { data: templates } = await client.v1.vitals.templates.list()
for (const template of templates) { console.log(template.name, template.metrics)}List vitals links
Section titled “List vitals links”const { data: links } = await client.v1.vitals.links.list({ status: 'ACTIVE' })Create a patient
Section titled “Create a patient”const { data: patient } = await client.v1.core.patients.create({ name: 'Jane Smith', email: 'jane@example.com', })By default, if a patient with the same email exists, their record is updated (upsert). Pass mode: 'create' to get a 409 error instead.
Create a scan
Section titled “Create a scan”const { data: scan } = await client.v1.vitals.scans.create({ vitalsLinkId: link.id, patientId: patient.id, })You can pre-fill patient health data for more accurate risk assessments:
const { data: scan } = await client.v1.vitals.scans.create({ vitalsLinkId: link.id, patientId: patient.id, inputData: { gender: 'female', age: 35, height: 165, weight: 62, smokingStatus: 'never', activityLevel: 'exercise20to60Mins', }, })Generate a magic link
Section titled “Generate a magic link”Magic links authenticate a patient and redirect them to a scan page:
const alias = process.env.UPVIO_BUSINESS_ALIASconst scanUrl = `https://scan.upvio.com/${alias}/links/${link.slug}`
const { data: magicLink } = await client.v1.core.patients.createMagicLink( patient.id, { redirectUrl: scanUrl }, )
// Send magicLink.url to the patientconsole.log(magicLink.url)Retrieve scan results
Section titled “Retrieve scan results”const { data: scan } = await client.v1.vitals.scans.retrieve(scanId)
if (scan.status === 'SUCCEEDED' && scan.results) { console.log(scan.results.metrics) // { heartRate: 72, bloodPressureSystolic: 120, ... }}Error handling
Section titled “Error handling”The SDK throws UpvioApiRequestError for non-2xx responses:
import { UpvioApiClient, UpvioApiRequestError,} from '@upvio/sdk-node'
try { await client.v1.vitals.scans.retrieve('invalid-id')} catch (error) { if (error instanceof UpvioApiRequestError) { console.error(error.status) // 404 console.error(error.statusText) // "Not Found" }}See Error Handling for common error scenarios.