Quickstart
Your first request in 5 minutes
This page gets you from zero to a working import in five steps. You only need curl (or any HTTP client) and a setup code from the portal.
Step 1 — Generate a setup code in the portal
Open your portal, go to Settings → Devices, and generate a new setup code. You’ll see something like MK-A3F7-92BC. The code is single-use and expires after 24 hours.
Step 2 — Redeem the code
Exchange the code for an API key, host URL, and encryption key:
curl -s -X POST https://myopia.kids/api/v1/setup/redeem \
-H "Content-Type: application/json" \
-d '{
"code": "MK-A3F7-92BC",
"hostname": "my-integration-server"
}'
Response:
{
"success": true,
"data": {
"apiKey": "mk_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2",
"host": "https://myopia.kids",
"encryptionKey": "base64encodedkey=="
}
}
Store apiKey and host — every subsequent request uses them. The encryptionKey is only needed for the optional DB-passphrase backup (POST /setup/db-key).
Step 3 — Verify connectivity
Check that your key is valid and the service is reachable:
curl -s https://myopia.kids/api/v1/health \
-H "Authorization: Bearer mk_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2"
Response:
{ "status": "ok" }
A 401 here means the key is wrong or was revoked. A 200 means you’re ready to import.
Step 4 — Send your first measurement
Use mode first_visit for a patient the server hasn’t seen before. The devicePseudonym is a stable, client-computed HMAC identifier — never a real name or date of birth.
curl -s -X POST https://myopia.kids/api/v1/import \
-H "Authorization: Bearer mk_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2" \
-H "Content-Type: application/json" \
-d '{
"mode": "first_visit",
"devicePseudonym": "a3f792bc1e4d5f6a7b8c9d0e1f2a3b4c",
"hints": {
"initialsHint": "AB",
"dobMonthYearHint": "1985-03"
},
"measurements": [
{
"eye": "R",
"measuredAt": "2026-07-15T09:00:00.000Z",
"sphere": -2.5,
"cylinder": -0.75,
"axis": 180
}
]
}'
Response (patient lands in pending queue):
{
"success": true,
"data": {
"assigned": 0,
"unmatched": 1,
"skip_pseudonyms": []
}
}
unmatched: 1 means the server received the measurement but doesn’t know which patient record it belongs to yet. A practice staff member links the pseudonym to a real patient in the portal — after that, subsequent imports use mode: token with the returned persistentToken for direct attribution.
Step 5 — What’s next
- → Details on the protocol model: Overview & Concepts
- → Full onboarding flow + DB-key backup: Onboarding & Authentication
- → All four import modes, batch rules, dedup: Importing Measurements
- → Mapping sync + rejection lists: Matching & Sync
- → Interactive API reference (try it live): API Reference