Medplum FHIR Subscriptions and webhooks

How to trigger Medplum Bots and external webhooks from FHIR resource changes, with the decisions, limits and checks a self-hosted team needs before going live.

On this page

When Medplum Subscriptions and webhooks fit your integration

Choose a Medplum Subscription when a new Encounter, Observation or QuestionnaireResponse should start downstream work without a scheduled job querying the FHIR API for changes. In Medplum, a Subscription is a FHIR resource that watches for create or update activity on resources matching criteria you define, then notifies a target when a match occurs. For a self-hosted team, the first decision is whether the event is time-sensitive enough to justify an event-driven path. Polling remains a reasonable pattern for nightly reconciliation, batch reporting and backfills, so list which workflows need immediate action and which only need periodic checks before you design the triggers.

The target decides where the work runs. A Bot target keeps the logic inside Medplum, so the code reads and writes FHIR data under the Bot's own access and its executions appear in the project's audit trail. An external webhook sends the changed resource to a service you operate, such as an integration engine, a notification system or a warehouse loader, which fits when the business logic or the operational owner sits outside Medplum. Use a Bot when the result must be written back to the record, and a webhook when another system must receive the event. Confirm in the Medplum docs for your installed version which target types it supports and how each one authenticates.

Before you build, check three things in your own environment: event volume and ordering, idempotency and the owner of each receiving endpoint. A trigger that fires on every update can create duplicate work if the target is not safe to run twice, and a webhook receiver that is down will need a recovery path. Also review who can create Subscriptions, because a trigger can send data to a destination that the author of the Subscription may not be authorized to expose. Limits such as the per-project Subscription count and the WebSocket options differ across releases, so confirm them against your version in the Medplum self-hosting docs before you size the design.

How a FHIR change reaches a Bot or webhook

The path starts when a client writes a FHIR resource to the Medplum server through the FHIR R4 API. The server checks each active Subscription criteria against the change, and a match sends a notification to either a Medplum Bot running inside the server environment or an external endpoint you own. The external endpoint sits across the trust boundary, so confirm how it authenticates requests and who can reach it. AuditEvent records capture the trigger and the outcome, and they are the first place to look when a notification seems to be missing.

Shows a FHIR write matched by Subscription criteria and delivered to a Bot or external endpoint.

Choosing between a Bot target and an external webhook

A Bot target runs server-side logic inside the Medplum deployment. When a Subscription matches a resource change, Medplum invokes the Bot with the triggering resource, so the code runs next to the data it reads and writes. The Bot authenticates as its own identity inside the project, which means its access comes from Bot memberships and access policies rather than from a token your team issues and stores. Network exposure stays inside your infrastructure, because the Bot does not need an inbound route from outside.

  • Where the logic runs: In the execution backend your deployment is configured for, such as AWS Lambda or a Kubernetes-based setup, with the Bot code versioned in the project.
  • Credentials: The Bot identity and its project secrets. No external API key sits in the Subscription itself.
  • Network paths: Traffic stays between the Medplum server and the execution backend. Outbound calls the Bot makes to third parties still need explicit egress rules.
  • Failure visibility: Execution results and errors are recorded in the project, so the team can trace them with AuditEvents and Bot logs without a separate delivery log.
  • Change control: Bot code changes go through the same release path as the rest of the platform, which affects how quickly a fix reaches production.

Confirm with your platform team which execution backend your deployment uses and which egress rules apply to Bot outbound calls.

Subscription configuration options and when each fits

This table compares the Subscription settings that decide how a FHIR resource change reaches a Bot or external system, from criteria and channel type to the per-project limit and resend behavior. Read each row as a choice you make at design time, then confirm the exact field names, limits and behavior against the Medplum docs for the version you run.

