Scheduling Medplum Bots with cron jobs

Medplum Bots can run on a schedule from settings on the Bot or from a Cron resource. This page explains which option fits, how to set each one up, and how to monitor scheduled runs on a self-hosted deployment.

On this page

When scheduled Medplum Bot cron jobs fit your workflow

A team that needs a Bot to run nightly reconciliation, patient reminders or report generation without a person clicking a button or an external system sending an event has a scheduling problem. Medplum Bots can run on a cron schedule set on the Bot's edit form, and a separate Cron resource, which requires the cron project feature, lets the same Bot run on several schedules under different identities and inputs. The Medplum documentation on cron jobs for Bots describes both approaches, so the first decision is whether one schedule on the Bot is enough or whether you need several.

Scheduled runs are one of several ways to start a Bot. The other common triggers are Subscriptions, which fire when a FHIR resource changes, and client-triggered calls, where an application or integration invokes the Bot directly through the API. A cron job fits work that is time-based rather than event-based, such as a daily sweep for overdue Tasks or a weekly export. If the work should happen the moment data changes, a Subscription is usually the better match. Map each workflow to its trigger before you build, and record which identity the run should use, since that choice determines what data the Bot can read and write.

Before you rely on a schedule in production, confirm three things in your own environment: whether your project has the cron project feature enabled, which Medplum version your self-hosted server runs, and how your team will see failed or skipped runs. The Bot's execution history and audit records are where you will verify that each run happened and what it did, so decide who reviews them and how often. Scheduled jobs that fail quietly can leave reconciliation or reminders incomplete for days, so define the alerting and the owner for each schedule before go-live.

Bot cron settings versus the Cron resource

This table compares the schedule set directly on a Bot with the separate Cron resource across where the schedule lives, how many schedules one Bot can run, identity and input control, feature requirements and fit. Read it row by row to decide whether one schedule is enough or whether the same Bot needs several schedules with different settings. The main takeaway is that the Cron resource is the option when one Bot must run on more than one schedule.

DimensionBot cron settingsCron resource
Where the schedule is setOn the Bot's edit formAs a separate Cron resource linked to the Bot
Schedules per BotOne schedule set on the Bot itselfSeveral schedules for the same Bot
Different identity per scheduleRuns under the Bot's own configurationEach schedule can run under a different identity
Different input per scheduleOne input set for the Bot's scheduled runsEach schedule can pass its own input
Feature requirementAvailable on the Bot's edit formRequires the cron project feature
Best fitA single recurring job with one identity and one inputShared Bot logic run for several tenants, reports or identities
Review before going liveConfirm the schedule and run identity on the BotConfirm the feature is enabled and list each schedule's identity and input

How the Cron resource runs one Bot on several schedules

A Cron resource lets one Bot run on several schedules, each with its own identity and input values. This fits a Bot that serves more than one job, such as a daily reconciliation and a monthly summary, or the same logic run for different sites. Setting cron on the Bot's edit form covers a single schedule. When the same Bot needs different schedules, the Cron resource is the tool to reach for, and it depends on the cron project feature being enabled on the project. Confirm that feature on the project before designing around it, because the schedule setup depends on it.

Each schedule may need its own identity because the work it does can touch different data. A nightly job that only reads one site's records should not run with access to every site, so the identity behind each schedule should match the access that job needs. Inputs matter for the same reason. A Bot run for a site or a reporting period usually reads its parameters from the input it receives, so each Cron entry carries the values that make that run correct. Review the access policies and memberships for each identity against the Bot's logic before the schedule goes live.

The trade-off is maintenance. One Bot is one codebase to test, review and release, but every schedule's inputs become a contract with that code. If the Bot changes the input fields it expects, every Cron entry that passes the old fields can fail or, worse, run with the wrong values. Record the expected inputs for each schedule alongside the Bot, and include a check in your release process that compares them with the Bot's current logic. Teams that prefer separate Bots for separate jobs accept more code to maintain in exchange for simpler input contracts.

How a scheduled run reaches the Bot

A scheduled run can start from two places: the cron setting on the Bot's edit form, or a separate Cron resource that requires the cron project feature. Both paths end in the same scheduled execution of the Bot, which runs under an identity and receives its inputs. Afterward, check the Bot's results and the resulting AuditEvents or logs, which are where you confirm that each scheduled run happened and what it did.

Two entry points lead to one scheduled Bot execution and its monitoring records.

