There are additional fees involved with TEFCA IAS in
live mode. Please contact support@fastenhealth.com or your Account Representative for more information.Overview
Bring Your Own Identity (BYOI) lets your application authenticate the patient at Authenticator Assurance Level 2 (AAL2) and perform identity proofing with your own supported Credential Service Provider (CSP). In the standard TEFCA IAS flow, Fasten sends the patient to a CSP such as CLEAR or ID.me and receives the verified ID Token directly. In BYOI mode, your application owns that CSP experience. Your backend sends a stablepatient_id to Fasten’s Identity service and receives a short-lived request_uri that can be passed into Fasten Stitch so
the patient can complete consent and provider selection.
Fasten uses the patient_id as the subject of a short-lived, Fasten-signed client assertion JWT and sends that JWT to your
registered Token Exchange endpoint. Your backend validates the assertion, uses the patient’s active CSP authorization
grant to obtain a fresh CSP ID Token, and returns the ID Token to Fasten. Fasten can repeat this exchange when another CSP
ID Token is required during a long-running or later data collection request.
BYOI is intended for organizations that have completed TEFCA subparticipant onboarding and have a CSP configured to issue
ID Tokens with the organization’s HCID in the
aud claim. If you do not have that setup yet, use the standard
TEFCA IAS flow.How It Works
- Your application authenticates the patient (AAL2) - The patient logs into their account within your product.
- Your application starts identity proofing - Your product verifies their identity with your CSP.
- Your backend stores the CSP authorization grant - Keep the patient’s CSP ID Token and refresh token on your backend.
- Your backend creates a Pushed Authorization Request - Call Fasten’s Identity service with your stable
patient_id. - Fasten calls your preregistered Token Exchange endpoint - Fasten sends a signed client assertion whose
subis thepatient_id. - Your endpoint validates the assertion and exchanges the active CSP grant for a fresh CSP ID Token.
- Fasten validates the CSP ID Token - The signature, issuer, expiration, audience, CSP, and environment must be valid.
- Fasten returns a
request_uri- The value is single-use, short-lived, and tied to your Fasten client. - Your frontend launches Stitch - You pass the
request_uriinto the Fasten SDK. - Fasten collects patient consent - The patient reviews your application and authorizes access.
- The patient selects providers - Fasten searches the TEFCA network and guides the patient through selecting the healthcare organizations they want to share.
- Fasten repeats the Token Exchange when necessary - Fasten may require a newly minted CSP ID Token to retrieve records from the TEFCA Network.
iss and sub values. Within your organization, each patient_id must always identify the same patient and
must not be reassigned.
Supported CSPs
Theidp value in your Token Exchange response identifies the CSP that issued the returned ID Token.
The CSP must issue an unexpired OpenID Connect ID Token that Fasten can verify. The token audience must include your organization’s pre-configured HCID.
Prerequisites
Before you build the BYOI flow, make sure you have:- Registered as a TEFCA subparticipant under Fasten with our QHIN.
- Authenticated the patient at AAL2 before submitting a Pushed Authorization Request.
- An authorized CSP that can complete IAL2 identity proofing.
- A CSP integration that can issue ID Tokens with
audset to your organization’s HCID. - Provided your organization’s HCID to Fasten.
- Provided your HTTPS Token Exchange endpoint to Fasten.
- TEFCA IAS enabled for the Fasten API mode you are using.
- Generated a
public_*ID and matchingprivate_*key from the Fasten Developer Portal.
private_* key and CSP credentials on your backend only.
Stable Patient Identifier
Thepatient_id is your stable, opaque identifier for the patient. Fasten places it in the sub claim of every client
assertion sent to your Token Exchange endpoint, allowing your backend to locate the correct CSP authorization grant.
The value must:
- Be stable and unique within your organization.
- Resolve to exactly one patient and one active CSP authorization grant.
- Never be reassigned to another patient.
- Be safe to use as an opaque identifier; do not put an email address, name, or other patient data in it.
patient_id and the patient’s Fasten identity. A PAR
request fails if a patient_id is already associated with a different patient or if that patient is already associated
with a different patient_id for your organization.
Developer Flow
1. Authenticate And Proof The Patient
Authenticate the patient at AAL2 and complete your CSP identity-proofing flow. Store the CSP authorization grant (ID Token and refresh token) securely on your backend, indexed by the stablepatient_id you send to Fasten. Your Token Exchange
endpoint uses this grant to obtain a new CSP ID Token whenever Fasten requests one.
You are responsible for managing the lifetime of the CSP ID Token and refresh token. If the underlying grant expires or
is revoked, the patient must authenticate again at AAL2 and complete any CSP authorization required to establish a new grant.
2. Create A Pushed Authorization Request
CallPOST https://identity.fastenhealth.com/oauth2/par from your backend. Send an
application/x-www-form-urlencoded request using HTTP Basic authentication with your Fasten public ID and private key.
Parameters
After validating the PAR request, Fasten immediately calls your registered Token Exchange endpoint. PAR fails if the
exchange cannot be completed or the returned CSP ID Token does not pass validation.
Response
A successful request returns201 Created.
request_uri is single-use and expires after 90 seconds.
3. Implement The Customer Token Exchange Endpoint
Your registered Token Exchange endpoint must:- Use HTTPS.
- Accept
POSTrequests withapplication/x-www-form-urlencodedbodies. - Validate the Fasten-signed client assertion before accessing CSP credentials.
- Use the assertion’s
subclaim to locate the expected patient and their active CSP grant. - Return a newly issued CSP ID Token.
Validate Fasten’s Client Assertion
Thesubject_token carries a short-lived client assertion JWT signed by Fasten. Validate:
Cache each accepted
jti until its assertion expires to prevent replay. Retrieve Fasten signing keys from
https://identity.fastenhealth.com/jwks.json and support normal key rotation. If an unknown kid is received, refresh
the JWKS once before rejecting the request.
An example decoded payload:
The
task_id is context for logging and tracing purposes. It is optional, do not reference it for authorization;
validate the assertion signature, issuer, audience, lifetime, and replay status on every request.Successful Response
Return200 OK and Content-Type: application/json
idp must identify the CSP that issued the ID Token. Supported values are clear_csp, idme_csp, and
persona_csp.
Error Responses
Return OAuth-compatible JSON errors withCache-Control: no-store.
4. Pass The request_uri To Fasten Stitch
Initialize Fasten Stitch with the request_uri returned by the PAR response.
request_uri immediately after your backend creates it. If the patient takes too long or refreshes the page, create a new PAR request and relaunch Stitch with the new value.
5. Handle Completion Events
Listen for the same Fasten Stitch events you use in other consent flows. Store the resultingorg_connection_id and related metadata so your backend can request exports and support the patient later.
- Use
widget.completeto update your frontend after Stitch finishes. - Use
patient.connection_successas the durable backend signal. - Store the resulting
org_connection_id. - Use
POST /bridge/fhir/ehi-exportwhen you are ready to retrieve records.
On-Demand Refresh
Fasten calls the same registered Token Exchange endpoint whenever it requires a fresh CSP ID Token. Each request contains a newly generated Fasten-signed client assertion with the originalpatient_id in sub. For an EHI Export or another
background task, the assertion may also contain a task_id.
Your endpoint must return an ID Token for the same CSP identity established by the initial exchange. Fasten rejects a
refreshed token if its CSP iss or sub differs from the initial token, even if the token is otherwise valid.
Your EHI Export request only needs the Fasten API credentials and connection_id; you are not required to send a CSP ID Token in the
/ehi-export request. Fasten retrieves a fresh token from your Token Exchange endpoint when needed. If the endpoint cannot
return a valid token, collection fails and the patient must reauthenticate with your CSP.
Token Exchange endpoint implementations must be safe when Fasten retries a request or makes concurrent requests:
- Do not assume a request is delivered exactly once.
- Coordinate access to rotating CSP refresh tokens.
- Persist a replacement CSP refresh token before invalidating the previous stored value.
- Return the same successful result when safely possible, or perform another valid CSP exchange.
- Do not revoke the patient grant merely because a request timed out or was retried.
Retry-After with 429 Too Many Requests or
503 Service Unavailable when Fasten should delay the next attempt.
Security And Operations
- Keep your Fasten private key on your backend.
- Keep the
patient_idstable and never associate it with a different person. - Return CSP ID Tokens only from your backend Token Exchange endpoint.
- Treat the CSP ID Token as sensitive patient identity data.
- Fasten receives the verified ID Token, not the patient’s ID photos or CSP proofing session materials.
Implementation Checklist
- Complete TEFCA subparticipant and BYOI onboarding.
- Register the Token Exchange endpoint, organization HCID, and supported CSP with Fasten.
- Authenticate patients to AAL2.
- Issue stable, opaque, never-reassigned
patient_idvalues. - Store each patient’s active CSP authorization grant securely on your backend.
- Implement Fasten client assertion validation and
jtireplay protection using Fasten’s JWKS. - Return the CSP ID Token and
idpin the Token Exchange response. - Verify retry and concurrent-refresh behavior with rotating CSP refresh tokens.
- Re-verify the patient when the CSP grant expires or is revoked.
- Keep all Fasten and CSP credentials on backend systems.
Standards
- OAuth 2.0 Token Exchange (RFC 8693)
- JWT Profile for OAuth 2.0 Client Authentication (RFC 7523)
- OpenID Connect Core 1.0
- NIST Digital Identity Guidelines: Authentication and Authenticator Management