OptionWhat it controlsWhen it fitsConfirm before you build
Criteria expressionWhich resource type and changes fire the Subscription, written as a FHIR search-style expressionNarrow triggers such as a new ServiceRequest with a given status, so Bots run only on relevant changesSupported search parameters and whether the criteria are evaluated on create, update or both for your version
Bot channelRuns a Medplum Bot inside your deployment when the criteria matchLogic that writes back to FHIR, calls internal services or transforms data in the same projectBot execution backend in your deployment, Bot secrets and the identity the Bot runs as
REST hook channelSends the matching resource to an external HTTP endpoint you specifyNotifying an external system such as a billing or lab service that already exposes an endpointEndpoint authentication, TLS requirements, payload shape and how the receiver acknowledges delivery
WebSocket channelPushes matching changes to an open client connection while it stays connectedLive user interfaces such as a worklist or dashboard that must update without pollingConnection limits, reconnect behavior, and that clients cannot rely on it as a durable delivery record
Per-project Subscription limitCaps how many Subscriptions one project can holdDesigns that consolidate many triggers into fewer, well-scoped SubscriptionsThe current numeric limit for your version, and whether it can be raised on your plan or deployment
Resend behaviorRe-sends a notification for a resource after a failed or missed deliveryRecovering from a receiver outage or a Bot error without manual data re-entryHow resend is triggered, which resources it covers, and how duplicate deliveries are handled by the receiver
Idempotent receiverYour endpoint or Bot tolerates the same event more than onceAny channel where retries or resends can deliver a second copy of a changeWhether the event carries a stable identifier and version you can use to detect duplicates

Per-project Subscription limits and WebSocket trade-offs

Medplum caps the number of Subscriptions a single project can hold, and that cap should shape your design before you write the first criteria. Treat the limit as a hard planning input rather than a number to discover in production. The exact value depends on the Medplum version you deploy, so confirm it in the Medplum Subscriptions documentation for that release, and ask your vendor or implementation partner to confirm it against your own environment. Do not carry a limit forward from a blog post, an older project or a Medplum Cloud plan, because self-hosted settings can differ.

Consolidating criteria is the main lever. Each Subscription should represent one distinct downstream need, such as one webhook endpoint for one integration, rather than one Subscription per Bot or per workflow step. Where several events need the same target, a single Subscription with a well-formed criteria expression and a clear channel usually works better than several overlapping ones. Map each planned Subscription to an owner, a target and a volume estimate during design, then compare the total against the confirmed limit. If the count is close, decide whether a Bot can fan out internally, which moves routing logic into code you can test and version.

A WebSocket subscription suits a connected client, such as a clinician's browser session or a monitoring screen, that needs near-real-time updates while it is open and can tolerate losing events when it disconnects. A server-side webhook suits an integration that must be notified even when no user is online, such as a lab interface or a billing system, and it needs a retry path and a logged delivery record. Use WebSockets sparingly for server integrations, because the connection lifecycle, reconnection and replay behavior become your problem. Test both paths under the disconnect and failure scenarios your workflow will actually face before you commit to either.

Setting up a Subscription and confirming it fires

This sequence takes a Subscription from criteria on a test project to a confirmed notification and then a controlled promotion. Each step ends with a check, so the team knows the trigger works before any production data or endpoint depends on it.

  1. Define the Subscription criteria on a test project

    An engineer creates a Subscription resource in a dedicated test project, with a criteria string that names one FHIR resource type and the search parameters that should match, such as a specific Observation code or a Patient status. Keep the criteria narrow so the test does not match unrelated data. Confirm the Subscription is saved and that its status shows as active in the project before you move on. Ask your Medplum contact or check the Medplum Subscriptions documentation for the current criteria syntax and the per-project Subscription limit in your version.

  2. Create the Bot or endpoint target

    Decide whether the Subscription calls a Bot inside Medplum or an external webhook, then create that target. For a Bot, deploy a simple test Bot that writes a marker value to a log or a test resource, and link it from the Subscription's channel settings. For an external webhook, point the channel at a test receiver you control, such as a request inspection endpoint in a non-production network. Check that the target answers a manual test request before connecting it to the Subscription.

  3. Grant the Bot identity the right access

    Assign the Bot a project membership and access policy that allows only the reads and writes the test needs. If the Bot should act for the person who made the change, decide whether runAsUser is appropriate and document that choice. Avoid using a project admin identity for the test. Confirm the access by having the Bot attempt one read of the triggering resource and one write to the test resource, then verify that a request outside the allowed set is refused.

  4. Trigger a test change

    Create or update a resource that matches the criteria, using a test client or the Medplum CLI from a controlled script. Record the resource ID, the time of the change, and the expected notification in a short test log so the result can be matched later. Do not use a synthetic change that also matches criteria for production workflows. Check that the resource was saved with the expected version before looking for the notification.

  5. Confirm the notification in logs and AuditEvents

    Check the Bot's execution logs or the receiving endpoint for the payload, and then search AuditEvent resources for the Subscription trigger and the Bot execution tied to the test resource ID. A matched entry should show the Subscription, the triggering resource and the outcome. If the notification is missing, first confirm the criteria against the saved resource, then check the Bot's access, and finally check the endpoint's reachability. Only proceed when both the payload and the AuditEvent agree with the test record.

  6. Repeat with a non-matching change

    Create or update a resource that does not match the criteria and confirm that no notification or Bot execution is recorded for it. This negative test shows that the criteria are narrow enough. Note any unexpected matches and tighten the search parameters before promotion. A clean result is an empty set of new AuditEvents for the non-matching change within the same test window.

  7. Promote the configuration with a controlled release

    Export the Subscription, the Bot code, its access policy and the endpoint settings from the test project, and apply them to the production project through your normal change process. Store the Bot code in version control and record who approved the promotion. Do not copy secrets or endpoint credentials between projects; configure those separately in the target project. Run one production-safe check, such as a change to a dedicated test Patient, and confirm the matching AuditEvent before enabling broader traffic.

Security risks in event-driven Medplum integrations

Subscriptions and webhooks move PHI out of Medplum at the moment a resource changes, often without a person in the loop. The cards below cover the places where that flow tends to fail: the secrets used to reach outside endpoints, the identity a Bot runs under, what the payload carries, how receivers know a call is genuine, and whether the trail is complete enough to investigate.

Endpoint credentials stored in Bot code

A webhook or Bot that calls an external system needs an API key, token or signing secret. If that value is hardcoded in Bot source or pasted into a Subscription, anyone who can read the Bot or export the project can use it. Store outbound credentials as project secrets, limit who can edit them, and check that Bot source contains no literal keys before a release. Confirm with your own team how secret access is granted and reviewed, since this depends on your project setup.

Bot running with broad project rights

A Subscription-triggered Bot acts as the identity it is configured with, and that identity may be able to read or write far more than the event needs. A Bot that only forwards lab results should not be able to read unrelated Patients. Review the Bot's membership and access policy, and check whether run-as-user behavior is what you want for each trigger. Least privilege should be tested with a non-admin event, not assumed from the configuration screen.

PHI sent to third-party endpoints

A Subscription can send the full resource, including names, identifiers, dates and clinical details, to a destination you do not operate. Before wiring an external webhook, decide which fields the receiver needs and whether the vendor is covered by a business associate agreement for your use case. Filter or minimize the payload in the Bot, and confirm the legal position with your privacy and compliance leads rather than relying on the endpoint's own terms.

Unverified inbound webhook calls

A receiver that accepts any POST to its URL can be tricked into processing forged events or replays. Require a shared-secret signature or another check on every inbound call, reject requests that fail verification, and tie accepted events to an idempotency key so a replayed message does not repeat a clinical action. Test the rejection path with a deliberately wrong signature. The exact header and signing scheme depend on how your receiver is built.

Gaps in the audit trail

When a delivery fails, an investigator needs to know which resource changed, which Subscription fired, which Bot ran, what it sent and whether the receiver responded. Medplum records AuditEvents for these steps, but retention, export and alerting are decisions for your deployment. Confirm which events your configuration produces, keep them in a store your security team can query, and run a test change to check that the full chain can be reconstructed.

Compliance docs

Troubleshooting failed or missing Subscription notifications

Why does my Subscription not fire when a resource changes?

The most common cause is that the saved resource does not match the Subscription criteria after the change. Compare the criteria string with the resource as it exists after the write, including the resource type, search parameter names, values and any modifiers. Check whether your trigger covers creates, updates or both, because a Subscription built for one event type will not respond to the other. Confirm the exact behavior for your Medplum version in the self-hosting and FHIR documentation, since criteria handling is the first thing to verify before assuming a platform fault.

How do I test whether my Subscription criteria match a resource?

Run the same FHIR search you put in the criteria against the resource in a test project, using the values it has after the change. If the search returns the resource, the criteria are a likely match and the problem lies elsewhere, such as the channel or the target. If the search returns nothing, adjust the criteria or the data. Repeat the test with a resource that is only partially populated, because missing fields are a frequent reason a search that looks right in a test still fails in production. Keep the test cases in version control so they run again after each change.

What causes a webhook target to return errors to Medplum?

Target errors usually come from the receiving side: an unreachable host, a certificate the Medplum server does not trust, a rejected authentication header, a non-success HTTP status or a response that arrives after the timeout. Check the target's access logs for the request time and the status it returned, then confirm that the target accepts the payload format and headers Medplum sends. Verify network paths from the Medplum server, not from your laptop, because firewall and egress rules on the server network often differ. Confirm retry and timeout behavior in the current documentation before you design the receiver.

Can I resend a webhook after the target recovers?

Yes, resending is part of the Subscription workflow, but confirm the exact procedure, the events it covers and how long the original data remains available in the Medplum version you run. Before you resend, fix the cause of the failure, or the same error will repeat. Make sure the receiving system handles duplicates, because a resent notification can arrive after the target already processed the original. Record which notifications you resent and why, so the audit trail explains the second delivery later. For clinical data, agree on a rule for who approves a resend.

How do AuditEvents help trace a failed notification to its source change?

AuditEvents record activity in Medplum, so they let you link a failed notification back to the change that triggered it. Work through three steps:

  • Find the AuditEvent for the write to the resource and note its timestamp and resource identifier.
  • Find the AuditEvent or entries tied to the Subscription execution for that same resource and compare times.
  • Check the outcome recorded for the delivery attempt, then match it to the target logs.

If the write has an AuditEvent but no delivery entry, the problem is likely in criteria or the Subscription setup. If a delivery entry shows an error, the problem is at the target or the network. Confirm which fields your version records before you build alerts around them.

Does a WebSocket subscription miss messages when a client disconnects?

A WebSocket subscription delivers messages only while the connection is open, so a client that disconnects can miss changes that happen during the gap. Confirm the reconnection and replay behavior for your Medplum version before you rely on it. Design the client to recover on its own: record the last change it processed, reconnect with backoff, and run a FHIR search for resources changed since that point. Make the handler idempotent, so processing the same resource twice does not create duplicate records. Test a forced disconnect during a burst of writes, because that is where gaps appear.

When should we escalate a missing notification to Medplum support?

Escalate after you have ruled out your own configuration. Gather the Subscription identifier, the resource identifier, the timestamps of the change and the expected delivery, the AuditEvent identifiers, the target logs and the Medplum version your deployment runs. Reproduce the problem in a minimal test project so the vendor can work from a clean case. If you run a self-hosted deployment, also state whether the problem follows an upgrade, since the upgrade path is documented in order. Report public defects through the project's GitHub repository, and confirm which support channel your contract includes.

Can DeployOpen diagnose missing Subscription notifications on our self-hosted Medplum?

DeployOpen can plan and carry out this work on a self-hosted Medplum deployment inside your own infrastructure. A typical triage covers criteria review, target and network checks, AuditEvent tracing, a reproduction in a test project and a written findings list with fixes. Engagements are fixed-scope, so the scope, deliverables and timeline are agreed in writing before work starts, and the quote follows from that scope. The cost depends on how many Subscriptions and targets are involved, how much logging already exists and whether the fix requires code or configuration changes. Ongoing monitoring and support are available as a retainer.

Limits to confirm in your environment

Subscriptions and webhooks depend on platform limits, retention windows and delivery behavior that differ by version and deployment. The cards below list what to confirm with the vendor docs for the exact version you run, and what to test in your own environment before a clinical workflow depends on them.

Per-project Subscription limit

Every Subscription counts against a limit set per project, so a design that creates one Subscription per patient, per clinic or per integration can hit the ceiling without warning. Confirm the current number in the Medplum docs for your version, then count the Subscriptions your planned criteria would need, including Bot triggers and external webhooks. Decide early whether to consolidate criteria or split work across projects, since changing it later affects Bot identity and access.

Self-hosting docs

Resend retention window

Failed webhook deliveries can be resent from the server, but only while the original attempt still exists in storage. Ask how long Medplum keeps delivery history on your deployment and whether your database backup schedule covers the same window. If a downstream system is down longer than that window, the resend path will not recover the missed events, so you need a reconciliation query against the FHIR API as a fallback.

Delivery ordering

Subscription notifications for rapid successive updates to one resource may arrive out of the order the changes were made, especially when retries or multiple server instances are involved. Confirm the ordering guarantee in the docs for your version. Receivers that apply state changes should compare the meta.versionId or lastUpdated values on the resource instead of trusting arrival order.

Duplicate handling

Retries after a timeout can deliver the same event more than once, so a receiver that creates a Task, sends a message or posts a charge will double-act unless it is idempotent. Confirm whether Medplum guarantees at-least-once or at-most-once delivery for your version. Then build receivers keyed on the resource version or an event identifier, and test a forced timeout in staging.

WebSocket connection limits

WebSocket Subscriptions hold open connections, and the number a single server instance or load balancer will accept depends on configuration, ingress idle timeouts and the proxy in front of Medplum. Confirm the connection and idle timeout behavior for your version, then load test with the expected number of clients. Check that your reverse proxy passes the upgrade headers and does not close idle sockets during quiet periods.

Self-hosted version differences

Subscription behavior, criteria support and AuditEvent detail can change between minor versions, and self-hosted installs must step through each minor version in sequence. Record the version in use, read the release notes for every version between it and your target, and rerun your Subscription tests after each upgrade. Treat the vendor docs for the version you run as the source of truth, not older blog posts or forum answers.

Upgrade guide

What Medplum Subscriptions implementation costs and requires

What drives the cost of setting up Medplum Subscriptions and webhooks?

The cost follows the number of Subscription criteria, the number of target endpoints or Bots each one triggers, how ready those endpoints are, and how much testing the event flow needs. Each criterion and target adds design, configuration and verification work, and each external webhook receiver adds integration work on the receiving side. Ask any provider to price these items separately in the written scope so you can see which ones move the total. No figure is given here because no researched cost for this work was supplied; confirm the basis of any quote in writing.

Can an internal team set up Medplum Subscriptions without outside help?

Yes, a team with FHIR experience and access to a Medplum project can configure Subscriptions and Bots itself, and Medplum's documentation covers the resource model and trigger behavior. The harder parts are usually outside Medplum: securing webhook receivers, agreeing on retry and failure handling with the receiving system, and testing event volumes under realistic load. Teams that lack in-house engineers with those skills, or that must prove the setup to an assessor, often bring in a partner for the design and test phases. Decide this by checking your skills against those specific tasks, not by the feature list alone.