Setting up a cron schedule on a Bot, step by step

This sequence takes a Bot from a tested manual run to a scheduled job with a known identity and inputs, and confirms that each scheduled run is visible to the team that will support it. Follow it in a non-production project first, then repeat it in production once the results match what you expect.

  1. Confirm the Bot runs manually

    Before adding any schedule, run the Bot by hand from the Medplum App with a representative input, and confirm it returns the output your team expects and makes the changes it should. Do this in a development or staging project, not production. The step is done when a manual run completes without errors and you have recorded the input and expected result, so a later scheduled failure can be compared against a known good baseline.

  2. Check the project for the cron feature

    Decide whether you need one schedule or several. A schedule set directly on the Bot's edit form is enough for a single job. If you need the same Bot to run on more than one schedule, or under different identities or inputs, you need a Cron resource, which requires the cron project feature. Ask your Medplum administrator to confirm the feature is enabled in the target project. The check is complete when you can see the project features and confirm the feature is on or have a request open to enable it.

  3. Set the schedule on the Bot

    For a single schedule, open the Bot's edit form in the Medplum App and enter the cron expression in the schedule field, then save. Write the expression according to the format in the cron jobs for Bots documentation, and confirm the time zone and value against that page before saving. Confirm the setting persisted by reopening the Bot and checking that the expression is still present. This step produces a Bot with a schedule, but no separate Cron resource is required.

  4. Create the Cron resource for multiple schedules

    If you chose the Cron resource path, create one Cron resource per schedule and link it to the Bot. Each resource holds its own schedule, the identity the Bot runs as, and the input it receives, so one Bot can serve several jobs without copying its code. Keep the list of Cron resources in version control or a change record, so reviewers can see which schedules exist. The step is complete when each Cron resource appears in the project and points to the correct Bot.

  5. Choose the identity and inputs for each schedule

    Decide which identity each scheduled run uses and what input it receives. Check that the identity has only the access policies the job needs, and that any secrets the Bot reads are available in the same project. Write the input as a fixed value that matches your manual test, and avoid input that depends on a person being logged in, since scheduled runs have no interactive user. The check is complete when a reviewer can name the identity, the input and the data the job can read or change for each schedule.

  6. Run a test and watch the first scheduled execution

    Trigger the schedule in a test project, or set a near-term expression if your environment allows it, and wait for the first scheduled run to occur. Confirm that the Bot executed, that its output matches the manual baseline, and that no unexpected records were created or changed. If the run fails, check the Bot's logs and the identity's permissions before changing the schedule. The step is done when one scheduled run completes with the expected result.

  7. Verify the run appears in monitoring

    Confirm that each scheduled execution is recorded where your operations team will look for it, using the audit and logging approach your deployment already uses for Bots. Check that the record shows the Bot, the identity and the time of the run, and that a failed run would be visible to whoever receives alerts. Document the location and the owner of those records. The step is complete when a scheduled run can be found from the monitoring view by someone who did not set it up.

Security risks in scheduled Bot runs

A scheduled Bot runs with no person present, so every risk depends on what the run is allowed to do and who can change it. The cards below cover the identity, secrets, schedule changes and audit trail, each tied to a control you can review in your own deployment.

Identity behind each run

A scheduled run acts as a specific identity, not as a person who clicked a button. Check which Bot membership and access policies apply to that identity, and whether the Bot is set to run as a user whose permissions are broader than the job needs. Confirm the identity and its access policy for every schedule before the first run in production, and record which resources that identity can read and write. Bot access design is covered in the Bot access policies topic.

Cron job docs

Secrets read without a person present

Scheduled Bots often read API keys or credentials to call downstream systems, and nobody is watching when they do. Confirm that each secret the Bot reads is stored as a project secret rather than in code, and that the schedule's project cannot read secrets belonging to another environment. Secret storage, separation and rotation are covered in the managing secrets topic, so review those controls here only as they affect scheduled runs.

Who can change a schedule

Anyone with permission to edit a Bot can change its cron expression, and anyone who can edit a Cron resource can change its schedule, identity or inputs. A changed input can point a job at a different population of records or a different endpoint without changing any Bot code. List the accounts that can edit Bots and Cron resources in each project, and confirm that schedule changes go through the same review as code changes.

Inputs that change run behavior

Each Cron resource supplies its own input to the Bot, so one Bot can behave differently across schedules. Treat inputs as configuration that affects data access. Confirm which inputs are allowed, who approves them, and whether any input carries identifiers or credentials that should instead be resolved from a secret. Write down the expected input for each schedule so a later change is visible against that baseline.

Audit trail for schedule changes

Scheduled runs leave evidence only if your deployment records both the executions and the changes made to schedules. Confirm that AuditEvent records capture Bot executions and that edits to Bot schedules and Cron resources are attributable to a named account. Test this on a non-production project by changing a schedule and checking the resulting audit trail before you rely on it. Monitoring details are covered in the monitoring and debugging topic.

Monitoring scheduled runs and catching missed or failed jobs

A scheduled Bot has no user waiting for its result, so the team has to confirm each run after the fact. Start by deciding who owns each schedule: the person or group who gets paged when a run fails, who decides whether a missed run is a problem, and who can change the schedule or its input. Without a named owner, a job that stops running can go unnoticed until a downstream report, claim or sync is found to be stale. Record that ownership alongside the Bot and each Cron entry, including the identity it runs under, since that identity determines which data the run can reach.

To confirm a run happened and what it produced, use the Bot's execution records and its logging, as described in the monitoring guidance your team maintains for Bots. For each schedule, check that a run occurred at the expected time, that it finished with a success status, and that the output matches what the Bot was meant to write. Check the output against the data itself, not only the status, because a Bot can complete without error and still process nothing. Note which fields in the input identify the schedule, so a run started by one Cron entry can be told apart from another run of the same Bot.

When a run fails or never starts, you need an alert that reaches the owner and enough context to act on it. Define the failure condition for each schedule, including a run that does not appear within its expected window, not only a run that throws an error. Decide how the owner is notified and how quickly a failed job must be re-run or escalated. The mechanics of setting alerts and tracing a failing run back to its input belong in the monitoring and debugging topic. Test the path end to end by forcing a failure in a non-production project before relying on the alert in production.

Limits to confirm before you schedule Bots

Scheduled Bots depend on features, settings and capacity that vary by plan and deployment. The cards below list the questions to settle with Medplum or check in your own environment before you move a cron schedule into production.

Cron project feature availability

A separate Cron resource, which lets one Bot run on several schedules under different identities and inputs, requires the cron project feature. Confirm whether that feature is enabled on your Medplum plan or self-hosted deployment before designing around multiple schedules. If it is not enabled, plan for one schedule per Bot set on the Bot's edit form.

Cron jobs docs

Schedule format and time zones

Ask Medplum which cron expression syntax the current docs accept and how run times are evaluated across time zones and daylight saving changes. A schedule written for one zone can fire at an unexpected local hour for a clinic or lab in another. Test the expression against the documented behavior, and record the zone your organization uses for reporting.

Overlapping runs

Confirm what happens when a run is still executing when the next scheduled time arrives. Ask whether the platform queues, skips or starts a second concurrent execution. Overlap can duplicate writes to Patient, Task or Observation resources if the Bot is not written to be idempotent.

Behavior after a server upgrade

Check whether schedules, Cron resources and their identities survive a server upgrade unchanged, and whether any runs are missed or duplicated during the restart window. Medplum requires self-hosted servers to be upgraded through each minor version in sequence, so include scheduled Bots in your upgrade test plan and confirm the expected state after each step.

Rate limits and capacity

Ask how scheduled executions count against API rate limits, Bot execution capacity and database load on your deployment. Several schedules that fire at the same minute can compete with interactive users and integrations. Confirm the limits that apply to your plan and size your schedules and staggered start times from those numbers.

Run identity and audit trail

Confirm which identity each scheduled run executes under and where its activity is recorded. The Cron resource lets you assign different identities per schedule, so verify the access policies on each identity before enabling it. Then confirm that run records are retained long enough for your audit and investigation needs.

How much effort and cost does scheduling Bots take?

What drives the effort of a Medplum Bot scheduling project?

The effort depends mostly on how many schedules you need, how many Bots they call, and how much the surrounding environment must be designed before the first run. A single Bot with one cron setting on its edit form is a small task. Ten schedules across several Bots, each running under its own identity with its own inputs, is a larger one because every schedule needs a defined purpose, access boundary and failure path. Other factors include whether the Bots already exist in version control, how the team handles secrets, and how much monitoring the operations team expects from day one.

Can our own team configure cron settings for Medplum Bots?

