Skip to Content
StoneDock Connect
StoneDock Connect
StoneDock Connect Documentation
SDKsTypeScript / JavaScript SDKPython SDK
SDKs

Python SDK

Official Python client for StoneDock Connect.

The onepath-connect package (currently v1.6.0) is the official Python SDK, hand-written (not auto-generated) with full type annotations.

Access: The SDK is distributed through a private PyPI index. After your BAA is executed, you'll receive credentials to configure your package manager.

The Python SDK trails the JavaScript SDK on resource coverage — see Resource parity with the JS SDK below before assuming a method exists.

Setup

Add the StoneDock index to your pip config or pyproject.toml:

# pip
pip install onepath-connect \
  --index-url https://pypi.onepath.health/simple \
  --extra-index-url https://pypi.org/simple
# pyproject.toml (poetry)
[[tool.poetry.source]]
name = "onepath"
url = "https://pypi.onepath.health/simple"
priority = "supplemental"

Quick Start

import os
from onepath import OnepathClient

client = OnepathClient(api_key=os.environ["ONEPATH_API_KEY"])

# Onboard a user
user = client.users.onboard(
    external_id="your-internal-user-id",
    consent_scope_id="full-health",
    consent_token=generate_consent_token(user_id),
)

# Submit health data
client.users.update_health_data(user.user_id, observations=[
    {
        "code": "8867-4",
        "system": "http://loinc.org",
        "display": "Heart rate",
        "value_quantity": {"value": 72, "unit": "beats/min"},
        "effective_date_time": datetime.utcnow().isoformat(),
    }
])

# Get AI insights
insights = client.insights.get(user.user_id)
print(insights.summary)

Client Options

from onepath import OnepathClient

client = OnepathClient(
    api_key="onepath_production_...",       # defaults to ONEPATH_API_KEY env var
    base_url="https://api.onepath.health",  # override for sandbox
    timeout=30,                             # seconds (default: 30)
)

All Resources

Most user-scoped methods accept a consent_jwt keyword argument to override the client's default for a single call — pass it explicitly whenever one client instance serves more than one user_id.

client.users

# Register a user — idempotent on external_id
user = client.users.onboard(
    external_id="user-123",
    consent_scope_id="full-health",
)

# Submit FHIR health data
client.users.update_health_data(user_id, observations=[...], conditions=[...])

# Retrieve all health data
data = client.users.get_health_data(user_id)

client.insights

insights = client.insights.get(user_id)
# insights.summary, insights.insights[], insights.health_score

client.lab

import base64

with open("lab_report.pdf", "rb") as f:
    pdf_b64 = base64.b64encode(f.read()).decode()

result = client.lab.analyze(user_id, document_base64=pdf_b64)
for finding in result.findings:
    print(f"{finding.test_name}: {finding.value} — {finding.status}")

client.coaching

# Start a session
response = client.coaching.chat(
    user_id,
    message="What does my latest lab work say about my cholesterol?",
    include_health_context=True,
)

# Continue the session
follow = client.coaching.chat(
    user_id,
    session_id=response.session_id,
    message="What can I do to improve it?",
)

client.goals

goals = client.goals.list(user_id)

goal = client.goals.create(
    user_id,
    title="Reduce resting heart rate to under 70 bpm",
    category="cardiovascular",
    target_date="2027-01-01",
)

client.goals.update(user_id, goal.goal_id, progress=40)

client.health_score

score = client.health_score.get(user_id)
# score.overall_score, score.domains.cardiovascular, score.trend

client.practitioners

Provisions a FHIR Practitioner identity for one of your clinicians so writes elsewhere (messaging, care team, visit notes, appointments) can attribute a specific action to a specific person.

practitioner = client.practitioners.register(
    "dr-smith-01",
    "Dr. Jane Smith",
    role="clinician",
    npi="1234567890",
)
practitioners = client.practitioners.list()
one = client.practitioners.get("dr-smith-01")

client.care_team

A patient's roster of assigned providers (treating / covering / supervising). Requires care_team.read/care_team.write and a registered practitioner.

client.care_team.add_member(user_id, "dr-smith-01", "treating")
client.care_team.update_status(user_id, "dr-smith-01", "paused")
client.care_team.end_membership(user_id, "dr-smith-01")  # soft-end, history kept

team = client.care_team.list(user_id, include_ended=True)
patients = client.care_team.list_patients("dr-smith-01")

client.messaging

Store-and-forward compliance record of patient↔provider messages — not a live chat backend. Requires messaging.read/messaging.write and a registered practitioner.

client.messaging.send(
    user_id,
    external_message_reference="your-ref-1",
    direction="patient-to-provider",
    practitioner_id="dr-smith-01",
    content="Question about my last lab result",
    sent_at=datetime.utcnow().isoformat(),
)

all_messages = client.messaging.list(user_id)
with_one = client.messaging.list(user_id, practitioner_id="dr-smith-01")  # scoped to one provider's thread

client.visit_notes

Freeform, provider-authored visit notes. Requires visit_notes.read/visit_notes.write.

note = client.visit_notes.create(
    user_id,
    external_note_reference="your-ref-1",
    practitioner_id="dr-smith-01",
    title="Follow-up visit",
    reason_for_visit="Routine check-in",
)

