# Flexpa Documentation > Flexpa gives apps and AI agents patient-consented health records through one FHIR R4 API. It connects to three patient access networks: medical record systems, health insurers, and national exchanges. Patients authorize access in Flexpa Consent. Apps query the Flexpa FHIR API, and agents use the records MCP server at https://api.flexpa.com/mcp/consent with the same patient access token. ## Core Concepts Flexpa operates through three main components: - **Network**: The largest directory of payer FHIR endpoints in the US, covering health insurers (claims, coverage and plan-held clinical data through CMS-9115 Patient Access APIs), and medical record systems (clinical records through ONC (g)(10) APIs); health plan and provider endpoints are listed in the Endpoint Directory. Network also reaches nationwide exchanges through TEFCA Individual Access Services, with IAL2 identity verification. - **Consent (Flexpa Consent)**: The patient-facing authorization flow: source sign-in or identity verification, review of connected sources, and a final sharing step. Apps launch it with OAuth 2.0 PKCE. - **Records (Flexpa API)**: A FHIR R4 API for claims, coverage and clinical resources, plus a records MCP server for agents. The typical integration flow: Patient authorizes in Flexpa Consent → Exchange the authorization code for a patient access token → Query the FHIR API, or connect an agent to the records MCP server with that token. The authorize request needs client_id, redirect_uri, response_type=code, scope, code_challenge with code_challenge_method=S256, and flexpa_external_id (your user ID for the patient); requests without flexpa_external_id are rejected. Try it in the [interactive demo](https://www.flexpa.com/demo), then build against sample data in [Test Mode](https://www.flexpa.com/docs/test-mode). For patients, Flexpa is in Claude's connector directory: https://claude.ai/directory/flexpa. The full text of the docs is in one file at https://www.flexpa.com/docs/llms-full.txt. Most pages are also available as markdown by adding `.md` to their URL, for example https://www.flexpa.com/docs/faq.md; the docs home is https://www.flexpa.com/docs/index.md. ## Coverage and pricing - Health insurers: claims, coverage and plan-held clinical data from 350+ health plans through CMS-9115 Patient Access APIs (Medicare Advantage, Medicaid, CHIP and Marketplace plans, where the plan offers the API). Per-plan status is in the [Endpoint Directory](https://www.flexpa.com/docs/network/directory). - Original Medicare: claims through CMS's Blue Button API ([Flexpa among the first Blue Button 3.0 apps](https://www.flexpa.com/blog/flexpa-blue-button-v3-first-wave)). - Employer-sponsored and off-exchange commercial plans with no Patient Access API (CMS-9115-F does not require one): claims through [proprietary network connections](https://www.flexpa.com/spotlights/proprietary-network-connections), direct patient portal integrations behind the same Consent flow and FHIR API. Optional add-on, included from Omni and $10,000 a year below it, needed only for claims Consent routes to a portal integration instead of a Patient Access API, including employer coverage at insurers that offer an API for other lines of business; claims through a Patient Access API never need it. Clinical records from EHRs and TEFCA come with every plan, for patients on any insurance. Employer coverage per plan is in the Endpoint Directory (fully funded and self funded lines of business) and `directory.check_lob_support`. - Clinical records, not only claims: 45,000+ providers on ONC (g)(10) EHR APIs, and [TEFCA Individual Access Services](https://www.flexpa.com/tefca-individual-access-services-api), where Flexpa has matched patients at 88,000+ facilities after one IAL2 identity verification (CLEAR, ID.me or Persona). C-CDA documents from TEFCA can be turned into structured FHIR with [C-CDA to FHIR conversion](https://www.flexpa.com/spotlights/ccda-to-fhir). - Pricing is published at [flexpa.com/pricing](https://www.flexpa.com/pricing) ([markdown](https://www.flexpa.com/pricing.md)): free for patients; annual platform plans from $20,000 a year (Startup, up to 5,000 eligible users), never metered per API call. A tier is set by eligible users (everyone on your platform who can access Flexpa); overage is billed per unique end user (someone you verify or retrieve data for), counted once per contract year. - Claims history: covered plans must expose the data they maintain with a date of service on or after January 1, 2016, so a connection can reach 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. - TEFCA access is live through the Kno2 and CommonWell QHINs and is enabled per application: ask partnerships@flexpa.com. The patient verifies their own identity; there is no guardian or proxy path on TEFCA. Health plan and EHR portals each take their own sign-in; someone with proxy access in a supported portal (a parent for a child, or a caregiver an adult has granted access) can connect it with their own login. - Going live: build in [test mode](https://www.flexpa.com/docs/test-mode), then live keys follow a signed MSA and a review of your privacy policy and terms of service ([road to production](https://www.flexpa.com/docs/guides/getting-started)). - Empty or late records: the API returns 429 while the first sync runs (usually under a minute); new records reach the source within about 24 hours of claims adjudication (adjudication typically takes about 5 to 30 days), in about 24 hours for EHRs and about 24 to 72 hours for TEFCA; before building for a specific plan or provider, open it in the [Endpoint Directory](https://www.flexpa.com/docs/network/directory): each endpoint's page shows token refresh and maximum authorization period, and, for health plans, the patient sign-in success and completion rates and the lines of business it serves. ## Docs - [Quickstart](https://www.flexpa.com/docs/guides/quickstart): Complete guide to integrating Flexpa with a working example application - [Road to production](https://www.flexpa.com/docs/guides/getting-started): How to go from introduction to live mode: demo intake, sandbox access, MSA, and kickoff - [FHIR API Reference](https://www.flexpa.com/docs/records): Complete API documentation including authentication, endpoints, and response formats - [Consent Reference](https://www.flexpa.com/docs/consent): Launching Flexpa Consent (OAuth 2.0 PKCE) from web and mobile apps - [FHIR Introduction](https://www.flexpa.com/docs/fhir/introduction): Introduction to FHIR resources and healthcare data standards - [Test Mode](https://www.flexpa.com/docs/test-mode): Guide to testing integrations with sample data before going live ## Guides - [Claims Data Guide](https://www.flexpa.com/docs/guides/claims): Understanding healthcare claims data and how to work with it - [Financial Data Guide](https://www.flexpa.com/docs/guides/financial): Interpreting cost information, insurance processing, and healthcare payments - [Usage Patterns](https://www.flexpa.com/docs/guides/usage): Common implementation patterns and best practices for Flexpa Consent - [Parsing FHIR Data](https://www.flexpa.com/docs/guides/parsing-fhir): Best practices for parsing and extracting data from FHIR resources - [Patient Linking](https://www.flexpa.com/docs/guides/patient-linking): Connecting patient records across sources - [Medplum Integration](https://www.flexpa.com/docs/guides/medplum): Integrating Flexpa with Medplum FHIR server - [AWS HealthLake](https://www.flexpa.com/docs/guides/healthlake): Integrating Flexpa with AWS HealthLake ## Agents - [Health Records for Agents](https://www.flexpa.com/docs/guides/agents): Building AI agents with Flexpa including MCP server integration - [Health Tools for Agents](https://www.flexpa.com/docs/guides/mcp-registry): Public registry of health MCP servers and their tools ## Network & Data - [Network Reference](https://www.flexpa.com/docs/network): Flexpa's three networks: medical record systems, health insurers, and national exchanges - [CMS Aligned Networks](https://www.flexpa.com/docs/network/cms): SMART Health Cards and Links and other CMS Aligned Network capabilities - [Endpoint Directory](https://www.flexpa.com/docs/network/directory): Directory of supported health plan and provider endpoints - [Endpoint Directory for Agents](https://www.flexpa.com/docs/network/directory-tools): Search and validate payer and provider endpoints from an AI agent through the public MCP registry - [Data Sheet](https://www.flexpa.com/docs/records/data-sheet): Comprehensive overview of available FHIR resources and data elements - [Claims to Clinical](https://www.flexpa.com/docs/records/claims-to-clinical): Transform claims data into clinical FHIR resources - [Webhooks](https://www.flexpa.com/docs/records/webhooks): Real-time notifications when patient data is available ## FHIR Resources - [Explanation of Benefit](https://www.flexpa.com/docs/fhir/explanation-of-benefit): Detailed EOB resource documentation including claims and payment information - [Coverage](https://www.flexpa.com/docs/fhir/coverage): Insurance coverage and plan details - [Patient](https://www.flexpa.com/docs/fhir/patient): Patient demographics and identifiers - [Condition](https://www.flexpa.com/docs/fhir/condition): Diagnoses and health conditions - [Medication](https://www.flexpa.com/docs/fhir/medication): Medication information from pharmacy claims - [MedicationRequest](https://www.flexpa.com/docs/fhir/medication-request): Prescribed medications - [Procedure](https://www.flexpa.com/docs/fhir/procedure): Medical procedures performed - [Observation](https://www.flexpa.com/docs/fhir/observation): Lab results and vital signs - [Encounter](https://www.flexpa.com/docs/fhir/encounter): Healthcare visits and admissions - [Practitioner](https://www.flexpa.com/docs/fhir/practitioner): Healthcare provider information - [Organization](https://www.flexpa.com/docs/fhir/organization): Healthcare organizations and facilities ## Optional - [FAQ](https://www.flexpa.com/docs/faq): Common questions about Flexpa integration and capabilities - [What We Don't Do](https://www.flexpa.com/docs/what-we-dont-do): Important limitations and scope of Flexpa's services - [Node SDK](https://www.flexpa.com/docs/records/node-sdk): TypeScript/JavaScript SDK for simplified API integration - [SMART Health Links](https://www.flexpa.com/docs/smart-health-links): Shareable health data links specification - [SMART Health Check-in](https://www.flexpa.com/docs/smart-health-checkins): Flexpa's test wallet for the SMART Health Check-in pre-visit protocol, and how to point a check-in page at it - [Terminology Guide](https://www.flexpa.com/docs/fhir/code-systems): Healthcare terminology and code systems reference ## Code Examples ### Start OAuth Flow ```typescript import FlexpaClient from '@flexpa/node-sdk'; // Client-side (browser) example (async () => { const codeVerifier = await FlexpaClient.generateCodeVerifier(); const codeChallenge = await FlexpaClient.generateCodeChallenge(codeVerifier); const authUrl = FlexpaClient.buildAuthorizationUrl({ publishableKey: 'pk_test_...', redirectUri: 'https://yourapp.com/callback', codeChallenge, externalId: 'user-123', }); window.location.href = authUrl; })(); ``` ### Exchange Code for Token ```typescript // Server-side example (e.g., in your callback handler) const client = await FlexpaClient.fromAuthorizationCode( code, codeVerifier, redirectUri, publishableKey ); const accessToken = client.getAccessToken(); ``` ### Fetch Patient Data ```typescript const client = FlexpaClient.fromBearerToken(accessToken); const everything = await client.$everything(); const claims = await client.search('ExplanationOfBenefit'); ``` ### Extract Data with ViewDefinition ```typescript const response = await fetch('https://api.flexpa.com/fhir/ViewDefinition/$run', { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ resourceType: 'Parameters', parameter: [{ name: 'viewResource', resource: viewDefinition }] }) }); ```