How long does a working Subscriptions setup take?

Duration depends on scope: a single criterion triggering one Bot in a sandbox project is far smaller than several criteria feeding external webhooks with tested retries and monitoring. The main schedule items are agreeing the event list, building and securing endpoints, testing with representative FHIR data, and cutover into the production project. No timeline was supplied for this work, so ask any provider for a duration tied to a written list of criteria, targets and test cases, and ask which of those items the estimate assumes you will complete.

What does the client need to provide for a Subscriptions engagement?

The client typically provides a non-production Medplum project with representative test data, named owners for each webhook endpoint who can change or confirm their behavior, and administrator access to the Medplum deployment, including the ability to create Bots and review AuditEvents. Without test data that reflects real resource shapes, validation of criteria is weak. Without endpoint owners, retry and error behavior cannot be agreed. Confirm access paths, credential handling and change approval for production before work starts, since these determine how quickly testing can move.

Will the Medplum project limit on Subscriptions affect the design?

Yes. Medplum limits the number of Subscriptions per project, so the count of criteria you need should be checked against that limit before the design is fixed. If the required count is close to or above the limit, the design may need consolidated criteria, separate projects or a different trigger pattern. Confirm the current limit in Medplum's documentation for your version, because it can change between releases, and include the check in the design review.

How is a fixed-scope Subscriptions engagement agreed?

Most DeployOpen engagements are fixed-scope, meaning the scope, deliverables and timeline are agreed in writing before work starts. For Subscriptions, that written scope should list each criterion, each target, the endpoint owners, the test cases, the monitoring and replay approach, and the handover material. DeployOpen does not publish a price list, so a quote follows from that written scope. Ask for the exclusions in writing as well, such as work on the receiving systems, and confirm how changes requested during the build are handled.

What ongoing effort does Subscriptions need after go-live?

After go-live, the recurring work is monitoring failed deliveries, reviewing AuditEvents for triggers and errors, resending webhooks when a receiver was down, and updating criteria when resource use changes. Medplum releases also require review, since self-hosted upgrades must pass through each minor version in sequence and the release cadence affects how often you retest. Ongoing support and continuous testing are available as retainers, and their scope should be defined in writing with the same care as the original build.

How DeployOpen scopes and supports Medplum event integrations

DeployOpen plans, implements, tests and documents Medplum Subscriptions and webhooks inside your own self-hosted Medplum deployment, in the cloud accounts, data centers or air-gapped networks you run. Scope is agreed in writing before work starts. For this topic, that scope should name each resource criteria that will trigger a Bot or external webhook, the Subscription channel type for each one, the endpoints and authentication used for outbound calls, the Bots that will run and the identity each one runs as, and the AuditEvent checks used to confirm delivery. A written scope that lists every Subscription is the fastest way to tell whether a request fits a fixed-scope engagement or needs a retainer.

Work usually falls into three parts: design of the trigger model, build and verification in a non-production project, and the cutover of live Subscriptions with the monitoring that follows. Verification covers the situations that cause the most trouble in practice, including criteria that match too many resources, receivers that fail or time out, resending after an outage, and WebSocket clients that disconnect. Ask for test cases tied to each Subscription, a record of the AuditEvent evidence each test produces, and a handover of runbooks your operations team can follow. Confirm with your own Medplum version which Subscription limits and channel options apply, since they change between releases and the Medplum versions and release policy sets the upgrade cadence you will need to plan around.

Retainer support covers the recurring part of the work. Medplum ships patch releases weekly and a major version annually, and a self-hosted server must be moved through each minor version in order, so Subscription behavior should be retested after each upgrade. A retainer can include upgrade rehearsals, regression tests for each Subscription, review of new AuditEvent failures and periodic re-checks of criteria as your resource volume grows. Ask for the retainer scope, response expectations and what is excluded in writing, and confirm which of these tasks your own team will keep in-house.

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.