Managing secrets for Medplum Bots

Keep API keys and credentials out of Bot source code by storing them as project secrets, separating development and production projects, limiting who can edit secrets, and auditing access on a self-hosted Medplum deployment.

On this page

Managing secrets for Medplum Bots: what it covers and when teams need it

Any Bot that calls an outside API needs a place to keep its credentials that is not the Bot's source code. Payer eligibility endpoints, laboratory interfaces and messaging vendors each issue keys or tokens, and a team that pastes them into a Bot risks exposing them in version control, in exported Bot code and in logs. Medplum provides project secrets for this purpose: named values stored on the Medplum project and made available to a Bot at execution time. This section explains what that covers, why it matters more on a self-hosted deployment, and the moments when the topic stops being optional.

On a self-hosted deployment, your organization owns the whole chain: the database that stores the project configuration, the server that injects secret values into Bot runs, and the audit trail your compliance team will ask about. Medplum's compliance documentation describes compliance as a shared responsibility between Medplum and its customers, so the way your team stores and limits access to these credentials is part of your own control set. Confirm with your security team where project secrets are persisted in your installation, who holds administrator rights on the project, and how those rights are reviewed.

The topic becomes urgent at three points: the first external integration that needs a credential, the first shared Bot repository where more than one engineer can see configuration, and the first audit request that asks how vendor credentials are controlled. Teams that wait until the third point usually find secrets already hard-coded in Bots and copied between projects. Before the first integration goes live, confirm the secret names, owners and rotation expectations for each vendor, and check the current behavior against the Medplum documentation for your version, since secret handling depends on the Bot runtime you have chosen.

Where secrets live across the Bot lifecycle

The flow starts in the Bot repository, where code is versioned but credentials never belong. CI/CD pipelines deploy Bots to the development project first, then promote the same code to the production project, and each project holds its own secrets. The trust boundaries sit between the repository and the Medplum server, and between development and production. Check that no secret value crosses either boundary in source, pipeline logs or Bot code, and that the external API receives only the credentials bound to the project where the Bot runs.

Bot code moves through CI/CD while each Medplum project supplies its own secrets at runtime.

Secret storage options and when each fits

Project secrets are values stored inside a Medplum project and made available to Bots at run time. Medplum administrators who can edit the project manage them, so the credential lives in the same system as the data the Bot touches. This keeps the setup close to the Bot and avoids a second system to operate, but it also means that anyone with rights to edit the project can view or change the value. Confirm in your Medplum version how secrets are exposed to Bot code and whether values can be read back through the API or console after they are saved.

  • Ownership: The Medplum project administrators own the values, so the credential's lifecycle is tied to the people who administer the project.
  • Rotation effort: Rotation is a manual edit in the project, and every Bot that reads the secret must be checked after the change.
  • Audit trail: Confirm whether changes to secret values appear in AuditEvents or project history, and whether reads are logged.
  • Upgrade dependency: Secrets sit in the Medplum database, so they travel with backups and are covered by upgrade and restore procedures.
  • Separation: Use separate development and production projects so a test credential never reaches a production Bot.

Before relying on this option, check how your Medplum version handles secret visibility and change history.

Setting up Bot secrets across dev and production projects

