Overview
The MediSync API uses JWT (JSON Web Token) authentication to secure all protected endpoints. The same token authenticates the Dashboard (REST) API and the Speech (WebSocket) API. This guide covers registration, login, and how to use and manage tokens.Authentication flow
1
Register
Create a MediSync account with your professional credentials.
2
Log in
Authenticate with email and password to receive a JWT token.
3
Use the token
Send the JWT as a Bearer token in the
Authorization header on every protected request.Tokens can be renewed without re-entering credentials — call
POST /api/refresh-token with a still-valid token. See Token management.Registration
Register a new healthcare-professional account:201 Created):
Fields
Fields
- firstName (required)
- lastName (required)
- email (required, must be unique)
- password (required, minimum 6 characters)
- specialty (required)
- ehr_system_type (required) — EHR system category
- ehr_system_name (required) — specific EHR system name
- title (optional) — medical title (Dr., Prof.)
Password requirements
Password requirements
Minimum 6 characters. Use a long, unique password — these accounts hold patient data, and a password manager is strongly recommended.
Login
Authenticate with your credentials to obtain a JWT token:200 OK):
Login parameters
Two-factor authentication
If an account has 2FA enabled andtwoFactorCode is omitted, login returns 202 Accepted with a challenge — resubmit with the twoFactorCode included.
Login errors
Platform messages are returned in German, and authentication failures use afailed label alongside error.
Using JWT tokens
Include your token in theAuthorization header for all protected endpoints:
Example request
Token structure
Treat the token as opaque. Do not decode it, parse it, or depend on its internal structure — the claims it carries are an internal detail and change without notice. The server extracts your user id from the token, so no separate
uid parameter is ever required.Everything you need about a token is available through the API: the authenticated user from GET /api/user/profile, and expiry by handling 401 and refreshing.Authorization
User identification
User identification is handled entirely through the JWT. The server extracts the user id from the token to authenticate the request and scope data access — you never pass a user id explicitly.Data access control
- Doctors can access only their own resources (their appointments, recordings, transcriptions, notes, and documents). Accessing another user’s resource returns
403 Forbidden. - Admin roles have elevated, system-level access (special permissions).
Subscription requirements
Some actions require an active subscription or trial — notably creating appointments and AI note generation. If your trial or subscription has lapsed,POST /api/appointments/add returns 403 with a German message. Check your subscription status in the dashboard.
Error handling
Error responses are JSON, but the shape depends on the layer that produced them:- Auth middleware (missing/invalid/revoked token) uses a
messagefield. - Route handlers (validation, not-found, ownership) use an
errorfield.
The API does not return the invented, English error
code values shown in some older examples (e.g. AUTH_REQUIRED). Branch on the HTTP status code and the presence of message / error / code fields shown above.Token management
Expiration
Tokens expire. A standard token is scoped to the working day;remember: true issues a longer-lived one.
Exact lifetimes are an internal detail and change — do not hard-code an expiry or compute one from the token. Treat a 401 as the signal to refresh or re-authenticate.
Refreshing a token
POST /api/refresh-token slides the current device’s session forward and returns a new token. It requires a still-valid token, so refresh before expiry rather than after — it extends a live session and cannot revive an expired one.
If a token has already expired, there is nothing to refresh: call
POST /api/login again.Signing out
POST /api/logout ends the current device’s session. Other devices stay signed in, and the token used for the call stops working on its next request.
Managing devices
An account can be signed in on several devices at once, up to a fixed cap. Signing in beyond it evicts the least-recently-active device.GET /api/sessions returns one entry per device with an id, a human-readable device_label, platform, last_seen_at, created_at, and current (whether it is the calling device). Devices are addressed by that id; the underlying session identifiers are never exposed.
DELETE /api/sessions to cut everything except the one you’re on. Revocation takes effect on the device’s next request.
Handling expired or revoked tokens
When you receive a401:
- If the token is merely expired and you still hold a valid one, call
POST /api/refresh-token. Otherwise re-authenticate withPOST /api/login. - Retry the original request with the new token.
401 carrying code: "SESSION_REVOKED" means that specific device’s session ended — through logout, an explicit revocation, or eviction past the device cap. Treat it as a sign-out and send the user back to login rather than retrying.
Security best practices
A MediSync token grants full access to a doctor’s patient data for its whole lifetime. Handle it accordingly.Token storage
- Browser: keep the token in memory, or in a
Secure,HttpOnly,SameSitecookie set by your own backend. AvoidlocalStorageandsessionStorage— any XSS on your page can read them. - Mobile: use the platform keystore (iOS Keychain, Android Keystore), not plain preferences files.
- Server-side: keep it in process memory or a secrets manager; never in source control or a build artifact.
- Call
POST /api/logouton sign-out and discard the token.
Network security
- Always use HTTPS / WSS, and validate TLS certificates.
- Keep tokens out of your own logs, analytics, and error reports.
- Refresh proactively rather than letting tokens sit long-lived in client storage.
- Use
GET /api/sessionsto surface active devices to the user, and revoke anything unexpected.
Rate limiting
Rate limits apply across the MediSync API. Limited responses return429 with standard RateLimit-* headers and Retry-After.
Treat any 429 as retryable: back off for the interval the response indicates rather than retrying immediately, and build clients so a limit is handled gracefully wherever it appears.
Next steps
API Reference
Explore the Dashboard API endpoints.
Login endpoint
Full reference for the login endpoint.
Reporting a vulnerability
How to report a security issue to MediSync.