Medplum Bots in production: Git, tests and CI/CD

Teams that run Bots from the web editor lose history, review and repeatable deploys as soon as several people change logic that touches patient data. This page explains how to build a governed Medplum Bots CI/CD process on a self-hosted deployment.

On this page

Why Medplum Bots CI/CD matters once Bots touch clinical data

A Bot repository, unit tests and a CLI deploy from CI give a governed release process for Medplum Bots: every change is reviewed, tested and recorded before it reaches a production project. In Medplum, a Bot is server-side TypeScript that runs when something calls it, whether that is a Subscription reacting to a resource change, a custom FHIR operation, a cron schedule or a direct client call. Once a Bot reads or writes Patient, Observation or Encounter data, its code is part of your clinical data path, so the change history for that code matters as much as the change history for the application that calls it.

Editing Bots in the web editor is convenient for a prototype, but it becomes hard to audit when several people edit the same Bots across projects. The editor saves the current code without a pull request, a reviewer, a commit message or a link to a ticket, so a reviewer cannot later reconstruct who changed a Bot, why, or what it did before. Bots that differ between a development and a production project are especially hard to trace. Teams usually reach the point of moving to Git when more than one person ships Bots, when Bots feed regulated workflows, or when an auditor or your own quality team asks how a production Bot was approved.

Before you move, confirm three things in your own environment: who may merge Bot changes, which project each pipeline deploys to, and whether your pipeline runner can reach the Medplum server you operate. Also confirm how your team's Medplum version pins to the CLI you deploy with, since the server and tooling are released on separate schedules, and check the Medplum releases page for the version you run. The rest of this page covers the repository layout, testing, the deployment pipeline and promotion between projects.

Where a Bot definition can live and when each option fits

This table compares three places a Medplum Bot definition and its code can be managed: the web editor, a Git repository deployed from CI, and a hybrid where Git is the source and production is read-only. Read each row against your release controls, since the right choice depends on how many people change Bots and how strictly production changes must be reviewed and traced.

QuestionEditor in the Medplum web appGit repository deployed with the Medplum CLI from CIHybrid: Git is the source, production editor is read-only
Review before releaseUsually none beyond the editor user's own check, so review depends on team habitCode review on merge requests or pull requests before the pipeline runsCode review in Git, with the pipeline as the only path into production
Audit historyChanges are visible in the project, but the record is not a version-controlled diffFull diff history in Git, linked to the pipeline run that deployed itGit history for code, plus server-side records of each deployment
RollbackManual: restore the previous code by hand or re-edit the BotRedeploy a prior commit or tag through the pipelineRedeploy a prior commit through the pipeline, the same path as any release
Who can change productionAnyone with editor rights on the projectOnly people who can merge to the protected branch and run the pipelineOnly the pipeline identity and a small group who can approve releases
Skills neededFamiliarity with the Medplum editor and FHIR basicsTypeScript, Git, CI configuration and Medplum CLI useThe same as the CI option, plus clear rules for emergency fixes
Suited toPrototypes, a single developer or a short-lived internal BotTeams with several Bot authors and a formal change processRegulated teams that want the web editor for reading and inspection only
Confirm before adoptingEditor permissions and what the project records for each saveCLI commands, flags and deploy behavior for your Medplum version in the Medplum docsHow you will block production edits and record emergency changes in your Medplum version

The four parts of a governed Bot release process

A Bot moves from a developer's editor to a live Medplum project through four linked parts. Each one controls a different risk, and none of them replaces the others. Read them in order, because each part depends on the output of the one before it.

Bot repository layout

The repository holds Bot source, shared types, tests and one configuration file per environment, so the same code can be promoted without editing it. It controls which code is versioned and reviewed. It does not control what a Bot is allowed to read or write in Medplum, which is set by project membership and access policies. Your team owns the folder conventions, the naming of each Bot, and the rule that environment-specific values such as project IDs stay out of source files.

TypeScript build output

