Audit logging with IHE BALP AuditEvents in HAPI FHIR

Teams that must show who accessed which health records need AuditEvent records they can trust. This page explains how HAPI FHIR's BALP audit logging works, what to configure, and what to confirm before go-live.

On this page

Audit logging with IHE BALP AuditEvents in HAPI FHIR: when you need it

A self-hosted HAPI FHIR server that holds clinical or personal data needs a record of who accessed what, when, and from which client. Compliance and security teams will ask for that record during reviews, and the server itself will not answer those questions unless you configure it to. BALP audit logging is the HAPI FHIR building block that generates AuditEvent resources for reads, searches and writes, following the IHE Basic Audit Log Patterns (BALP) profile. It records the event and its context, but it does not decide who may see what. That is the job of authorization and consent, which must be designed alongside it.

Teams usually need BALP logging when they are asked to show access history for patient or personal records, when an internal policy requires per-request accountability, or when another system depends on a consistent audit trail. Confirm the specific obligations with your privacy office, security team and auditors before the build, because they determine which events, retention periods and reviewers apply. Also confirm which HAPI FHIR version and interceptor configuration your environment will run, since the audit interceptor and its profile behavior should be checked against the documentation for that release.

Treat audit logging as one control among several. An audit record of a denied or permitted read is only useful if authorization rules, identity and consent are also in place and tested. HAPI FHIR documents that it does not provide a single security layer, so the operator must assemble authentication, authorization, audit and network controls. Decide early whether audit records must prove the identity of the user, the application, or both, because that choice drives the identity provider integration and the context you must pass into each request.

How a request becomes an AuditEvent

The flow starts with a client call to the FHIR endpoint, which first passes the authentication layer that establishes who the user and client are. The BALP audit interceptor wraps the resource provider, so each read, search or write produces an AuditEvent carrying user and client context taken from the authenticated token. The AuditEvent is then sent to a separate audit repository across a trust boundary. Check that the audit store is outside the FHIR server's write path and that failed audit delivery is handled deliberately.

A FHIR request passes authentication and the BALP interceptor before an AuditEvent leaves the server.

Which audit configuration fits your situation

A single-tenant server with one identity provider is the simplest case. Every request carries a token issued by the same authorization server, so the interceptor that generates BALP records can read the subject, the client application and the scopes directly from the validated token. The main work is making sure the token claims you need are present and stable, and that the audit interceptor runs after authentication so it sees the authenticated principal rather than an anonymous request.

  • User context: the subject identifier and, where your policy requires it, a human-readable name or organizational identifier mapped from token claims.
  • Client context: the client ID of the calling application, so you can separate a clinician's browser app from a batch integration using the same user account.
  • Events to confirm: reads, searches and writes each produce an AuditEvent in your test run, including conditional and batch operations.
  • Patient context: confirm whether the patient referenced in a read or search is recorded, since BALP entries for searches depend on how the query is captured.
  • Interceptor order: confirm that authentication runs before the audit interceptor on every endpoint, including the metadata and bundle paths.

Before go-live, send one request of each type from each client application and check the resulting AuditEvent fields against your policy.

Configuration options and when each fits

This table compares the main decisions for BALP AuditEvent generation: which interactions to record, where the records are stored, how user and client identity is sourced, and whether query parameters are kept. Each row shows the volume and privacy trade-off so you can match the setup to your audit obligations and storage budget. Confirm exact option and interceptor names against the BALP documentation for your HAPI FHIR version before you write configuration.