This sequence gives each Medplum Bot the same named secrets in a development project and a production project, with values entered in the admin tooling and never in code. The result is a Bot that has been tested with development values and promoted with a known configuration.

  1. Create separate development and production projects

    An administrator creates two Medplum projects, one for development and testing and one for production, on the self-hosted deployment. Keep them apart from the start so that test credentials never reach live patient data and production keys never sit in a test environment. Confirm that each project has its own membership list, so that the people who can edit one project's settings are chosen separately from the other. Check that both projects appear in the admin console and that the project names make the environment obvious to anyone who opens them.

  2. Define required secret names for each Bot

    The Bot owner lists every credential the Bot needs, such as an API key for an external service or a webhook signing secret, and gives each one a fixed name. Write the list in the Bot's documentation or repository README, with the purpose and the external system for each name. Use the same names in both projects so the Bot code does not branch by environment. Check that the list matches what the code reads, so a reviewer can compare the two without opening the Bot's source.

  3. Add secret values through the admin tooling

    An administrator enters each value in the project settings of the Medplum admin tooling, once in the development project and once in the production project, using a different value in each. Enter values directly in the tool and do not paste them into Bot source files, configuration files, commit messages or chat threads. Record in your change log who added each secret and when, without recording the value itself. Check that each secret name appears in the project settings with the expected name, and that no value has been copied into the repository.

  4. Scan the repository for stray credentials

    Before the Bot moves past development, the engineer runs a secret scanning tool over the Bot repository and its history. The scan should find no API keys, tokens or passwords in source, tests, fixtures or example files. Any match is treated as an exposed credential: revoke it at the external service, remove it from the history and add the secret through the admin tooling instead. The step is complete when the scan reports no findings and the team has recorded the result.

  5. Confirm the Bot reads secrets at runtime

    The Bot developer writes or confirms code that reads each secret by its agreed name when the Bot runs, and does not fall back to a hard-coded default. The developer then runs the Bot in the development project with a harmless input and checks that the code reaches the external service using the development value. The step is complete when a missing secret causes a clear, logged error instead of a silent failure or a call with an empty credential.

  6. Run a test invocation in development

    The tester invokes the Bot in the development project using a test input and a development endpoint at the external service. The run should succeed, and the Bot output should match the expected result for that input. Repeat the test for at least one failure path, such as an invalid input, to confirm the error handling works. The step is complete when the run is recorded as successful and the team has agreed on the test cases to repeat before promotion.

  7. Review AuditEvents for access to secrets

    After the test runs, a reviewer checks the AuditEvent records for the development project to confirm that the Bot executed as expected and that only the expected identities triggered it. Confirm that the AuditEvents show who invoked the Bot and when, and that no secret value appears in any logged output. Ask your platform team to confirm which AuditEvents your self-hosted deployment records for administrative changes to project settings, since that record is the evidence for who edited secrets. The step is complete when the reviewer signs off on the record and the same checks are planned for the production project.

Why separate development and production projects matter

Development and production Medplum projects should never share secrets, and the reason is simple: a Bot runs with whatever credentials it finds in its project. If a test Bot in a development project holds the same payer API key as the production Bot, a bad test input, a loop or a misconfigured trigger can send real claims or patient messages to a live external system. Keeping separate projects means each environment resolves its own secretName values to its own credentials, so the blast radius of a test stays inside the test. Before go-live, confirm with the payer or vendor that sandbox credentials are issued separately from production ones, and that the sandbox endpoint cannot reach production records or accounts.

The same secret names in both projects are what make promotion work without code changes. A Bot that reads a secret called PAYER_API_KEY can be promoted from development to production unchanged, because the value behind that name is different in each project. The Bot code never contains the value, so the promoted artifact is identical and the environment decides what it talks to. Name conventions should be agreed and documented once, and a naming mismatch between projects should be treated as a failed promotion, not a fix to apply in production. The release mechanics themselves are covered in the CI/CD sibling topic.

The cost of two projects is ongoing synchronization. Every new secret, rotated credential, changed endpoint or added Bot membership must be applied in both projects, and drift between them is the usual cause of production-only failures. Plan for an owner who reviews the two configurations on each change, and for a periodic comparison of secret names (not values) across projects. Ask your team to estimate this recurring effort before choosing the model, since it grows with the number of Bots and integrations. Confirm your deployment's project and access settings in the Medplum authentication documentation before relying on them.

Who can edit secrets and how access is audited

Secret protection is only as strong as the people and identities allowed to change it. The cards below cover the role split, the membership model for engineers and CI, how to review changes, and how to trace which executions used a credential. Confirm each behavior against the Medplum version you run before you write it into policy.

Separate project admin from Bot editor

Project administrators can change project configuration, including the secrets a Bot reads, while Bot editors can change Bot code. When one person holds both roles, a single account can swap a credential and alter the code that uses it. Map each role to a named group and confirm in your environment which permissions each role grants before you assign them. Keep secret edit rights with a small admin group.

Medplum auth docs

Least-privilege membership for engineers