The TypeScript build turns reviewed source into the JavaScript that Medplum executes, so type errors against the Medplum SDK are caught before deployment. It controls the compiled artifact that gets deployed. It does not check runtime behavior against real FHIR data, and it does not confirm the build target matches the execution backend in your deployment. Your team owns the compiler configuration, the pinned SDK version, and a check that the build output is the same artifact the tests ran against.

Unit test gate before merge

Unit tests run against mocked FHIR inputs on every change, and a failing test blocks the merge. They control logic errors in mapping, validation and error handling, such as an incomplete questionnaire or a missing identifier. They do not prove that access policies, Subscription criteria or live search behavior work on your server. Your team owns the test fixtures, the coverage expectations for each Bot, and an integration check in a non-production project for anything the unit tests cannot reach.

CI job that deploys to a named project

A CI job uses the Medplum CLI to deploy a built Bot to one named Medplum project, using credentials stored in the CI system. It controls which project receives a release and who can trigger it. It does not control secrets stored inside the Medplum project, and it does not decide whether a Bot's Subscriptions or cron schedules are correct after deployment. Your team owns the project-per-environment mapping, the protected branch rules, the client credentials scope, and the promotion step that moves a Bot from a development project to production.

How a Bot change moves from commit to production project

A change starts on a developer branch in the Bot repository and passes a pull request review and unit tests before any CI job runs. The CI job builds the Bot and uses the Medplum CLI to deploy it to a development project, where the change is checked before approval. Only after an approval step does the same build go to the production project on the self-hosted Medplum server. Secrets such as project credentials are injected by the CI system at deploy time, so the repository and the Bot code never hold them. Check that the production deploy runs from the approved build and that the secrets come from the CI store.

Flow of a Bot change from branch to production, with the CI secret boundary marked.

Setting up Medplum Bots CI/CD from a Git repository

This sequence moves a Medplum Bot from the web editor into a Git repository where it is built, tested and deployed by a pipeline to the development project first. The result is a Bot whose every change is reviewed, tested and traceable to a commit.

  1. Create the repository and project layout

    The platform or integration team creates a Git repository with one folder per Bot, a shared folder for types and helpers, and a configuration file that records which Medplum project each deployment targets. Keep the development and production project identifiers in separate, named configuration entries so a deploy cannot reach production by accident. Done when the repository holds an initial commit, a README that names the owner of each Bot, and a branch protection rule on the main branch that requires review. Confirm the repository host's branch protection options before you rely on them.

  2. Add TypeScript build configuration

    A developer adds a TypeScript configuration with strict type checking, a build script that compiles each Bot into the output the deploy step expects, and a lint step. Pin the Node.js and TypeScript versions in the repository so local runs and CI runs match. Done when running the build command on a clean checkout produces compiled output without errors and without manual steps. Confirm the Node.js version and the Bot build output format against the Medplum documentation for your installed version.

  3. Write the first Bot with typed input

    A developer writes a small Bot handler that receives a typed input, reads or writes FHIR resources through the Medplum client, and returns a typed result. Keep the handler thin and move business rules into plain functions that take data and return data, so they can be tested without a server. Done when the Bot compiles and its input and output types match the FHIR resources it reads and writes. Illustrative check: a Bot that sets a Task status from an incoming Observation should fail the build if a required field is removed from the type.

  4. Add unit tests that run without a live server

    A developer adds unit tests for the plain business functions and for the handler, using a mocked Medplum client so the suite runs in CI without network access or a Medplum deployment. Cover valid input, missing required fields and the error path for each branch. Done when the test command runs locally and in the pipeline, reports a pass count, and fails when a deliberate change breaks an expectation. Test only what the mock can represent; leave end-to-end behavior to the trigger check in a later step.

  5. Configure CI credentials for the development project only

    A platform engineer creates a client identity in the development Medplum project only, with the smallest access policy the Bot needs, and stores its credentials as secrets in the CI system, never in the repository. Production credentials are not created or stored in this pipeline at this stage. Done when the pipeline can authenticate to the development project in a test job and the credential is visible only to the deploy job's environment. Confirm the supported credential type, client setup and secret handling for your installed version against the Medplum authentication and self-hosting documentation, since these vary by version and deployment.

  6. Add the deploy job with the Medplum CLI

    A platform engineer adds a deploy job that runs only after the build and tests pass on the main branch, installs the Medplum CLI at a pinned version, and deploys the compiled Bot to the development project using the Bot's identifier from the repository. Record the commit hash in the Bot's description or a tag so each deployed version traces to a commit. Done when a merge to main produces a successful deploy job log that names the Bot and the commit. Confirm the CLI command syntax and flags against the Medplum documentation for the installed version before writing the job.

  7. Verify with a test trigger and an AuditEvent check

    A tester sends a test input to the deployed Bot in the development project, either by calling it directly or through the Subscription or operation that normally invokes it. Then the tester checks the AuditEvent records for that execution to confirm the Bot ran, the identity used matches the CI client, and the outcome matches the expected result. Done when the trigger returns the expected output and a matching AuditEvent appears with the right identity and no unexpected errors. Record this check in the pipeline notes so every release repeats it before any promotion to another project.

How TypeScript and unit tests fit the Bot release gate

A unit test proves the Bot's own logic, and nothing about the server it runs on. For a Medplum Bot written in TypeScript, unit tests should cover input validation (rejecting a malformed payload or a missing Patient reference before any write), branching (which resource types or status codes trigger which path), transformation of FHIR resources (mapping an incoming Observation into the fields a downstream system expects), and error paths such as a failed lookup or an upstream timeout. These tests run in a few seconds on a developer laptop or in a CI runner. What they cannot prove is equally important: whether the Bot's project membership and access policies allow the write, whether a Subscription actually fires for the resource change, or whether the real data on the server contains extensions, profiles or search results the fixture never included. Those belong to later gate stages, and the release checklist should say so explicitly.

Mock the Medplum client so that CI never needs production credentials. The Bot's handler should receive a MedplumClient (or a narrow interface wrapping the calls it makes) as a parameter rather than constructing its own connection from environment variables. In unit tests, substitute a stub or a mock that returns canned FHIR resources and records the writes it receives, then assert against those records. Keep client IDs, secrets and base URLs out of the test code and out of the CI job's default environment, so a pull request from a fork or a misconfigured branch cannot reach a live project. Confirm the exact client construction and mocking helpers against the Medplum SDK version you pin, since the Bot templates in the Medplum documentation may change between releases.

Add a separate integration stage against a development project before any promotion. Run a second CI job, gated on the unit tests passing, that deploys the Bot to a dedicated development project with its own credentials, then exercises it with realistic FHIR resources and a test identity bound to the Bot's intended access. This stage is where permission errors, Subscription delivery and server-side validation surface. Give the job its own secrets scope, limit who can approve it, and tear down or reset the test data after each run. Ask your Medplum partner or internal platform team to confirm which parts of the integration stage can run in your CI system and which need a self-hosted runner inside your network.

Promoting Medplum Bots between development and production projects

The pipeline builds each Bot once from a tagged commit, deploys that artifact to the development project, and deploys the same artifact to production after approval. The code that passed testing is the code that runs in production, so a production change can be traced to a commit and a pipeline run.

  • Audit trail: The commit, the pipeline run and the approval record form one chain. Keep pipeline logs with the release record so an auditor can trace a running Bot back to its source.
  • Configuration drift: Drift is limited to settings the pipeline does not manage. A change made in the production editor is overwritten on the next deploy, so agree on whether that overwrite is acceptable.
  • Re-checks after promotion: Confirm that secret references resolve in production, that Subscriptions pointing at the Bot exist with production criteria, that access policies and Bot memberships are correct, and that the run-as identity is the one you intended.
  • Approval: A named release owner approves the production stage. Configure the pipeline environment so that the person who merged the code is not the only approver.

Before the first production deploy, run every re-check against the production project itself, not only against development.

Who can deploy Bots and how credentials stay out of the repository

A Bot release is only as trustworthy as the identity that deploys it and the place where its secrets live. The four controls below cover who can deploy, which identity each environment uses, what must be reviewed first, and where credentials are kept. Each card names the decision your security team owns and the evidence to retain.

Scope CI credentials to one project

The pipeline that deploys Bots should hold a credential that can reach only the one Medplum project that owns those Bots. Medplum supports client credentials for server-to-server access, so the CI job can authenticate as a dedicated machine client. Decide who creates that client, which access policy it carries, and how often it is reviewed. Keep the deploy logs and the AuditEvents that record the client's writes as evidence that the credential did only deployment work.

Medplum authentication docs

Separate development and production identities

Development and production should use different Medplum projects, different client credentials, and different people with deploy rights. A shared identity lets a test deploy change production Bots, and the audit trail then cannot show which environment a change reached. Decide whether non-production runs in its own project and who may approve a promotion into production. Keep a current list of client identities per environment and the AuditEvents that show which identity performed each deploy.

Require review before any deploy

Medplum does not enforce these controls by default. You configure branch protection and required review in your Git host and CI system. Decide which branches may trigger a production deploy, how many approvals a change needs, and whether a named person must release the deploy job after merge. Block direct pushes to the main branch and require the unit tests to pass first. Keep the protection settings export, the approval record for each merge, and the deploy log that links the commit to the run.

Keep secrets out of source

API keys, client secrets, and third-party tokens belong in the CI secret store and Medplum project secrets, never in the repository. The CI store holds what the pipeline needs to deploy, and project secrets hold the values a Bot reads at runtime. Decide which values each store holds, who can read or edit them, and how rotation is scheduled. Run secret scanning on commits and pull requests. Keep the secret inventory, rotation dates, and any scanner findings with their resolution.

What to confirm in your Medplum version and environment

Before you adopt a Git-based Bot release process, confirm which Medplum version your self-hosted server runs and how often that version changes. The latest release at research time was 5.2.5, published on October 15, 2026, after 5.2.4 on October 14 and 5.2.3 on October 8. Medplum ships major versions once a year in Q4, minor versions two to three times a year, and patch versions weekly. That cadence means your pipeline will see frequent patch changes and fewer major ones, so pin the server version you test against and record it in the repository. Check the Medplum versions and release policy for the support window of your current major version, since a Bot process built on an unsupported release creates a second upgrade problem.

Next, confirm that the Medplum CLI version in your CI image matches the server, and that the Bot configuration you commit (entry point, runtime settings and identifiers) is the form that version expects. A CLI that is newer or older than the server can deploy a Bot that appears to succeed but behaves differently at runtime. Also confirm how your Bot runtime is provisioned. On the AWS-based deployment path, the CLI deploy step creates or updates functions in your account, so IAM permissions, function naming and region become part of the pipeline. On other backends, such as a Kubernetes-based executor, the deploy target and its credentials are different, and the pipeline must be written for that target. Ask your platform team which backend each environment uses before you write the deploy job.

Finally, treat server upgrades as changes that can alter Bot behavior. Self-hosted Medplum must move through each minor version in sequence, and a post-deploy data migration can run for hours or days on large datasets, so Bot tests should run against the target version in a non-production project before the server is upgraded. Read the Medplum upgrading guide before any server upgrade that could change Bot execution, the FHIR behavior your Bots depend on, or the runtime they deploy to. Record which Bot versions passed on which server version, so a rollback of either the server or the Bots has a known-good pair to return to.

Medplum Bots CI/CD questions buyers ask before hiring help

What does it cost to move Medplum Bots into Git and CI/CD?

The cost depends on four things: how many Bots you run, how mature your existing tests are, how many environments (for example development, staging and production projects) must receive releases, and how much CI tooling you already operate. Each Bot needs a source file, a test, a build step and a deploy step, so a small inventory with no tests costs far less to bring under version control than a large set of Bots with undocumented behavior. Ask any provider for a written scope that lists the Bot inventory, the environments in scope, the test work included, and whether CI runners and secrets handling are your responsibility or theirs. Quotes should separate one-time setup from ongoing maintenance of the pipeline.

How long does a Bot CI/CD project take, and what sets the timeline?

