If your app uses its own sign-in (provider custom), StickyHealth cannot check your tokens itself. Instead, your server hosts a validation endpoint: we send it the token, and it tells us who the user is. This page is the contract that endpoint must follow.
Overview
- You build the endpoint and send us its URL. We register it for your organization.
- The app never sends the URL. In the SDK, the custom provider's
confighas no URL field:auth={{ token, provider: 'custom', config: {} }}. - On every sign-in from your app, StickyHealth calls the endpoint with the member's token, plus an authorization request when the app sent one (see Authorization requests).
Endpoint requirements
- Protocol: HTTPS
- Method:
POST, JSON body - Timeout: respond within 10 seconds, or the sign-in fails
Request
Token validation
{{code.b0}}Token validation with an authorization request
{{code.b1}}The entries contain only external_uid values. StickyHealth sets the permissions and the one-hour expiry itself. Your endpoint decides only whether the signed-in user may access each listed member.
Response
Basic response
{{code.b2}}Response to an authorization request
When the request contains authorization_request, your response must contain authorization_request too, listing the entries you approve:
{{code.b3}}Response requirements
- Return HTTP
200with a JSON body for a valid token. subis required: the user's id in your system. It becomes the member'sexternal_uid, which webhooks and authorization requests use to refer to them.- If the request contained
authorization_request, always echoauthorization_requestback with only the entries you approve. Leave out any entry the user may not access. Return"entries": []to approve none. - Other fields are allowed.
email,nameandpicture, if present, fill in the member's profile.
Validating authorization requests
When the request contains an authorization request:
- Check permissions: make sure the authenticated user may access each requested member.
- Check the ids: make sure each
external_uidis a real user in your system. - Log it: record every authorization request for audit.
Never trust the requested list on its own: it comes from the app. Only your endpoint can confirm that the user may access those members.
Errors
For an invalid token or a failed check, return an error status. Any status outside 2xx fails the sign-in. We suggest:
400: invalid request format401: invalid or expired token403: the user may not grant the requested access500: internal error
{{code.b4}}Examples
A valid token:
{{code.b5}}A valid token with an approved authorization request:
{{code.b6}}Implementation example (Python, Flask)
is_valid_token, extract_user_from_token and can_access_member stand in for your own logic.
{{code.b7}}Security requirements
- Serve the endpoint over HTTPS only.
- Rate-limit it.
- Validate the request body.
- Approve only members the authenticated user is allowed to manage.
- Log every authorization request for audit.