Initiate and poll a FHIR bulk data export ($export) to retrieve patient data as NDJSON files

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

Steps

  1. Initiate a system-level export: GET [base]/$export with headers Accept: application/fhir+json and Prefer: respond-async; optionally add _type=[ResourceType1,ResourceType2] to limit exported resource types.
  2. The server responds with HTTP 202 Accepted and a Content-Location header containing a polling URL for the export job status.
  3. Poll the Content-Location URL; while the job is running the server returns 202 with an optional X-Progress header; when complete it returns 200 with a JSON body containing output[] array.
  4. Each output[] element has type (FHIR resource type) and url (URL to download an NDJSON file); each line in the NDJSON file is a complete FHIR resource JSON object.
  5. Download each NDJSON file with the same bearer token; process line by line rather than loading entire files into memory, as files may contain millions of records.
  6. Check the error[] array in the completed export manifest for any resource types that failed to export; handle partial export failures gracefully.

Known gotchas

Related routes

run a FHIR bulk data export using $export and retrieve ndjson output asynchronously
fhir · 6 steps · unrated
Kick off a FHIR Bulk Data patient-level $export, poll for completion, and download NDJSON output
hl7.org · 6 steps · unrated
Initiate a FHIR Bulk Data $export with Prefer: respond-async header and poll for completion
healthcare-fhir · 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