Yes, for a simple case your team can set a cron schedule directly on the Bot's edit form in the Medplum app. The harder parts are not the setting itself but the decisions around it: which identity the run uses, what data that identity can reach, what input each run receives, and how a missed or failed run is noticed. Teams that already run scheduled jobs and know their Medplum project model usually handle the first schedule without outside help. Teams new to FHIR access policies or to self-hosted operations often ask for a review of those decisions first.

What does the work need from our side?

The project needs named people who can make decisions and provide access, not only time from engineers. Typically this means a Medplum administrator who can create the Cron resources and confirm project settings, someone who owns each Bot's business logic, a security contact who approves the identities each schedule uses, and an operations contact who will receive alerts. You will also need access to the self-hosted environment, its logs and its secrets store, and a non-production project where schedules can be tested before they touch live data.

How long does it take to validate a first schedule?

The validation period depends on how often the schedule runs, how quickly your team can observe a run, and how many outcomes must be checked. A schedule that runs hourly gives you more chances to observe behavior than one that runs monthly, and a Bot that writes data needs checks on the written resources as well as on the run log. No duration has been set here. Ask the implementation partner to state the validation steps and the observation window in the written scope, and confirm how your change process approves moving a schedule into production.

What recurs after a scheduled Bot goes live?

Most of the recurring work comes from change rather than from the schedules running by themselves. Bot code changes, Medplum server upgrades, rotation of credentials used by the Bots, and changes to who should be able to edit a schedule all require review. Monitoring also needs ongoing attention, because alert thresholds and expected run times drift as data volumes grow. If you keep the work in house, plan for these recurring tasks in your operations calendar. If you engage a partner, the scope should state whether upgrades, rotation and monitoring tuning are in the retainer or in separate work.

How do the self-hosted environment and security design change the cost?

A self-hosted deployment adds work that a hosted service would handle for you. Your team or partner must confirm how the Medplum server, its database and cache are run, how logs reach your monitoring tools, and how secrets are stored and rotated. Identity design also adds cost when each schedule needs its own identity with narrow access, because each identity must be created, tested and reviewed. Compliance expectations can add evidence work. Medplum's compliance documentation describes compliance as a shared responsibility between Medplum and its customers, so confirm which parts of the schedule design fall to your team.

What should a quote for scheduling Bots include?

A useful quote lists the work as separate items you can compare against your own plan. Ask for the list of schedules and the Bot behind each one, the identity and access design for each schedule, the approach to inputs and secrets, the monitoring and alerting scope, the test plan in a non-production project, and the handover of documentation. Ask which items are one-time and which recur, what happens if the scope grows after you sign, and what your team must provide. Ask for the assumptions behind the quote, such as the number of environments and the Medplum version in use, so you can check them against your deployment.

Does a fixed-scope engagement cover ongoing schedule changes?

A fixed-scope engagement covers the schedules, Bots and deliverables agreed in writing before work starts. Adding a schedule, changing a Bot's inputs, or moving to a new identity after go-live is usually new scope unless the agreement says otherwise. Ongoing support, upgrades and continuous testing are available as retainers, which suit teams that change schedules often. Before you sign, ask how changes are requested, priced and approved, and whether the retainer covers monitoring reviews as well as code changes.

How DeployOpen scopes and delivers scheduled Bot work

DeployOpen plans, implements and hands over scheduled Medplum Bot work inside infrastructure you control, starting from a written scope. The work covers which Bots run on a schedule, which identities and inputs each schedule uses, and how scheduled runs are monitored after go-live.

How we scope

  • Inventory every job that should run on a timer, with its business owner, expected frequency and failure impact
  • Decide per job whether a cron setting on the Bot is enough or a Cron resource is needed for several schedules
  • Agree in writing which project, identity and input each scheduled run uses before any build starts

How we build

  • Configure Bot cron settings and Cron resources in the development project first, then promote them through your release path
  • Test each schedule against the expected identity, access policies and inputs, including runs that fail on purpose
  • Confirm that the cron project feature is enabled in the target project before Cron resources are created

How we hand over

  • Document each schedule, its Bot, inputs, identity and owner so your team can change it without guessing
  • Walk your operations staff through checking scheduled runs in AuditEvents and the failure alerts you chose
  • Record a runbook for pausing, rescheduling and re-running a job after a missed or failed execution

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts
  • Ongoing support, upgrades and continuous testing are available as a retainer, including retesting after Medplum upgrades
  • Ask any quote to separate one-time build work from recurring monitoring and support

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.