Engineers should hold project membership with the narrowest access that lets them build and test Bots, and production membership should be rarer than development membership. Use separate membership for CI service identities so pipelines can deploy Bots without holding human credentials. Review membership on a fixed schedule and remove access when people change roles.

CI identities with client credentials

Automated deployments should authenticate with client credentials scoped to one project rather than with a shared personal login. Store the client secret in your CI vault, rotate it on a schedule, and check that the identity cannot read secrets it does not need. Confirm how your version issues and revokes these credentials before you document the procedure.

Sign-in controls for the admin interface

Who can reach the admin interface depends on how users sign in. Medplum supports multi-factor authentication and external identity providers, so requiring MFA and routing admin sign-in through your corporate identity provider limits who can open the console and change secrets. Verify which settings apply to admin accounts in your deployment, since defaults differ between projects.

Medplum auth docs

Review who changed a secret

A secret change should leave a trail showing the actor, the time and the Bot or project affected. Ask your team to confirm whether the audit records for secret changes in its Medplum version include the old and new values' metadata, the actor and the timestamp. Where the detail is thin, record changes in your change management system and require a ticket reference for each edit.

Trace Bot runs that used a credential

Medplum AuditEvents record Bot executions, so you can connect a run to the Bot and the caller involved. Use these records to find every execution in a window after a suspected exposure, then compare them against the rotation date. Test this path during a rotation drill so the trace works when you need it.

Medplum compliance docs

How much effort and cost does Bot secret management take?

How much internal effort does setting up Bot secret management take?

The effort depends mostly on how many Bots and external integrations need credentials, and on whether your organization already runs a secrets manager that can serve as the source of truth. A small Medplum project with a handful of Bots and one or two vendor keys is a short exercise. A program with many Bots, several sandbox and production projects, and multiple third-party APIs adds inventory, naming, rotation and approval work. Confirm the effort with your own team by counting Bots, secrets and owners before anyone estimates hours.

What drives the cost of securing Medplum Bot credentials?

Cost follows the number of moving parts. The main drivers are:

  • The number of Bots and external integrations that hold credentials
  • Whether a secrets manager such as OpenBao already exists, or must be built
  • How many Medplum projects you run, such as separate development and production projects
  • How formal your change control and approval steps must be for compliance evidence
  • How many people must be trained to edit secrets safely

Ask any partner to price each driver separately so you can see which ones your own team can absorb.

Can our own team manage Bot secrets without an outside partner?

Yes, many teams do this in-house, especially when they already operate a secrets manager and have engineers who know the Medplum project model. The work is mostly configuration, process and documentation rather than novel engineering. A partner tends to help when the team lacks time, has no one who has built this before, or needs an independent review of the design before an assessment. Be realistic about capacity: rotation, access reviews and incident response continue after the first setup.

What do we need to provide before the work can start?

Plan to provide four things:

  • Access to the Medplum projects in scope, with enough rights to inspect Bots, project secrets and access policies
  • The vendor credentials and API keys the Bots use, along with the vendors' owners who can rotate them
  • Your existing identity and secrets tooling details, if any
  • A named internal owner who makes decisions on naming, approvals and rotation schedules

Without a named owner, the design usually stalls at the approval step.

How long does fixing Bot secrets take, and what sets the timeline?

No single duration applies, because the timeline depends on scope. The largest variables are the number of Bots and credentials to move, how many vendors must issue new keys, whether projects must be split, and how long approvals take inside your organization. Ask the team for a written inventory first, then confirm the sequence with them and the vendors. Quoted timelines should be tied to that inventory.

What does a consultant add beyond the configuration work?

A consultant can add an inventory of every Bot and credential, a review of which people can read or edit secrets in each project, a design for separate development and production projects, and a rotation and audit procedure your staff can run. Consultants also bring testing of the controls, such as checking that a Bot cannot read another project's secrets, and documentation that compliance reviewers can follow. DeployOpen plans, implements and documents this work inside your infrastructure, and fixed-scope quotes follow a written scope agreed before work starts. DeployOpen does not publish prices.

What should a written quote for this work include?

