Authentication
Your key
Every request carries your partner key in X-Api-Key.
X-Api-Key: pk_live_4f9c…
The key is issued by the Health Nexus team and shown once. Store it in a secret manager; never put it in a mobile app, a web page or a repository. If it leaks, ask for it to be rotated: the old key stops working at once.
Calls are server to server. A request that carries an Origin header, as browsers send, is refused with 403. A key can also be restricted to a list of IP addresses.
Naming the person
Requests about one person name that person in headers.
| Header | Required | Value |
|---|---|---|
X-Api-Key | always | Your key. |
X-Subject-Email | on every endpoint outside sign-in and sign-up | The person's email, lowercase. |
X-Subject-Account-Id | recommended | user.accountId from the sign-in reply. |
X-Request-Id | optional | Your own trace id. It is kept in our audit log and helps when you report a problem. |
The sign-in and sign-up endpoints take only your key: there the email travels in the body.
X-Subject-Account-Id is a check, not a key. When you send it, the person must be known at that account, otherwise the API answers 404. When one email holds two records, the header tells them apart; without it the API answers 400 with code: "ambiguous_subject".
Whom your key can reach
Your key reaches the people who signed in or signed up through your integration and accepted the terms. Knowing someone's email is never enough.
| Reply | Meaning | What to do |
|---|---|---|
403 code: "user_not_linked" | The person has an account but has not signed in through you. | Send them through sign-in. |
403 code: "terms_required" | Signed in, but the terms are not accepted yet. | Record the acceptance. |
404 | No such person. | Start with check-email. |
Scopes
A key has the read scope, or read and write.
read: everyGET.write: signing people in and up, accepting terms, uploading, and everyPOST,PUT,PATCHandDELETE.
A read-only key that tries to write gets 403 with "Partner credential is read-only.".
No sessions
The API never hands you a session token and there is nothing to refresh. A finished sign-in creates the link between the person and your key; after that, the same headers work on every call until the key is rotated or revoked.