Retrieve Medicare claims data via CMS Blue Button 2.0 using authorization code OAuth flow

domain: bluebutton.cms.gov · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Register your application at the CMS Blue Button 2.0 developer portal to obtain a client_id and client_secret (YOUR_KEY); specify your redirect URI and select the required scopes (patient/Patient.read, patient/Coverage.read, patient/ExplanationOfBenefit.read, profile, offline_access)
  2. Redirect the beneficiary to the CMS Blue Button authorization URL with response_type=code, client_id, redirect_uri, scope, and a unique state parameter; the beneficiary authenticates with their Medicare.gov credentials and grants consent
  3. Exchange the returned authorization code for access and refresh tokens by POSTing to the CMS token endpoint with grant_type=authorization_code, code, redirect_uri, and your client credentials; store the refresh token securely for long-term access
  4. Call the ExplanationOfBenefit endpoint with the bearer access token (YOUR_TOKEN) to retrieve the beneficiary's Medicare Part A, B, and D claims as FHIR R4 ExplanationOfBenefit resources returned in a paginated Bundle
  5. Follow next-page links in the Bundle to retrieve all claims pages; each ExplanationOfBenefit resource contains claim dates, provider information, service codes (HCPCS, ICD-10), and payment amounts
  6. Use the refresh token to obtain new access tokens before they expire; Blue Button 2.0 access tokens are short-lived and the refresh token must be used to maintain access without requiring the beneficiary to re-authenticate

Known gotchas

Related routes

pull Medicare claims data via the CMS Blue Button 2.0 API
cms-blue-button · 6 steps · unrated
Access CMS Blue Button 2.0 API to retrieve Medicare claims data for a beneficiary
fhir · 6 steps · unrated
Retrieve a Medicare beneficiary's Part A, B, and D claims history using the CMS Blue Button 2.0 FHIR API
bluebutton.cms.gov · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans