How HAPI FHIR Bulk Data $export works and when teams need it
Teams need Bulk Data $export when they must move large FHIR datasets into analytics, research or another system without paging through the REST API one search result at a time. The HAPI FHIR JPA server implements the FHIR Bulk Data $export operation at system, Patient and Group level. Each request runs as an asynchronous Batch2 job inside the server, so the export continues in the background while the client waits for it to finish. Choose the level deliberately: system export covers the whole repository, Patient export covers patient-linked data, and Group export limits output to members of a defined group. A narrower scope reduces file volume and the access you must grant downstream, so decide the scope with the data consumer before the first run.
The flow has three steps. The client kicks off the job with a GET request that includes the Prefer: respond-async header. The server responds with a Content-Location URL that identifies the job. The client polls that URL until the job completes, then reads a manifest that lists the output files. Plan the polling interval, timeout and retry behavior in the consuming system, and confirm them against the HAPI FHIR bulk export documentation for the version you run. Each output file is stored as a Binary resource and contains one resource type, so a single export produces several files per type. Downstream loaders must handle that split, and they must also be able to fetch files by their Binary URLs.
Setting up a bulk export on the JPA server
This sequence takes a HAPI FHIR JPA server from a bulk export being switched on to a set of verified NDJSON files in hand. Each step ends with a check so the team knows whether the export is complete and correct before the data is used downstream.
Enable the bulk export operation on the starter
The platform engineer confirms that the bulk export module is enabled in the JPA server starter configuration and that the server is running the expected HAPI FHIR version. Because the export runs as an asynchronous Batch2 job, the job framework must be working before any request is sent. Restart the server after configuration changes, then read the server's CapabilityStatement to confirm the $export operation is advertised at system, Patient and Group level. The step is done when the capability check shows the operations and the server logs show no startup errors related to batch jobs. Confirm the exact configuration keys against the version you deploy, since they change between releases.
Send the kick-off request with respond-async
The client sends a GET request to the $export endpoint for the scope needed, such as the whole system, all Patients or one Group, with the Prefer header set to respond-async. The server accepts the request and starts a Batch2 job instead of returning data inline. Record the request time, the scope and the requester identity, because these details are needed later for audit and for matching the job to its output. The step is done when the server replies with an accepted status and a Content-Location header pointing to a job status URL. If the request is rejected, check the authorization settings and the requested resource types before retrying.
Poll the Content-Location URL until the job completes
The client polls the Content-Location URL at a reasonable interval until the status response changes from in-progress to complete. Polling is read-only, so it can be done by the same integration that started the job or by a separate monitoring process. Keep the interval modest and handle error responses explicitly, since a failed job reports an error rather than a manifest. Watch the server logs and the batch job status during a long run to confirm work is progressing. The step is done when the poll returns a complete status with a manifest. If the status reports an error or never completes, collect the job identifier and server logs before starting another export.
Read the manifest and check the file list
The client parses the manifest returned by the completed job, which lists the output files with their resource types and download URLs. Compare the resource types in the manifest against the list the export was expected to produce, such as Patient, Observation or Encounter for the scope requested. Note that large resource types can produce several files, so the count per type may be higher than one. Record the transactionTime and the file count in your export log. The step is done when every expected resource type appears in the manifest, or when any gap is explained and documented. Missing types should be investigated in the server logs before the data is treated as complete.
Download the NDJSON Binary files
The client downloads each file listed in the manifest. Each output file is stored on the server as a Binary resource and contains one resource type in NDJSON format, with one FHIR resource per line. Download over an encrypted connection with the same credentials or an authorized token, because the files contain patient data. Save each file under its resource type and export identifier so it can be traced back to the job. The step is done when every file has downloaded without a transport error and the local file sizes are non-zero. If the Binary security context is in use, a download without the required permission will be refused, so confirm the access rules before troubleshooting the transfer.
Validate the NDJSON content
The data team checks that each file is valid NDJSON and that every line parses as a single FHIR resource of the resource type named in the file. Count the lines and compare them with the totals the team expects from the source system or from a sample search, bearing in mind that the export reflects the data at the transaction time. Check a small sample of records for expected identifiers and fields. The step is done when every file parses cleanly and the record counts match the expected totals within the tolerance the team has agreed. Mismatches usually point to a scope error, a partition or access restriction, or a file that was truncated during download.
Record the export for audit and reuse
The operator records the job identifier, requester, scope, transaction time, manifest, file checksums and validation results in the export log. This record lets the team show what was exported, when and by whom, and supports repeat runs. Store the exported files in a location that matches the data classification and access controls agreed for the project. The step is done when the log entry is complete and the files are stored under the agreed access controls. Confirm with your privacy and security teams how long exported copies may be kept and who may read them, since the export itself does not set those rules.
Export levels, output formats and file size settings compared
This table compares the three export levels, the default NDJSON output against a custom format, and the default 100 MB file split. Read each row as a decision: the first column names the setting, and the other columns show what it changes for the team that exports the data and the loader that receives it. The main takeaway is that scope and format choices are cheap to make early but expensive to change once downstream loaders depend on them.
| Setting | What it changes | Trade-off for downstream loaders | When to choose it |
|---|---|---|---|
| System level export | Exports all resource types the server holds, subject to the request parameters | Largest output and the widest data exposure; loaders must handle many resource types | Full migrations or warehouse loads that need every resource type |
| Patient level export | Exports resources linked to the patients in scope | Smaller, patient-centred extracts; compartment rules decide which resources are included | Cohort extracts, patient data access requests or research pulls |
| Group level export | Exports resources for members of a defined Group | Scope depends on Group membership at export time, so membership must be current | Recurring cohort or program reporting where the population is managed as a Group |
| Default NDJSON output | Each file holds one resource type in newline-delimited JSON, stored as a Binary resource | Widely readable by common loaders; no conversion step on the server | Most integrations and any loader that already reads NDJSON |
| Custom format via STORAGE_BULK_EXPORT_RESOURCE_CONVERT | Registers a converter on the pointcut so the server writes another format | You must build, test and maintain the converter and confirm the loader accepts its output | A downstream system needs a format NDJSON cannot serve and the team owns the converter |
| Default split at 100 MB | Each file is split so no file exceeds 100 MB by default | Smaller files parallelize and retry better; more files mean more downloads and manifest entries | Most loaders that read files in parallel or stream them |
| Smaller file size | Produces more, lighter files per resource type | Easier to retry and resume; more HTTP requests and more objects to track | Loaders with tight memory limits or flaky networks |
| Larger file size | Produces fewer, heavier files | Fewer downloads, but each failed transfer or parse costs more to repeat | Loaders that favor few large inputs and run on stable networks |
Securing exported files with Binary.securityContext
Exported NDJSON files are bulk copies of patient data, so they need the same protection as the source records. Binary.securityContext ties each file to an access rule, while authorization, audit, retention and transport protection cover the rest of the path. HAPI FHIR provides these as separate building blocks that your team must assemble and test together.
Populate Binary.securityContext during export
Export jobs can set Binary.securityContext on each generated file so the BinarySecurityContextInterceptor can decide who downloads it. The rule you choose here determines whether a file is shared with the requesting user, a group or nobody beyond the export job. Confirm in a test environment that the context reaches every output file, including files split past the default 100 MB limit, before relying on it.
Binary security docsAuthorize the export endpoint
Restricting who can start a $export job matters as much as restricting downloads, because a permitted job creates the files in the first place. Use the AuthorizationInterceptor or your identity provider's token checks to limit which systems can export at system, Patient and Group level. Ask who approves Group-level exports and how that approval is recorded.
Security introductionLog access with BALP
BALP audit logging records who accessed which data, which supports reviews of bulk exports. Confirm that the audit events cover both the kick-off request and the file downloads, since a bulk export can run for a long time and touch a large population. Decide where audit records are stored, who can read them and how long they are kept.
Set retention and deletion for export files
Exported files stay on disk until something removes them, so an unmanaged export directory becomes a second copy of patient data. Define how long files remain available after the job completes, who can delete them and how deletion is confirmed. Check whether your deployment's storage and backup policies also cover these files, because backups may keep copies after the server deletes them.
Protect files in transit
Clients receive the manifest and then download each NDJSON file through the server or a reverse proxy, so every download needs TLS end to end. Confirm that the proxy does not cache responses, that access logs do not record bearer tokens, and that file URLs cannot be shared outside the authorized client. Review these settings with the team that runs the ingress.
Plan the controls as one layer
HAPI FHIR does not provide a single security layer, so the controls above only protect exports when they are configured to agree. A reviewer should trace one export from the kick-off request through the Binary resources to the deletion record. Ask your implementation partner for this trace as a written test case before go-live.
How the Batch2 job and Binary files fit together
Treat the export as three trust zones: the HTTP API that accepts the kick-off, the Batch2 job that does the reading and writing, and the storage that holds the output. The client makes a $export request with Prefer: respond-async, the server answers with a Content-Location URL, and a Batch2 job runs asynchronously. The job reads resources from the database in batches, writes each output file as a Binary resource, and records the files in a manifest that the client receives when it polls the status URL. The client then downloads each file through the Binary endpoint. Each hop is a point where authorization must be checked again, because the job runs under server credentials rather than the caller's session, so the caller's permissions do not follow the work automatically.
Each output file holds one resource type, so a single export of a Patient and Observation population produces separate files for each type. Consumers must load each file into the table or schema for its type and must not assume a mixed stream. Confirm with your consuming team whether they expect one file per type or a stream they can split themselves, and confirm how the manifest lists files so loaders can map each entry to a resource type. Because files are split so no file exceeds 100 MB by default, a single type can span several files, so loaders need to read the whole manifest, not just the first entry. Test this with a real extract before building the pipeline around it.
Request and download flow for a bulk export
The flow starts with the client sending a kick-off request to the $export endpoint with Prefer: respond-async, and the server responds by starting a Batch2 job. The client then polls the URL returned in Content-Location until the job completes and a manifest lists the output files. Each file is a Binary resource, and the BinarySecurityContextInterceptor checks the Binary.securityContext before the client downloads it. Check that your client handles the polling loop and that your authorization rules apply to every Binary download, not only the kick-off call.
Sequence of kick-off, polling, manifest and secured Binary download.
Limits to confirm before relying on bulk export
Bulk export looks simple from the outside: one kick-off request, a polling loop and a set of files. The limits below decide whether that output fits your downstream consumers and whether the job behaves predictably in your environment. Confirm each one with the HAPI FHIR documentation and a test run on your own deployment before you commit a delivery date.
Output format is NDJSON only
Each exported file is newline-delimited JSON, and the server supports only NDJSON unless a converter is registered on the STORAGE_BULK_EXPORT_RESOURCE_CONVERT pointcut. If a receiving system needs another format, such as CSV or Parquet, the converter is custom code your team or DeployOpen must write, test and maintain through upgrades. Confirm whether the consumer can read NDJSON directly before you plan a converter.
Bulk export docsFiles split at 100 MB
Each output file holds one resource type and is split so that no file exceeds 100 MB by default. A large Patient or Observation export therefore produces many numbered files, and the manifest grows with them. Ask the receiving team whether their loader handles many files per resource type, and test the split size against their ingestion limits before changing the default.
Batch2 job capacity
The export runs as an asynchronous Batch2 job, so concurrent exports compete with other batch work on the same server. Confirm how many jobs can run at once, how long completed output stays available for download, and how a stalled or failed job is detected and restarted. Load-test a full Group export against your expected data volume before you schedule recurring extracts.
Authorization of the kick-off request
The kick-off request and the polling URL are ordinary FHIR requests, so your authorization layer must decide who may start an export and who may read its status. Export at system level can reach every resource type, which makes it the highest-risk scope. Confirm how your authentication and AuthorizationInterceptor setup treats the $export operation before you open the endpoint to any integration account.
Behavior across multiple instances
When several server instances sit behind a load balancer, the kick-off request, the polling requests and the file downloads may reach different nodes. Confirm that every node reads the same job state and database, that a poll hitting another node returns the correct status, and that output files are reachable from every node. Test a poll and a download routed to a different instance than the kick-off before you rely on the setup.
Securing exported files
Exported Binary resources can carry a securityContext, which the BinarySecurityContextInterceptor uses to restrict who downloads them. Without that setup, a user who obtains a file URL may read the full extract. Confirm that your export jobs populate securityContext for each Binary, that the interceptor is enabled, and that the rules match the access model used for the source data.
Binary security docsQuestions teams ask before exporting FHIR data with HAPI FHIR
What drives the cost of a HAPI FHIR Bulk Data export project?
The main cost driver is the written scope: how many resource types and export levels (system, Patient, Group) are in play, whether custom output formats are needed, how the exported files must be secured, and how much testing the data volume requires. A quote follows from that scope, so ask for each component to be priced separately. One-time work includes design, build and initial testing. Recurring costs appear only if you buy ongoing support, upgrades or continuous testing as a retainer. DeployOpen does not publish a price list, so request a written scope before comparing options.
How long does a Bulk Data export implementation take?
Duration depends on the same factors as cost: scope, the volume of data to export, the number of resource types and export levels, the custom formats and security controls required, and how quickly your team can provide access and decisions. Export runtime itself depends on your data size and database capacity, so test it against a realistic copy of your data before committing to a production window. Ask for a timeline in the written scope that separates build, testing and cutover, and confirm which parts depend on your environment.
What does our team need to provide for a Bulk Data export engagement?
The work needs a few specific inputs from your side:
- Engineers who understand FHIR resource structures and the Java and Spring Boot environment in which the HAPI FHIR JPA server runs.
- Database access to the PostgreSQL or Microsoft SQL Server instance behind the server, plus the schema and storage details.
- Details of your identity provider, including how clients authenticate and which roles should download exported files.
- The list of consumers who will receive the NDJSON output and the formats they need.
- Named owners who can approve scope, test results and the production cutover.
Can our own team run a HAPI FHIR Bulk Data export without a partner?
Yes, if your team has FHIR, Java and database skills and time to test. The HAPI FHIR documentation describes the operation, the Batch2 job flow and the Binary resource storage, so a capable team can build the export and the security settings itself. A partner adds the most value when the export needs custom output formats, tight integration with your identity provider, security testing before go-live, or documented evidence for a compliance review. Compare the internal effort against the written scope to decide.
How do the exported files get secured?
Exported files are stored as Binary resources, so access control has to be designed rather than assumed. HAPI FHIR supports populating Binary.securityContext during export so the BinarySecurityContextInterceptor can restrict who downloads each file. You still need to define which roles or compartments may read each export, confirm that the authorization interceptor and your identity provider enforce those rules, and decide how long files are kept and who may delete them. HAPI FHIR states it does not provide a single security layer, so testing these controls is part of the work.
What goes wrong most often with Bulk Data exports?
Teams most often hit problems with assumptions about output. Each file contains one resource type and is split so no file exceeds 100 MB by default, so consumers that expect a single file per type will fail. Only NDJSON is supported unless a converter is registered on the STORAGE_BULK_EXPORT_RESOURCE_CONVERT pointcut, so any other format needs custom work. Other common issues are unsecured download links, polling clients that do not handle the Content-Location flow, and exports run against undersized databases. Test with a consumer that reads the manifest, not just the server response.
Do we need a formal security or compliance review for exported health data?
Exports of patient data usually fall under your privacy and security obligations, so review the access model, retention and audit logging before go-live. DeployOpen tests the setup and prepares evidence for assessments, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies perform those functions. Ask for the export controls to be listed in the written scope so each one can be tested and evidenced.
What to confirm with the HAPI FHIR version you run
Confirm the release you deploy before you rely on any export behavior described on this page. HAPI FHIR 8.2.0 requires JDK 17, so a server built on an older release line may need a different Java runtime, and the latest release supplied for this topic is v8.8.2, released on 25 September 2026. Export behavior, default file sizes, pointcut names and configuration keys can change between releases, so read the release notes for your exact version before you copy any setting from this page or from older examples.
Treat the bulk export documentation for your version as the reference for the Prefer: respond-async kick-off flow, the Batch2 job behavior, the 100 MB default file split and the STORAGE_BULK_EXPORT_RESOURCE_CONVERT pointcut. Check each of these against the documentation published for the release you run, and record the version and the page you checked in your deployment runbook. Ask your implementation partner to confirm the same items in a test environment built from the target release, not from the most recent documentation.
Also confirm the Binary security interceptor behavior for your version, because the Binary.securityContext population and the restrictions it enforces decide who can download exported files. Test the download path with a non-authorized account on the exact release, since a version change can alter how the interceptor is registered. Write the results into your change record so that a future upgrade starts from a verified list of export settings rather than from memory.
Deciding between bulk export and paged REST reads
The decision starts with the consumer's need: if it needs whole datasets for Patient, Group or the full system, bulk export fits, and paged REST reads fit single records or small searches. Next, check the output format. The JPA server's Bulk Data $export writes NDJSON only, so a consumer that needs another format must have a converter registered on the STORAGE_BULK_EXPORT_RESOURCE_CONVERT pointcut before the export is designed. Last, decide whether the exported files need restricted download, which means populating Binary.securityContext for the BinarySecurityContextInterceptor.
Decision path from consumer need to export format and file access.
Official HAPI FHIR documentation for bulk export
The two supplied HAPI FHIR documents cover the bulk export operation and the interceptor that restricts who can download its output. Read them together, because the export job decides what gets written and the binary security interceptor decides who can read it afterwards. The cards below point to the sections each team needs before building or reviewing an export.
Bulk export server guide
The main HAPI FHIR bulk export page explains the asynchronous Batch2 job behind system, Patient and Group level exports. Use it to confirm the kick-off request with Prefer: respond-async, the polling flow through the Content-Location URL, and the manifest that lists output files. Check the page for the file size default and the NDJSON-only output before you promise downstream consumers a format.
Bulk export docsBinary security interceptor guide
This page covers the interceptor that checks access to Binary resources, which is how exported files are normally protected. Read it to see how Binary.securityContext is evaluated on download and what the interceptor does not cover. Confirm that your export jobs populate that field before you rely on it, because an export without security context leaves files governed only by your general server access rules.
Binary security docsExport output and file handling
The bulk export guide describes how each file holds one resource type and is split so that no file exceeds the default limit. Plan storage capacity, download clients and retries around that split rather than around a single large file. Ask your team to test a full export against the production data volume so the number of files and total storage are known before the first scheduled run.
Custom output formats
Non-NDJSON output requires a converter registered on the STORAGE_BULK_EXPORT_RESOURCE_CONVERT pointcut. The guide explains that hook, so read it before scoping any project that needs CSV or Parquet. Estimate the converter as custom development and testing work, and confirm with the HAPI FHIR documentation and your own engineers how it interacts with file splitting and the manifest.
Version alignment check
Bulk export behavior and configuration keys can change between HAPI FHIR releases, so the docs you read must match the version you run. Check the versions page before copying a configuration example, and record the exact server version in your deployment notes. Pin the version you tested with the export pipeline, and repeat the export test before each upgrade.
How DeployOpen scopes and delivers a HAPI FHIR bulk export
DeployOpen plans and implements HAPI FHIR bulk export inside your own infrastructure, whether that is your cloud accounts, data centers or an air-gapped network. Work starts from a fixed-scope written agreement that names the export types in scope (system, Patient or Group level), the resource types to include, the output storage location, the Binary security settings and the acceptance tests. Before that agreement is signed, your team should confirm which client systems will poll the Content-Location URL, who owns the downloaded files afterward, and which parts of the export pipeline your own staff will maintain.
Delivery covers the server-side configuration and the controls around the exported files. That includes the Batch2 job settings, the file size behavior, any custom output converter registered on the STORAGE_BULK_EXPORT_RESOURCE_CONVERT pointcut, population of Binary.securityContext and the BinarySecurityContextInterceptor, and authentication and audit logging for the kick-off and download calls. DeployOpen also runs security testing against the export endpoints, checking whether a caller can read another tenant's files, guess manifest URLs or download files without the expected security context, and then retests after fixes. Ask any delivery partner to show the test cases and the findings report format before you commit.
Ongoing support is available through a retainer, which can cover upgrades to newer HAPI FHIR releases, regression checks on export output after schema or configuration changes, and continuous security testing as your deployment changes. Confirm with your own team which responsibilities stay internal, such as storage lifecycle, retention of exported NDJSON and access reviews, and write them into the agreement so nothing depends on assumption. Quotes follow from the written scope, so the more precisely you describe export volumes, consumers and compliance obligations, the more accurate the proposal will be.

