Authentication
Email codes, Apple and Google, tokens and API keys.
Email code
curl -X POST https://api.avycenna.com/api/v1/auth/otp/send \
-H "Content-Type: application/json" \
-d '{"email": "you@clinic.com"}'
curl -X POST https://api.avycenna.com/api/v1/auth/otp/verify \
-H "Content-Type: application/json" \
-d '{"email": "you@clinic.com", "otp": "123456"}'Codes expire after 10 minutes. Verifying returns an access_token, a refresh_token and the user.
Apple and Google
- Web:
GET /auth/oauth/googleor/auth/oauth/appleredirects to the provider. Afterwards the browser returns to the web app with tokens in the URL fragment, which is never sent to a server. - Native: the iOS app posts Apple's identity token to
POST /auth/oauth/apple/native; the Android app posts Google's ID token toPOST /auth/oauth/google/native. GET /auth/providerssays which providers this server has configured.
Tokens
| Token | Lifetime | Use |
|---|---|---|
| Access token | 15 minutes | Authorization: Bearer <token> |
| Refresh token | 30 days | POST /auth/refresh returns a new pair; the old refresh token stops working |
POST /auth/logout revokes a refresh token.
API keys
For server-to-server integrations, create a workspace key under Integrations and send it as:
X-API-Key: sk_live_…Workspace keys have the read_granted scope: they read data patients have shared with the workspace and can't change anything. Account administration (workspaces, billing, members) needs a signed-in session.