client.visit_notes.update(user_id, note.note_id, note.version, assessment="Stable")
client.visit_notes.sign(user_id, note.note_id, note.version)  # final + immutable from here
client.visit_notes.add_addendum(user_id, note.note_id, "dr-smith-01", "Correction: BP was 120/80, not 128/84")

notes = client.visit_notes.list(user_id)
detail = client.visit_notes.get(user_id, note.note_id)  # includes addenda

client.appointments

Mirrors your own scheduling system (or telehealth tool) into StoneDock's FHIR store. Requires appointments.read/appointments.write and a registered practitioner.

appt = client.appointments.create(
    user_id,
    external_appointment_reference="your-ref-1",
    practitioner_id="dr-smith-01",
    scheduled_start="2026-12-01T15:00:00Z",
    duration_minutes=30,
    reason="Follow-up",
)

appointments = client.appointments.list(user_id)
one = client.appointments.get(user_id, appt.fhir_appointment_id)
client.appointments.update_status(user_id, appt.fhir_appointment_id, "arrived")
client.appointments.add_note(user_id, appt.fhir_appointment_id, "dr-smith-01", "Patient arrived on time")

client.conditions

Requires conditions.read/conditions.write.

condition = client.conditions.create(
    user_id,
    external_condition_reference="your-ref-1",
    name="Hypertension",
    diagnosed_date="2026-01-15",
)
conditions = client.conditions.list(user_id)
one = client.conditions.get(user_id, condition.condition_id)
client.conditions.update(user_id, condition.condition_id, clinical_status="resolved")
client.conditions.delete(user_id, condition.condition_id)  # soft delete

client.questionnaires

Questionnaire responses not tied to a medication order. Requires questionnaires.read/questionnaires.write.

client.questionnaires.submit_response(
    user_id,
    questionnaire_code="phq-9",
    answers=[{"code": "phq9-1", "display": "Little interest or pleasure", "value": "1"}],
)
responses = client.questionnaires.list_responses(user_id, questionnaire_code="phq-9")

client.medications

Medication order/refill lifecycle — full parity with the JS SDK, since this resource is server-to-server only. See the medication refill lifecycle guide for the full end-to-end flow.

order = client.medications.create_order(
    user_id,
    external_order_reference="wellvi_order_9182",
    medication_name="Semaglutide",
    medication_category="peptide",
    expected_supply_duration_days=28,
    start_date="2026-08-18",
    ehr_practice_config_id="5f2c1e3a-...",  # optional — omit for no EHR sync
    idempotency_key="wellvi_order_9182",
)

orders = client.medications.list_orders(user_id)
due = client.medications.get_refills_due(within_days=5)

client.medications.submit_progress_checkin(
    user_id,
    order.medication_request_id,
    answers=[{"code": "wellvi-side-effects", "value": "None reported"}],
)
checkins = client.medications.list_progress_checkins(user_id, order.medication_request_id)

# Refilled: call create_order() again with renews_order_reference set.
# Not refilled: close the loop instead —
client.medications.discontinue_order(
    user_id, order.medication_request_id, reason="patient-discontinued"
)

Resource parity with the JS SDK

The Python SDK does not yet have: health_summary, chat, documents, demographics, fitness_plans, product_advisor, or usage. If you need any of these today, call the raw API directly with requests (or use the JavaScript SDK from a Node service) — see the API Reference for exact paths. prescriptions exists on the client (Wellvi pharmacy-submission integration, server-to-server only) but is intentionally undocumented here — it's bespoke for one partner integration.

Two newer backend endpoints — allergies and authored notes — aren't wrapped by either SDK yet; call them directly over HTTP. client.questionnaires and client.appointments are also only partially wrapped on both SDKs — amending a questionnaire response, adding a comment to one, and rescheduling or editing appointment details all require a direct HTTP call; see the API Reference for exact paths.

Error Handling

from onepath.errors import (
    OnepathAuthError,
    OnepathForbiddenError,
    OnepathValidationError,
    OnepathRateLimitError,
    OnepathNotFoundError,
    OnepathServerError,
)
import time

try:
    user = client.users.onboard(external_id="user-123", consent_scope_id="full-health")
except OnepathAuthError:
    # 401 — API key or consent token invalid/expired
    pass
except OnepathForbiddenError:
    # 403 — valid credentials, but this scope isn't granted
    pass
except OnepathValidationError as e:
    print(e.details)  # {"external_id": ["required"]}
except OnepathRateLimitError as e:
    time.sleep(e.retry_after)
    # then retry
except OnepathNotFoundError:
    pass
except OnepathServerError:
    # 5xx — safe to retry with exponential backoff
    pass

Type Annotations

The SDK ships a py.typed marker and full type stubs:

from onepath.types import (
    OnboardUserResponse,
    GetInsightsResponse,
    HealthInsight,
    FhirObservation,
    ConditionResponse,
    VisitNoteSummaryResponse,
)

TypeScript / JavaScript SDK

Official TypeScript and JavaScript client for StoneDock Connect.

Error Reference

Every error code from the StoneDock Connect API, explained.

On this page

SetupQuick StartClient OptionsAll Resourcesclient.usersclient.insightsclient.labclient.coachingclient.goalsclient.health_scoreclient.practitionersclient.care_teamclient.messagingclient.visit_notesclient.appointmentsclient.conditionsclient.questionnairesclient.medicationsResource parity with the JS SDKError HandlingType Annotations