Sign-in & Sign-up
Bring your users onto Health Nexus with the steps our own site and app use: check the email, then sign in, sign up or reset the password. These calls carry only your key (the write scope): the person's email travels in the body, and no X-Subject-* header is needed. A finished sign-in returns no session token: it links the person to your credential, and from then on you call every other folder with X-Subject-Email. Run the requests top to bottom; each saves verificationToken / identityToken for the next one.
Check an email
Step 1 of every sign-in and sign-up. Tells you where this email stands, in `outcome`: `login` (the person has an account and a password: go to `POST sign-in`), `setup` (a clinic created the record and no password is set yet: finish it through the sign-up steps, sending `action` back), or `register` (new to us: go through the sign-up steps). For `setup` and `register` the first verification code has already been emailed and the reply carries the `verificationToken` for `POST sign-up/verify-email`. A new person gets a Health Nexus account.
Sign in
Signs the person in with their email and password. Three possible replies with HTTP 200: a finished sign-in (`signedIn: true`, with `user`, `terms` and `link`); a verification step (`requiresVerification: true` with a `verificationToken`: the person must enter the code sent by email and/or text, see the two verify requests); or `accountSelectionRequired: true` with an `identityToken` (sandbox only: one more step, `POST select-location`). A wrong password answers 401 with `code: wrong_password`. No session token is ever returned: after a finished sign-in you call the data endpoints with your key and `X-Subject-Email`.
Verify the email code (sign-in)
Checks the code emailed during a sign-in. When that code was the last thing missing, the sign-in is finished in this call (`signedIn: true`); otherwise the reply carries the next `verificationToken` and says which code is still pending in `verification`.
Verify the phone code (sign-in)
Checks the code sent by text message during a sign-in. Finishes the sign-in (`signedIn: true`) when nothing else is pending.
Resend the sign-in code
Sends the pending sign-in code again. One resend per verification token per cooldown window (429 with `retryAfterSec` otherwise).
Start a sign-up
Starts a sign-up for an email and emails the first verification code. Equivalent to `POST check-email` for a new person; use either. An email that already has an account and a password answers 409 `already_registered`: sign in instead.
Verify the email code (sign-up)
Checks the emailed code. The reply carries the next `verificationToken`.
Add a phone number
Adds the person's mobile number and texts a code to it. `countryCode` is the dial code without the plus sign (see `GET country-codes`).
Verify the phone code (sign-up)
Checks the texted code. After this the person can complete the sign-up.
Resend the sign-up codes
Sends the pending sign-up codes again.
Complete the sign-up
Completes the sign-up with the person's details and the password they chose. `action` is the value the check-email or start reply gave you (`register_new_patient` or `register_existing_patient`). Two possible replies with HTTP 200: a finished sign-up (`signedIn: true`), or `accountSelectionRequired: true` with an `identityToken`: sandbox only, one more step: `POST select-location`. Password rule: at least 8 characters with upper case, lower case, a number and a special character. Birth date: a real `YYYY-MM-DD` day, age 16 to 100.
List locations
Sandbox: the list of locations for `POST select-location`. Any of them can be chosen. Production needs no location step.
Choose a location
Sandbox step. Finishes a sign-up or sign-in whose reply said `accountSelectionRequired`, by choosing a location: any one from the list. In production a new sign-up lands in Health Nexus without this step. `facilityId` comes from `GET locations`. Answers a finished session (`signedIn: true`).
List country dial codes
Countries and their dial codes, for the phone step.
Start a password reset
Starts a password reset and emails a code. Also the way a person with a clinic-created record chooses their first password when check-email says `firstTime: true`. An unknown email answers 404 `ACCOUNT_NOT_FOUND`; a record with no password yet answers 409 `PASSWORD_NOT_SET` with the token to finish setup through the sign-up steps.
Verify the email code (reset)
Checks the emailed code. `verification.phoneSent: false` in the reply means no text could be sent: ask for a number with `POST password-reset/phone`.
Add a phone number (reset)
Adds or changes the mobile number during a reset and texts its code.
Verify the phone code (reset)
Checks the texted code. The next step sets the password.
Resend the reset code
Sends the pending reset code again.
Set the new password
Saves the new password. With `email`, the person is signed in at once (`signedIn: true`); otherwise, or if the sign-in could not be finished, the reply says `passwordSet: true, signedIn: false` and you call `POST sign-in`.