A useful quote lists the Bots and integrations in scope, the Medplum projects and environments covered, the secrets tooling and its ownership, the change control steps to be documented, the training and handover deliverables, and the testing that proves the controls work. It should also state what is excluded, such as vendor-side key issuance or your own audit fees. Ask whether the price includes a retest after fixes and whether ongoing rotation support is a separate retainer. Quotes follow written scope, so vague scope produces vague numbers.

What recurring costs come after the initial setup?

Recurring costs are mostly internal time. Someone must rotate credentials on schedule, review who can edit project secrets, handle new Bots and vendor changes, and keep the runbook current. Infrastructure for your secrets manager and any monitoring also recur. Ask any partner which parts of this run work are included in a fixed-scope project and which need a retainer for continuing support.

Limits to confirm in your environment

Secret handling for Bots depends on details that vary by Medplum version, deployment method and execution backend. The cards below list what to confirm with Medplum and in your own test environment before you commit to a secrets design. Medplum's compliance responsibility is shared with the customer, so the answers become part of your evidence.

Secret-change auditing

Confirm whether your self-hosted version records who created, changed or read a project secret, and when. Ask whether those events appear in AuditEvent resources or only in server logs. Test it with a throwaway secret, then check that the record shows the actor, the time and the Bot or project affected. Without this trail, a changed API key can look identical to a legitimate rotation during an investigation.

Compliance docs

Encryption of secret values at rest

Ask how secret values are stored in the PostgreSQL database and whether they are encrypted at the application layer or only relied on through disk encryption. Confirm who holds the key, where it lives, and how it is rotated. Also check whether database backups, read replicas and logical exports contain the values in readable form. Your security team will ask these questions during review.

Secret size and count limits

Confirm the maximum number of secrets per project and the maximum size of each value. Large values such as certificates or private keys may hit limits that short API keys never reach. Ask Medplum whether these limits differ between Community self-hosting and Enterprise Self-Hosted, and test your largest expected value before designing around one secret per integration.

Behavior during server upgrades

Confirm whether secrets survive each minor version step and whether any schema change touches stored secret values. Plan a test upgrade in a staging environment that mirrors your production project, then verify that Bots still read the expected values afterward. Medplum requires upgrades through each minor version in sequence, so include every step in that test.

Upgrade guide

Secret injection on your execution backend

Confirm that the backend you choose for Bot execution, such as AWS Lambda or a Kubernetes-based runtime, receives secrets through the same path your design assumes. A secret that Medplum injects into one runtime may need a different mechanism in another. Verify environment variable handling, log redaction and the identity the function runs under before moving any production credential.

Shared compliance responsibility

Medplum states that compliance is a shared responsibility between Medplum and its customers. For secrets, that means your team owns the access reviews, rotation schedule, backup handling and evidence of each control in a self-hosted install. Ask Medplum which controls it covers for its own service and which you must operate yourself, and record the split in your control matrix.

Compliance docs

How DeployOpen scopes and delivers Bot secret handling

Bot secret handling is scoped in writing before any work starts. A DeployOpen engagement for Medplum Bot secrets is agreed as a fixed scope that names the Medplum projects in play, the Bots that call external systems, and the secret inventory those Bots depend on. The scope also covers who may view and edit project secrets, the separation between development and production projects, and a rotation runbook that states who rotates each credential, how often, and what the Bot owner must check afterward. Deliverables and timelines are agreed in the same document, so the client can compare the work against an internal estimate or a competing quote on equal terms.

Delivery happens inside your own infrastructure and Medplum deployment, not on a DeployOpen-hosted system. Your team keeps custody of the environment, the credentials and the audit records, and receives the configuration, the role matrix, the runbook and the test notes as documentation at handover, with a walkthrough for the engineers and administrators who will run the process after the engagement closes. Before handover, confirm with DeployOpen which parts of the runbook depend on your identity provider, your secret store and your CI/CD tooling, because those are the points most often left for the client to finish. If you want continued help, optional retainers can cover ongoing rotation support and security testing of Bot integrations, so new Bots and changed permissions are reviewed as they appear. DeployOpen does not issue audit reports, attestations or certifications, so any compliance evidence it prepares should be reviewed by your independent auditor.

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.