STARCO Studio from the API.
Goal: do by code what STARCO Studio does with clicks: pick a kit, create a study with its synthetic cohort, look at the cohort and one descriptive statistic, and export the study with its fingerprint.
STARCO_STUDIO_API (the same variable the notebooks generated by Studio read). Until then, the Academy and the playground run the twin side.STEP 1 Sign in with your developer account Beta#
Studio uses the console token of STARCO Dev (POST /v1/sessions, see the quickstart): the studies belong to your account, and each study is a project of yours.
export API="https://api.starco.dev/v1"
export STUDIO="$STARCO_STUDIO_API"
export STARCO_CONSOLE=$(curl -s -X POST "$API/sessions" -H "Content-Type: application/json" \
-d "{\"email\": \"dev@example.test\", \"password\": \"$STARCO_PASSWORD\"}" | jq -r .token)import hashlib, os, requests
API = "https://api.starco.dev/v1"
STUDIO = os.environ["STARCO_STUDIO_API"]
console = requests.post(f"{API}/sessions", json={
"email": "dev@example.test", "password": os.environ["STARCO_PASSWORD"]}).json()["token"]
C = {"Authorization": f"Bearer {console}"}STEP 2 The kits Beta#
A kit is a study template: measures with their units and the bounds a value must fit to be recorded (never a reference range), states and phases, and alerts. Each kit comes with its schema already normalised, ready to send back as is or edited. The STARCO bio reference describes the three kits measure by measure.
curl -s "$STUDIO/kits" -H "Authorization: Bearer $STARCO_CONSOLE" | jq '.kits[] | {key, measures: [.schema.measures[].key]}'kits = requests.get(f"{STUDIO}/kits", headers=C).json()
for k in kits["kits"]:
print(k["key"], [m["key"] for m in k["schema"]["measures"]])
print(kits["import"])seguimiento-entre-visitas ['study.qol_score', 'study.energy', 'wellness.mood_level', 'wellness.sleep_hours', 'wellness.steps']
sueno-y-actividad ['wellness.sleep_hours', 'biomarkers.resting_heart_rate', 'biomarkers.hrv_rmssd', 'wellness.steps', 'wellness.exercise_minutes']
cohorte-laboratorio ['lab.marker_1', 'lab.marker_2', 'biomarkers.weight', 'biomarkers.waist_circumference', 'biomarkers.height']
{'formats': ['csv'], 'xlsx': False, 'max_kb': 2048, 'max_rows': 5000}The kits' names and labels are in Spanish in the API; the Studio screens show them in Catalan and English too.
STEP 3 Create a study Beta#
Send the kit, a name and the measures (here, the kit's own). Studio creates, all or nothing, a project of yours with its synthetic cohort, schema version 1, the initial states and the kit's automations switched off.
MEASURES=$(curl -s "$STUDIO/kits" -H "Authorization: Bearer $STARCO_CONSOLE" | jq '.kits[] | select(.key == "sueno-y-actividad") | .schema.measures')
STUDY=$(curl -s -X POST "$STUDIO/studies" -H "Authorization: Bearer $STARCO_CONSOLE" -H "Content-Type: application/json" \
-d "{\"kit\": \"sueno-y-actividad\", \"name\": \"Sleep 01\", \"measures\": $MEASURES, \"planned_participants\": 40, \"duration_months\": 6}")
STUDY_ID=$(echo "$STUDY" | jq -r .study.id); PROJECT=$(echo "$STUDY" | jq -r .study.project_id)kit = next(k for k in kits["kits"] if k["key"] == "sueno-y-actividad")
study = requests.post(f"{STUDIO}/studies", headers=C, json={
"kit": kit["key"], "name": "Sleep 01", "measures": kit["schema"]["measures"],
"planned_participants": 40, "duration_months": 6}).json()["study"]
print(study["id"], study["project_id"], study["schema_version"], study["data_class"])d8362ec3-2469-4ff9-93ce-0d5a330994cb 8668960e-48fe-4518-9253-fb204fe51b15 1 syntheticA wrong measure is refused with a stable code and the field, and nothing is created: for example 422 bounds_invalid with "field": "measures.0.min" when the minimum is not below the maximum.
STEP 4 The cohort at a glance Beta#
curl -s "$STUDIO/studies/$STUDY_ID/overview" -H "Authorization: Bearer $STARCO_CONSOLE" | jq '{participants, window, measures}'ov = requests.get(f"{STUDIO}/studies/{study['id']}/overview", headers=C).json()
print(ov["participants"], ov["window"])
for m in ov["measures"]:
print(m["key"], m["days_with_data_pct"])8 {'from': '2026-11-06', 'to': '2026-11-19', 'days': 14}
wellness.sleep_hours 85.7
biomarkers.resting_heart_rate 100
biomarkers.hrv_rmssd 100
wellness.steps 83
wellness.exercise_minutes 83.9The share of participant-days with data: a day without data is counted as missing, never filled in. With nobody to count it is null.
STEP 5 Describe a measure Beta#
Exploratory, descriptive statistics: n and missing data always, the participant as the unit (the mean of each participant's days) and also by participant-day. No reference ranges and no interpretation. The STARCO bio reference writes out each method with a worked example.
curl -s "$STUDIO/studies/$STUDY_ID/analysis/describe?measure=wellness.sleep_hours" -H "Authorization: Bearer $STARCO_CONSOLE" | jq '{participants, note, by_participant}'d = requests.get(f"{STUDIO}/studies/{study['id']}/analysis/describe", headers=C,
params={"measure": "wellness.sleep_hours"}).json()
print(d["note"])
print({k: d["by_participant"][k] for k in ("n", "missing", "mean", "sd", "median", "iqr")})Exploratory, descriptive statistics on synthetic sandbox data: not clinical conclusions about any person. n and missing data are always shown; null means no data.
{'n': 8, 'missing': 0, 'mean': 7.398492, 'sd': 0.451854, 'median': 7.566621, 'iqr': 0.556818}A statistic that needs more data than there is (a standard deviation with one participant) is null. By phase, comparisons between groups, correlations and simulations have their own routes next to this one: analysis/phases, analysis/compare, analysis/correlation and scenarios.
STEP 6 Export the study with a project key Beta#
The export is read with a key of the study's project (scope read), as the R and Python notebooks do: one JSON document, its SHA-256 in X-Content-SHA256 and the same fingerprint in the project's audit chain.
KEY=$(curl -s -X POST "$API/projects/$PROJECT/keys" -H "Authorization: Bearer $STARCO_CONSOLE" -H "Content-Type: application/json" \
-d '{"name": "notebook", "scopes": ["read"], "ttl_days": 7}' | jq -r .secret)
curl -s -D headers.txt -o study.json "$STUDIO/export" -H "Authorization: Bearer $KEY"
grep -i x-content-sha256 headers.txt; sha256sum study.jsonkey = requests.post(f"{API}/projects/{study['project_id']}/keys", headers=C,
json={"name": "notebook", "scopes": ["read"], "ttl_days": 7}).json()["secret"]
r = requests.get(f"{STUDIO}/export", headers={"Authorization": f"Bearer {key}"})
print(r.json()["format"], hashlib.sha256(r.content).hexdigest() == r.headers["X-Content-SHA256"])starco-studio-export/v1 TrueWhat just happened
A kit became a study: a project of yours with a synthetic cohort and a versioned schema. You looked at it the way Studio's panel does and described one measure without labelling anyone. The export left with a fingerprint that the audit chain also holds. Everything you did is a row of the project's chain (studio.* actions next to the API's).