Skip to content

Health records for agents

Flexpa helps patients access and share health records from insurers, medical record systems, and nationwide exchanges. Developers use Flexpa to build agents for clinical trials, benefits navigation, and healthcare services. One 3-in-1 network covering CMS-9115, ONC (g)(10) and TEFCA IAS, with patient consent, IAL2 identity proofing, SMART Health Links and a FHIR® API.

Integrate in three requests

Flexpa uses OAuth 2.0 with PKCE. Every step works in test mode with the test keys from the Developer Portal, so you can build end to end before going live.

  1. Send the patient to Consent. Redirect to https://api.flexpa.com/oauth/authorize with client_id (your publishable key), redirect_uri, response_type=code, scope=launch/patient, code_challenge, code_challenge_method=S256 and flexpa_external_id (your user ID for this patient; requests without it are rejected). The patient connects their health plan or provider and consents, then returns to your redirect_uri with a code.
  2. Exchange the code for a token. POST https://api.flexpa.com/oauth/token with grant_type=authorization_code, code, code_verifier, redirect_uri and client_id. The body can be JSON or form-encoded. The response has an access_token valid for 24 hours and a refresh_token.
  3. Read the record. GET https://api.flexpa.com/fhir/Patient/$PATIENT_ID/$everything?_count=100 with Authorization: Bearer <access_token>. $PATIENT_ID is sent literally: with a patient access token it stands for the patient behind the token. Follow each page's next link until it is absent. A 429 means the first sync is still running, so retry.
# 2. Exchange the authorization code
curl -X POST https://api.flexpa.com/oauth/token \
  -H "Content-Type: application/json" \
  -d '{"grant_type":"authorization_code","code":"<code>","code_verifier":"<code_verifier>","redirect_uri":"https://your-app.com/callback","client_id":"<publishable_key>"}'

# 3. Read the patient's record, one page at a time
curl 'https://api.flexpa.com/fhir/Patient/$PATIENT_ID/$everything?_count=100' \
  -H "Authorization: Bearer <access_token>"

The quickstart runs these steps in a working Next.js app. The OAuth reference covers every authorization and token parameter, the FHIR API reference covers search and paging, and the Node SDK wraps all three steps.

Coverage, access and pricing

  • Data returned. Claims, coverage and pharmacy data from health plans, and clinical records from medical record systems and TEFCA: lab and imaging results, clinical notes, conditions, medications, allergies, immunizations, procedures and visits, as FHIR R4. See the data sheet.
  • Health plans. 350+ plans through CMS-9115 Patient Access APIs, covering Medicare Advantage, Medicaid, CHIP and Marketplace plans where the plan offers the API. Covered plans must expose the data they maintain with a date of service on or after January 1, 2016, so history can go back to that date or to the start of the patient's enrollment with that plan, whichever is more recent. How much a plan still holds varies. Per-plan status is in the Endpoint Directory.
  • Original Medicare. Claims through CMS's Blue Button 2.0 API, with the same Consent flow.
  • Employer and commercial plans without a Patient Access API connect through proprietary network connections, an add-on included from the Omni plan and $10,000 a year below it.
  • Medical record systems. 45,000+ providers on ONC (g)(10) EHR APIs. Each facility is one sign-in, and where an Epic organization supports MyChart Central, one Epic ID sign-in can share every linked Epic organization in the same step.
  • TEFCA. Flexpa is a live Individual Access Services provider on TEFCA through the Kno2 and CommonWell QHINs. One IAL2 identity verification (CLEAR, ID.me or Persona) searches participating facilities nationwide instead of one portal at a time. The patient verifies their own identity; there is no guardian or proxy path on TEFCA. Ask partnerships@flexpa.com to enable TEFCA for your application. TEFCA documents that arrive as C-CDA can be turned into structured FHIR with the C-CDA to FHIR conversion add-on. See the network guide.
  • When records are empty or late. API requests return 429 while the first sync runs, usually under a minute. New records reach the source on different timelines: health plan claims within about 24 hours of adjudication (which itself typically takes about 5 to 30 days), EHR records in about 24 hours, and TEFCA records in about 24 to 72 hours. See the network guide. What each plan or EHR returns varies, so check the Endpoint Directory and handle empty results per resource type.
  • Going live. Build in test mode first. Live keys come after a signed MSA and a review of your privacy policy and terms of service. The steps and timelines are in road to production.
  • Pricing. Published at flexpa.com/pricing: free for patients, platform plans from $20,000 a year, never metered per API call. A plan's tier is set by eligible users, everyone on your platform who can access Flexpa. Overage is billed per unique end user, someone you actually verify or retrieve data for, counted once per contract year.
For agents

Built to be read by machines

Every page is published as markdown at its own URL, the whole corpus sits in one file, and live patient records are reachable over MCP. Point an agent at any of these rather than at the rendered page.