DecisionOptionTrade-offWhen it fits
Audited interactionsWrites only (create, update, delete)Lowest event volume, but reads of sensitive records go unrecordedSystems where access to data is already controlled elsewhere and changes are the main concern
Audited interactionsReads and searchesHigh volume, since every search and read produces a record that must be stored and queriedClinical or regulated records where the question is who viewed a patient's data
Audited interactionsHistory and operationsAdds records for version reads and privileged calls, which are useful but add review workloadEnvironments with a documented need to trace version access or administrative actions
AuditEvent destinationSeparate audit repositoryKeeps audit data away from the clinical store and its administrators, but adds a second system to run and secureOrganizations that require audit records to be tamper-resistant or reviewed by a team separate from data administrators
AuditEvent destinationSame FHIR server storageSimpler to deploy, but audit records share access paths, backups and administrators with the data they describeLower-risk deployments with clear admin separation and a plan to export records to an audit store later
User and client identityToken claims from the external identity providerTies each record to a verified person or application, but depends on consistent claim mapping and token validationMost production setups that already use OAuth 2.0 or OpenID Connect sign-in
User and client identityClient-supplied or header-based identityEasy to set up, but the caller can alter it, so records are not reliable evidence of who actedOnly for test environments or behind a trusted gateway that sets the header
Query parametersRecord search parametersShows what was searched for, which helps investigations, but can place patient identifiers and other sensitive values into the audit storeWhen investigators need search intent and the audit store has the same protection as the clinical data
Query parametersOmit or hash parameter valuesLimits exposure of sensitive values, but reduces detail for investigations and may need custom codeWhen the audit store has weaker controls or wider access than the source data

How to set up BALP audit logging step by step

This sequence takes a HAPI FHIR JPA server from a confirmed version and Java runtime to a working BALP audit pipeline, where every read, search and write produces an AuditEvent with user and client context in a separate audit repository.

  1. Confirm the HAPI FHIR version and JDK

    Choose the HAPI FHIR release line and the matching JDK before any code is written, because the server, its interceptors and the audit libraries must all run on the same Java runtime. The HAPI FHIR versions page lists the JDK each release requires, and HAPI FHIR 8.2.0 requires JDK 17. Record the chosen version in your build file and in your change record. The step is done when a build of an empty project compiles against that version on the target JDK in your CI pipeline, and the team has written down which FHIR versions (such as R4 or R5) the server must serve, since that decides the resource types the audit rules must cover.

  2. Deploy the JPA server in a test environment

    Deploy the HAPI FHIR JPA server starter in a non-production environment that matches your planned hosting model, whether Docker, Kubernetes with the Helm chart, or a WAR on an application server. Replace the default embedded H2 database with PostgreSQL or Microsoft SQL Server, since the starter does not support MySQL and H2 is not intended for production. Confirm the server answers a capability statement request and that a test Patient can be created, read and searched. Without a working baseline, you cannot tell later whether a missing audit record comes from the interceptor or from the server itself.

  3. Put authentication in front of the server

    Configure authentication so every request carries a verified user identity and a client identity that the server can read. HAPI FHIR does not provide one complete security layer, so you choose the authentication interceptor or the reverse proxy and external identity provider that performs sign-in, then confirm the claims your audit logic needs, such as the subject, the user name or organization identifier and the calling application's client ID. Your identity provider team should confirm which claims are issued for workforce and system clients. The step is done when a token from each login path produces a request in which the user and client values are visible in the server log, and anonymous requests are rejected or clearly marked.

  4. Register the BALP audit interceptor

    Register the BALP audit interceptor on the server so it generates AuditEvent resources for reads, searches and writes according to the IHE BALP profile. Decide which interactions are in scope, since audit volume grows with every search, and confirm that the interceptor is ordered so it sees the authenticated principal that your authentication step sets. Map the user and client values from the authentication step into the agent fields of each AuditEvent. The step is done when a single read, a single search and a single create each produce one AuditEvent in the test server output, with the expected action code and an entity reference to the resource or search that was requested.

  5. Route AuditEvents to a separate audit repository

    Send the generated AuditEvent resources to a repository that the FHIR server's own administrators cannot edit, such as a separate store in a different database or account with append-only permissions and its own retention settings. Keeping audit records out of the clinical data store means a compromised or misconfigured FHIR server cannot quietly alter its own history. Confirm the transport between the server and the repository is encrypted, that the repository rejects updates and deletes for the service account, and that failed deliveries are retried or raised as errors rather than dropped. The step is done when a forced delivery failure is visible in your alerting and no AuditEvent is silently lost.

  6. Test with real reads, searches and writes

    Drive a scripted set of real client calls through the server: a read of a permitted patient, a search with several parameters, a create, an update, and a request that authorization must deny. Use at least two distinct user identities and one system client so the agent fields can be checked against known values. Query the audit repository for each call and compare the stored AuditEvent with what you expected, including the action, outcome, agent user and client, and the entity reference. Confirm that the denied request is recorded with an outcome that reflects the failure. The step is done when every scripted call has exactly one matching AuditEvent with the expected agent and entity, and the results are saved as the baseline for regression testing after upgrades.

  7. Confirm the audit pipeline before production

    Before go-live, review the test results with your security and compliance team and confirm the retention period, access rights to the audit repository, and the procedure for investigating a request from a named user. Repeat the scripted test after each HAPI FHIR upgrade or interceptor change, since the audit output can change between releases. Ask your auditor or compliance adviser which obligations the audit trail must meet, because DeployOpen prepares the controls and evidence but does not decide compliance or issue assessments. The step is done when the sign-off records the test baseline, the owner of the audit repository, and the regression test schedule.