The timeline is set by the Bot inventory, the state of the existing tests, the number of approval steps before production, and access delays on the Medplum project and CI system. A team with a few well-understood Bots and an existing pipeline has a short path. A team with many Bots written in the web editor, no tests and several projects to reconcile has a longer one. Ask for a phased plan in the written scope: inventory and export, repository and build setup, tests for the highest-risk Bots, then the promotion path. Treat any duration you are given as conditional on those inputs, and ask what would change it.

What must our team provide before outside help can start?

Outside help needs four things early: access to the Medplum project or projects where Bots run, access to the CI system that will build and deploy them, a complete inventory of existing Bots with their owners, triggers and the data they read or write, and named approval owners for each environment. Without the inventory, the work becomes guesswork about which Bots are live. Without named approvers, promotion to production has no clear sign-off. Ask the provider to confirm these items in writing and to state who holds credentials and who will revoke any temporary access when the work ends.

Can an internal team move Medplum Bots to Git alone?

Yes, a team with TypeScript experience and access to its Medplum projects can usually do the basic move alone, since the Medplum CLI and the Bot code are the core of the work. Outside help tends to add value in three places: designing the repository and environment layout so projects stay separate, writing tests that use realistic FHIR fixtures and mock clients, and reviewing how deployments are gated and audited. The fastest route for most teams is to pilot one Bot end to end, then repeat the pattern. Decide early which part your engineers will own after handover and which part needs a second reviewer.

How are promotion and rollback handled for Bots between projects?

Promotion moves a tested Bot version from a development project to staging and then production, with the same source code and a recorded approval at each step. Rollback means redeploying the last known good version from Git, not editing code in the web editor during an incident. Your written scope should state how versions are tagged, where approvals are recorded, how environment-specific values such as secrets are kept out of the repository, and how a rollback is tested before it is needed. Check with Medplum's current CLI and Bot documentation for the exact deploy commands and how Bot versions are identified in your release version of Medplum.

What are the main risks of moving Bots out of the web editor?

The main risks are deploying a Bot with a different configuration than the one that was tested, leaking credentials into the repository, and losing track of which Bots are live in each project. Each risk has a control: a single source of truth in Git, secrets stored in project secret configuration rather than code, and a deployment record for every release. Also plan for Bots that depend on Subscriptions, cron schedules or access policies, because changing a Bot's code does not change those settings. Ask any provider how they will document those dependencies and test them before cutover.

Which Medplum version should we target before we build the pipeline?

Pin the Medplum SDK and CLI versions in the repository and match them to the server version your deployment runs, since Bot behavior and CLI commands can change between releases. The latest release at research time was 5.2.5, published on October 15, 2026, and Medplum ships patch versions weekly. Confirm your server version first, then check the release notes on the GitHub releases page before choosing the SDK version. If you plan a server upgrade, sequence it with the pipeline work so the CI tests run against the version you will actually operate.

How DeployOpen scopes and delivers Medplum Bots CI/CD

DeployOpen plans, implements, tests and hands over self-hosted Medplum Bot delivery inside your own infrastructure, so Bot code moves through Git, review and automated checks before it reaches a project. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory the Bots, Subscriptions and cron jobs that will move into a Git-based release process
  • Agree in writing which Medplum projects are covered and how dev and production promotion is defined
  • Confirm the CI runner, Medplum CLI version and secrets handling the written scope will rely on

How we build

  • Set up a Bot repository in TypeScript with unit tests that run on every proposed change
  • Configure a CI/CD pipeline that deploys Bots with the Medplum CLI and promotes them between projects
  • Document the release steps, access rules for pipeline credentials and the rollback path

How we hand over

  • Deliver the repository, pipeline configuration, test suite and promotion runbook to your engineers
  • Walk your team through a release from a branch to production and a rollback on a test project
  • Record the decisions made, including which Medplum version each environment is pinned to

How we support

  • Offer ongoing support, pipeline maintenance and upgrades as a retainer after handover
  • Review Bot test coverage and pipeline changes when Medplum releases new minor or patch versions
  • Keep the written scope as the reference for any change requests made after the engagement starts

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.