What an IHE BALP AuditEvent records and why the context matters

A BALP-conformant AuditEvent answers five questions about every access: who acted, which resource or patient record was touched, what action was taken, when it happened, and from where. In HAPI FHIR, the AuditEvent produced by the BALP audit interceptor is the record your compliance team and auditors will read, so each of those answers has to be filled from a reliable source. The who part is the one most often done wrong. It should name the human user and the client application (the app or service acting on the user's behalf), each identified in a way your identity provider can later confirm. Before you build anything, confirm with your version's documentation which fields the BALP interceptor populates by default and which you must supply through your own code, because the defaults are not the same as a complete record for your environment.

The user and client context must come from the verified access token, not from request headers. A header such as a user identifier or application name is set by whoever sends the request, so a caller can write any value into it and the audit trail will faithfully record a lie. The safer design is to let the authentication layer validate the bearer token against your authorization server, then have your interceptor read the subject and client claims from that validated token and place them into the audit record. Decide which claims map to the user, which map to the client, and what happens when a claim is missing. Test this directly by sending a valid token with a forged header and confirming the record shows the token's identity.

Some requests will arrive with no verified user, such as public metadata calls, failed logins, or access through a service account with no named human behind it. These need a written policy before go-live, not an accidental default. Decide whether each anonymous or unidentified case is recorded, how it is labeled, who reviews it, and how long it is kept. Your privacy and security owners should sign off on that policy, and the test plan should include unauthenticated and expired-token requests so you can show the policy in operation. Ask your auditors which events they expect to see for failed and unidentified access, since their expectations shape how much you must capture.

Security and operational risks of audit logging

Audit logging creates its own security surface: the records can leak the data they describe, the repository becomes a high-value target, and a gap in the trail can be as damaging as a missing control. The cards below pair each risk with the control the operator adds around the HAPI FHIR server and its audit repository.

PHI and query values in audit records

An AuditEvent can carry patient identifiers, resource IDs and search parameters, and a search string such as a name or diagnosis code is itself health information. Decide per event which identifiers and query values the record may hold, and mask or hash the rest before the record leaves the server. Test a sample of generated records with a clinician-facing review, not only a developer check, and confirm that your audit repository is inside the same privacy boundary as the FHIR data.

HAPI FHIR security docs

Audit repository access and tamper resistance

An audit trail is only useful if people who are being audited cannot edit it. Store audit events in a repository that the FHIR server can write to but application administrators cannot modify or delete, and restrict read access to a small named group. Confirm how your chosen repository handles immutability, write-once storage or signed batches, and record who holds administrative rights over it.

Clock and time source consistency

Audit reports are reconstructed by timestamp, so servers that drift produce records that appear out of order or fall outside an investigation window. Synchronize every HAPI FHIR node, database host and the audit repository to the same time source, and monitor offset as a health signal. Ask whether the recorded time is the request start, the commit time or the send time, and document which one your investigators should rely on.

Gaps when the audit sink is unavailable

If the audit repository is down or slow, an interceptor that writes synchronously can fail the user's request, while one that drops events silently leaves a hole in the record. Decide which behavior is acceptable for reads and for writes, and design a local buffer or retry queue with a bounded size. Alert on queue depth and failed sends, and test the outage path before go-live so you know what the trail looks like afterward.

Log volume and retention growth

Every read, search and write can produce an AuditEvent, so volume grows with clinical use, bulk operations and automated clients, not with the size of the dataset. Estimate event volume from your own traffic logs during a pilot, then set retention by the policy your compliance team has agreed. Ask your vendor or repository provider for storage and indexing costs at your projected volume, and plan archive tiers before the first year of data accumulates.

Separation of duties for audit configuration

The people who can change which events are generated, which fields are masked or where events are sent can also hide their own activity. Split roles so that the team that operates the FHIR server cannot alter audit settings alone, and require a second approver for changes to interceptor configuration. Keep configuration in version control, review changes in the same way as code, and periodically compare the running configuration with the approved copy.

Questions teams ask before adding BALP audit logging

What drives the effort and cost of adding BALP audit logging to HAPI FHIR?

The main drivers are how many resource types, operations and client paths must be audited, how many identity sources must supply user and client context, and where audit events must land. A server with a few resource types read by one application is a much smaller job than a multi-tenant server with several front ends, bulk export and custom operations. Cost comes from design work (which events, which fields, which actors), build work (interceptor configuration, any custom mapping), test work (checking that each read, search and write produces the right record) and review work by the compliance and security teams. Ask any partner for a written scope that lists the operations covered, the identity fields mapped and the audit repository being used, since those items set the quote.

How long does a BALP audit logging setup take?

Duration depends on scope rather than on a fixed template. A setup that covers one server, a short list of operations and an existing audit repository is usually far shorter than one that spans several servers, partitions, identity providers and a repository that must be built or changed. Time is spent on agreeing the event model, building and testing the interceptor configuration, validating records against the expected structure, and getting sign-off. Ask for a timeline in the written scope, with milestones tied to the operations and environments in scope, and confirm which steps depend on your own teams, such as access to the audit repository or identity provider.

What must our team provide before the work starts?

Expect to provide four things. First, the identity provider details that supply user and client identity, such as the claims or headers the server can trust. Second, the audit repository, including where events are sent, how long they are kept and who can query them. Third, representative test data and request patterns, so that reads, searches and writes can be exercised with realistic but non-production records. Fourth, named sign-off from security, compliance and the application owners who will accept the event model. Confirm early who owns each item, because delays in access or approvals are a common cause of schedule slip.

Can an in-house team build BALP audit logging without a partner?

Yes, a capable in-house team can do this if it has Java and HAPI FHIR experience, access to the server build, and someone who understands the audit requirements well enough to define the event model. HAPI FHIR provides BALP audit logging as one of its security building blocks, so the work is configuring and testing rather than writing a logging system from nothing. The harder parts are usually the design decisions, the verification against the standard's expectations, and the evidence trail for assessors. Teams should decide whether they have that combination of skills and time before committing, and a partner can be engaged for design review, testing or a fixed-scope build.

How does BALP audit logging relate to AuthorizationInterceptor and consent?

They answer different questions. The AuthorizationInterceptor decides whether a request is allowed, while consent and search narrowing decide which data a permitted user sees. BALP audit logging records what happened, including who acted, through which client, on which resources and with what outcome. Those records are most useful when they also capture denied requests and consent-driven filtering, so teams should plan these controls together rather than as separate projects. Check with your security team which decisions must appear in the audit trail, and test that an authorization denial and a consent redaction both produce the expected record.

What changes when we upgrade HAPI FHIR?

Upgrades can change how interceptors are registered, which fields appear in generated events and which Java runtime is required. HAPI FHIR 8.2.0 requires JDK 17, and the latest release supplied for this page is v8.8.2, released on 25 September 2026, so check the version notes for each step between your current release and your target. After any upgrade, rerun your audit tests, compare sample records against the previous output and confirm that the audit repository still accepts them. Plan this as part of your regular upgrade process, not as an afterthought, and keep the test cases under version control so they can be reused.

Which parts of the audit setup should we verify ourselves?

Verify the parts that reflect your own obligations: the list of audited operations, the identity fields carried into each record, the destination and retention of events, and the access controls on the audit repository. Ask your partner or internal team to show test evidence for reads, searches and writes from each client type, and confirm that failed requests are handled as your policy requires. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors and certification bodies issue any audit report or certification, so confirm with your assessor which evidence they expect.

Running and reviewing the audit trail after go-live

The ongoing work after go-live is proving that the audit trail still covers what it was built to cover. Coverage drifts quietly. A HAPI FHIR upgrade, a new interceptor, a changed resource profile or a new operation can each change which requests produce an AuditEvent, and nothing fails loudly when a read path goes unrecorded. Treat coverage as a test result that you repeat after every upgrade, not as a property you verified once during build. Keep a fixed set of sample requests (reads of each sensitive resource type, searches with and without patient parameters, creates, updates, deletes and any bulk or admin operations you have enabled) and record which ones produce a BALP event, with which action, outcome and agent details. Compare the result against the previous release before you approve the upgrade. The upgrade plan itself is covered elsewhere; this check is the audit-specific gate inside it.

The pipeline between the server and the separate audit repository needs its own monitoring. Watch for three things: events that the server generates but the repository never stores, delivery failures or retries that pile up during an outage, and gaps in timestamps or sequence that suggest lost messages. Ask your team to confirm how the repository acknowledges receipt, what happens to events when it is unreachable, and whether the server is configured to fail requests or drop events in that state. Those are design decisions with compliance consequences, so they belong in the operating record. Day-two dashboards for latency and errors cover the server; the audit path needs a counter-level comparison of requests served against events received.

Access reviews are only useful if you can run them. Pick a small set of realistic questions (for example, which users read a given patient record in the last 30 days, or which client applications accessed a restricted resource type) and confirm that the repository returns complete answers with user and client context on each event. Run these queries on a schedule, not only when an incident occurs. Put the BALP configuration and the interceptor registration under change control, so every change to what is audited, which agent identities are recorded and where events go has a ticket, a reviewer and a rollback path. Your compliance team should be able to see that history without asking the platform team to reconstruct it.

How DeployOpen scopes and delivers HAPI FHIR audit logging

DeployOpen plans and builds BALP-style AuditEvent logging around your HAPI FHIR server as part of a written, fixed-scope engagement. The work covers the interceptor configuration, the user and client context your audit records need, the separate audit repository, and the tests and documentation your compliance and security teams use to review it.

How we scope

  • Agree in writing which interactions are audited: reads, searches, creates, updates and deletes on which resource types.
  • Map which identity claims, client applications and network details must appear in each AuditEvent record.
  • Confirm the destination audit repository, its retention rules and who in your organization reviews the records.

How we build

  • Enable and configure the BALP audit logging on the HAPI FHIR server, with the agreed interaction coverage.
  • Connect authentication context from your external identity provider so user and client fields are populated.
  • Test generated AuditEvent records against real read, search and write requests, including failure and denied cases.

How we hand over

  • Deliver configuration files, a field-by-field map of what each AuditEvent contains, and the test results.
  • Document how to add or change audited interactions, and what to re-test after a HAPI FHIR upgrade.
  • Walk your security, compliance and operations teams through the records and the review procedure before close.

How we support

  • Offer ongoing support, upgrades and continuous testing of the audit logging as a retainer.
  • Retest audit coverage after platform changes, identity provider changes or new resource types are added.
  • Confirm with your auditors which evidence they expect, since DeployOpen prepares records but does not issue audit reports.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.