Temporal batch operations from the CLI

Temporal batch operations from the CLI let operators signal, cancel, terminate or reset many workflows selected by a visibility query. This page covers how to scope, run and track them safely.

On this page

Temporal batch operations from the CLI: when one change has to reach thousands of workflows

When a bug fix, a bad deploy or a downstream incident leaves thousands of workflows in the same state, acting on them one at a time stops being practical. A CLI batch job solves this by applying one operation to every workflow that matches a visibility query. The four operation types are signal, cancel, terminate and reset. Signalling sends a message into running workflows so their code can change course, cancelling asks workflow code to stop and clean up, terminating ends executions immediately without giving workflow code a chance to run, and resetting moves executions back to an earlier point in their history so they can replay with fixed code. Teams reach for batches when the affected population is large, when the matching rule is clear (for example, one workflow type, one task queue or one failure type), and when doing the same action by hand would take longer than the incident window allows.

Every batch depends on visibility. The query that selects workflows is evaluated by the advanced visibility store, so the batch can only target what that store has indexed, and the results can lag behind current state. Confirm which visibility backend your server uses and how far behind it runs before you trust a count. Also confirm the exact batch subcommands, flags, query syntax and job-tracking commands in the Temporal CLI documentation for your server version, because these have changed across releases and should not be copied from older runbooks. Start with a query that returns a small known set, check the matched count against what you expect, and record the query and the operator who ran it.

Before you start, decide which operation the situation actually needs. Signals and cancellations depend on workflow code handling them, so a batch of signals is only safe if every matched workflow version knows how to react to it. Terminations are irreversible for the affected executions and skip cleanup, so they suit only workflows whose side effects are already handled. Resets preserve work but must use the right reset point for each workflow, which a single batch rule may not give you. Track batch job progress with the CLI or the Web UI, watch for failures in the job, and plan a verification query afterwards that shows the expected end state. Pause the batch, or narrow the query, if the downstream system it affects starts to degrade.

Which batch operation fits the change: signal, cancel, terminate or reset

This table compares the four Temporal batch operation types by what they do to a workflow, whether workflow code can clean up, what they leave in history and the usual trigger. Read each row against the change you need to make, then confirm the history effects in the Temporal documentation before running a batch on production namespaces.

OperationWhat it does to each workflowWorkflow code gets a chance to clean upWhat it records in historyTypical trigger and fit
SignalDelivers a named signal with an optional payload to each matched workflow; the workflow keeps runningYes, the workflow code reads the signal and decides what to doA signal event is added to each workflow's historyRelease workflows waiting on an external event, such as a batch of approvals that have now been granted
CancelRequests cancellation; the workflow receives a cancellation request at its next cancellation pointYes, cleanup and compensation run in workflow code before the workflow endsA cancellation request event, followed by whatever the workflow records as it winds downGraceful shutdown of work no longer needed, where compensating steps must run
TerminateStops each workflow immediately without running workflow codeNo, workflow code does not run and no cleanup happensA termination event closes the history; in-flight activities are not given a chance to finishStuck work that cannot finish or make progress, after you have confirmed that no cleanup is needed
ResetMoves each workflow back to an earlier point in its history and replays forward on the new codePartly, replay runs the corrected workflow code from the reset pointHistory after the reset point is kept in the original run but is no longer used by the new run; confirm the exact behavior in the docsResuming work after a bug fix in workflow code, when the failed or wrong path should be rerun
Signal fit checkLow risk when the workflow handles the signal idempotentlyNot applicableAdds events, so it can change how workflows that already ended are handledUse a signal only when the target workflow code is known to handle that signal name and payload
Cancel fit checkSafe for long-running work with compensation logic that has been testedRequired for compensation to runCancellation is visible in history and metrics for later auditAvoid when the workflow is blocked in code that never reaches a cancellation point
Terminate riskLoses in-progress state for that run and any pending workNot applicableTermination is the stop action you would record in an incident or change logConfirm there is no external side effect that needs manual repair after the run stops
Reset riskCan rerun side effects if activities are not idempotentDepends on the reset point chosenChanges how the run continues; confirm history and visibility effects in the Temporal docs firstChoose the reset point carefully and test it on a small set before a batch run

How a batch job selects workflows and reports progress

The operator starts by writing a visibility query, which runs against the visibility store and not the workflow history itself. The matched set comes back for review, and nothing is changed until the operator approves it. Only then is the batch job submitted to the Temporal Service, which applies the chosen operation to each workflow. Check the job's progress and failed executions before assuming the batch is complete.

Batch path from visibility query, through a review gate, to the Temporal Service.

How visibility queries decide which workflows a batch touches

The target set of a Temporal batch job is whatever the visibility query returns at the moment the job runs, so the query is the blast radius of the operation. A query such as a WorkflowType filter combined with ExecutionStatus = "Running" is evaluated once, the matching workflow IDs are collected, and the signal, cancel, terminate or reset is applied to that set. Anything that starts, stops or changes status between your review and the run can be swept in or left out. Treat the query text as the change under review, not the command that follows it.

The advanced visibility store decides what the query can see and how fast it answers. Temporal's visibility docs recommend Elasticsearch or OpenSearch for anything beyond a few workflow executions, and list the versions supported by each server release, so confirm the backend and its version against the Temporal visibility documentation before you rely on a query for a large population. Search attributes shape the query further: a custom attribute that is not registered, or is registered with a different type than the one you filter on, will not match what you expect. Ask the platform owner to list the search attributes in each namespace and to confirm how time-based and status filters behave on your version.

Before any batch operation is submitted, run the same query as a count and sample a handful of returned workflow IDs. Compare the count with what the business owner expects, check that the sample contains only the workflows you intend to change, and record the query text and count in the change ticket. This dry run is cheap compared with a terminate that cannot be reversed. Also confirm the query is bounded by time or workflow type, so a broad filter on a busy namespace does not reach workflows that were never part of the incident.

Running a batch job safely from the CLI, step by step

This sequence takes a batch operation from a confirmed cause to verified results, with a check at each step so the team can stop before a bulk change reaches workflows it should not touch.

  1. Confirm the cause and the target operation

    The on-call engineer or workflow owner states the root cause in one sentence, names the single operation needed (signal, cancel, terminate or reset) and lists which workflow types and namespace are affected. A second person reviews this statement before any query is written. Done means the operation is written down with its reason, the owner who approved it and the namespace it targets. Ask your team to confirm exact operation semantics against the current CLI reference, since termination and reset behave differently in workflow history.

  2. Write and count the visibility query in a non-production namespace

    Write the visibility query that selects the affected workflows, using workflow type, status, start time and custom search attributes where they exist. Run it first against a non-production namespace that holds comparable data, then against production as a count-only query with no batch action attached. Compare the count with the number the owner expected from the incident. Done means the expected count matches the actual count, or the difference is explained. Visibility data can lag behind live state, so confirm the index behind the query is healthy before trusting the count.

  3. Capture an export of the affected workflow list

    Save the list of matching workflow IDs and run IDs to a file that the change record references, and record the query text and the time it ran. Where workflow inputs or state matter for recovery, export the event history for a sample or for all matches, according to your retention and data handling rules. Done means the file exists, its row count matches the count from the previous step, and it is stored where the on-call team and auditors can reach it. This export is the main recovery reference, because a batch action that has run cannot be undone by the batch job itself.

  4. Test the operation on a small sample

    Pick a small, representative subset of the exported list, such as a few workflows from different states, and run the same operation on that subset as a single-workflow command or a small batch. Describe each sampled workflow afterwards and check its status, pending activities and history against what the operation should produce. Done means every sampled workflow shows the expected result. If any sample behaves differently, stop and investigate before scaling up. Note whether the operation can be reversed for these workflows, since that decides how much risk the full run carries.

  5. Submit the batch job with a reason and identifier

    Start the batch job with the same query used in the count, the chosen operation, a reason string that points to the change record, and a unique job identifier. Use the rate and concurrency settings your team has confirmed against the CLI reference and your service capacity, rather than defaults you have not reviewed. Done means the batch job reports as accepted with the identifier recorded in the change record. Record who submitted it, because the reason and identity appear in workflow history for each affected workflow.

  6. Monitor progress against the expected count

    Watch the batch job status until it finishes, and compare the number of processed and failed workflows with the expected count. Check the Temporal server and worker metrics for unexpected load or error spikes, and pause or stop the job if errors rise or workers degrade. Done means the job reports complete, processed plus failed equals the expected count, and every failure is listed with a reason. Do not start a second batch on the same workflows until failures are understood.

  7. Verify results in the Web UI or with describe commands

    Re-run the visibility query used before the job and confirm that the affected workflows are in the expected state and that none remain in the old state. Sample workflows with describe commands or the Web UI and check the history entries that the operation wrote, including the reason and identifier. Done means the post-run count matches the target, the sampled histories show the expected events, and the failures from the batch job are either fixed or listed for a follow-up change. Close the change record with the job identifier, the exported file location and the verification results.

Tracking batch job progress and catching failures early

A batch job changes many workflows at once, so a small mistake in the query or the operation can spread quickly. Watch five signals together: the job itself, the set of workflows still matching the query, failed operations, worker load, and the audit trail. Confirm each signal in your monitoring setup before you submit the first batch.

Job state and completed count

Read the batch job's state and its completed count with temporal batch describe before you assume the work is done. A job that stays in progress with a flat completed count usually means operations are failing or throttled, not that the job is slow. Compare the completed count with the number of workflows your query matched when you submitted the job. If the two diverge without explanation, pause and inspect a sample of workflows before letting the job continue. Confirm the batch job fields your CLI version reports, and whether your dashboards show batch progress at all.

Workflows still matching the query

Rerun the same visibility query after the job reports completion. If workflows still match, the query may have caught new executions that started during the batch, or the operation may not have taken effect. Visibility data is not always instantly consistent with execution state, so check a few of the remaining workflow IDs directly with temporal workflow describe before you rerun the batch. Keep the query text in the job record so the rerun uses the same filter. Confirm how your visibility store lags behind executions in your deployment.

Failed and erroring operations

Failed operations are the earliest sign that a batch is hitting the wrong workflows or a state it cannot change. Look at the failure count and the reasons attached to them, and group them by message. A cluster of identical errors often means a single workflow type does not accept the signal, reset point or termination you sent. Stop the job if one error type grows faster than the completed count. Confirm where your team sees batch failure counts and whether alerts fire on them.

Worker and task queue load

A batch that signals or resets many workflows generates work for workers, and that work competes with live traffic. Watch the task queue backlog, schedule-to-start latency and worker slot usage for the queues the affected workflows use. A growing backlog during the batch means the job is outpacing your workers, so reduce the rate or add capacity before continuing. Confirm which Temporal metrics your Prometheus or other monitoring setup collects for task queues and worker slots, and set alerts on them before the batch starts.

Self-hosted deployment docs

Submitter, reason and audit record

Every batch should record who submitted it, which query and operation it used, and the reason it was approved. Store that record outside the operator's shell history, in a ticket or change log your security team can review. Check that the Temporal service audit or access logs capture the identity of the caller for batch requests, which depends on how your authorization is configured. Without an Authorizer, the default configuration allows any API request, so confirm the audit trail is tied to real identities before relying on it for review.

Self-hosted security docs

Batch patterns by incident situation

When a dependency such as a payment API or database was down, many workflows may be waiting on activities that kept retrying. In this case the work is usually not broken, so the batch should not terminate or reset it. Start by confirming the outage has ended and the activities can succeed, then decide whether the waiting workflows should continue unchanged or need a targeted signal.

  • Query first: filter by ExecutionStatus = "Running" and the workflow type affected, then compare start times with the outage window to size the group.
  • Prefer no change: if retries will complete on their own, leave the workflows alone and watch the failure trend instead of signalling them.
  • Signal only when needed: use a batch signal only where workflow code is written to wake up on a specific signal, and confirm that name in the code first.
  • Watch retry pressure: a large signal batch can flood workers at the moment the dependency recovers, so confirm worker capacity before starting.
  • Verify after: sample a few executions per affected type and confirm the activities advanced and the workflows completed.

Before starting any batch, confirm the batch targets only the workflows you intend to change.

Who can run batch operations and how to control it

Batch termination and reset act on many workflows at once, so the access path to the Temporal frontend matters more than it does for a single command. The cards below cover the server settings, network placement and audit trail that decide who can submit a batch job and whether that submission can be traced.

Default authorizer allows every request

If no Authorizer is configured, self-hosted Temporal uses the noopAuthorizer, which allows every API request with no authentication or access control. A batch termination or reset submitted through the frontend would then be open to anyone who can reach it. Before running any batch job in a shared environment, confirm which Authorizer is set in the server configuration and test that an unauthorized caller is refused.

Security docs

Authorizer plugin for batch permissions

An Authorizer plugin decides whether each API call is allowed. Batch operations call the same API as single-workflow commands, so the permission model you set for signalling, cancelling, terminating and resetting governs batch jobs too. Map each batch operation to a role your team can explain, and confirm the exact role each one requires in the security docs before you write the policy.

Authorizer details

ClaimMapper maps identities to namespace roles

A ClaimMapper reads JWT or certificate claims and maps them to namespace roles that the Authorizer then checks. Operators who run batch jobs should hold roles scoped to the namespaces they need, not a global administrator role. Review which claims your identity provider issues, keep the mapping in version control, and test with a non-production user that a batch job in another namespace is refused.

mTLS on frontend traffic

Self-hosted Temporal supports mutual TLS with separate settings for internode and frontend traffic. Requiring client certificates on the frontend means only callers holding a trusted certificate can reach the API that batch commands use. Plan certificate issuance, rotation and revocation for the people and automation that run batch jobs, and confirm the frontend TLS settings match your certificate authority before go-live.

Keep services off the public internet

The Temporal deployment docs say services should run on hosts not reachable from the public internet, with network access restricted to trusted internal networks. A reachable frontend weakens every other control in this section, including mTLS and the Authorizer. Confirm that the frontend address used by CLI operators sits on an internal network, that jump hosts or VPN paths are documented, and that firewall rules are reviewed after each change.

Audit trail for each batch submission

Record who submitted each batch job, which query selected the workflows, the reason and the time. Temporal's own event history shows what happened to each workflow, but it does not by itself tie an action to a named person or change ticket. Store CLI invocations and their batch job IDs in your central logging, and require a reference such as an incident or change number in the job description so auditors and responders can reconstruct who did what.

What to confirm in your environment before a batch touches production

A batch job is only as safe as the visibility query that selects its targets, so confirm that your visibility store returns complete results before anything runs against production. Run the exact query you plan to use in a non-production namespace and compare the matched count with what you expect from the Web UI or a direct count. Check the advanced visibility backend against the Temporal visibility docs, because the supported stores and minimum versions differ and Elasticsearch or OpenSearch is the recommended option beyond a few workflow executions. Lagging or partial indexing is the most common reason a batch hits the wrong set of workflows, so record the indexing delay you observe and plan around it.

Next, decide who can submit a batch and who can approve one. Self-hosted Temporal uses the default noopAuthorizer when no Authorizer is configured, which allows every API request, so a batch submitted by any user with network access can terminate or reset executions across namespaces. Confirm that an Authorizer and ClaimMapper are in place for the namespaces involved, that only a named operator role can start signal, cancel, terminate or reset batches, and that the audit trail records the operator identity for each job. Rehearse the full sequence (query, dry count, small batch, progress check, rollback) on a non-production namespace first, and confirm that the server and visibility versions in that rehearsal match production. Version support should be checked against the Temporal server upgrade guide before any change window.

Before submission, write down the recovery path for each operation type. Termination and reset cannot be undone by the batch itself, so the record should state how affected workflows will be resumed or repaired, who owns that work, and how long the team can wait before escalating. Confirm that workers on the relevant task queues are healthy, with free capacity and no backlog, because a batch of resets or signals creates a burst of workflow tasks that can overload them. Finally, open a change record that names the query, the target count, the operation, the approver, the start and stop criteria, and the rollback owner. Attach the rehearsal results so the approver can see what happened on the non-production namespace.

Limits to confirm before you rely on CLI batches

Batch jobs look simple on a command line, but their reach depends on the visibility store, the rate limits on your service and what history the cluster still keeps. The cards below list the points to confirm in the Temporal CLI reference, the visibility docs and your own load tests before you rely on a batch for production work.

Maximum workflows per batch

Confirm how many workflow executions a single batch job can select and act on, and how the job pages through the matching set. A batch built from a visibility query can miss executions if the query returns more results than the job reads in one pass. Ask the question for your exact CLI version, then run a dry query against a staging namespace with a known count and compare the processed total with that count.

Visibility docs

Pausing, cancelling and resuming jobs

Confirm whether a running batch job can be paused, cancelled or resumed. Operators often need to stop a batch that is hitting a downstream outage or the wrong set of workflows. Check the CLI reference for the batch job controls available in your version, and test how a stopped job reports the executions it already changed so you know exactly where a partial run left off.

Visibility lag behind workflow state

Visibility records are written separately from workflow history, so a query can return executions that have already changed state or omit ones that just started. Confirm how far your visibility store can lag under load and whether your batch selects by status, start time or custom search attributes. Re-run the query after a short wait and compare results before you signal or terminate anything.

Visibility docs

Rate limits and worker capacity

A batch that sends signals or cancellations at full speed can saturate the frontend, the history service and the task queues that your workers poll. Confirm the request rate your namespace and service accept before a large run, and check that workers have enough slots to process the resulting tasks. Watch task backlog and error rates during a pilot batch on a small subset.

Retention effects on closed workflows

Closed executions are removed once the namespace retention period ends, so a batch that targets older workflows may find nothing to act on, or may act on a partial record. Confirm the retention setting for each namespace, and decide whether a reset or signal makes sense for executions near the end of that window. Check the retention behavior in your environment before you schedule a cleanup job.

Questions teams ask before running Temporal batch operations

Can our own team run Temporal batch operations without outside help?

Yes, if the team already operates a Temporal deployment and has engineers comfortable with the Temporal CLI, visibility queries and namespace access. The work needs a clear understanding of workflow types, search attributes and how each batch action changes workflow history. Teams with that background usually handle routine batches in-house, while teams new to Temporal benefit from a dry run on a non-production namespace first. Ask the team to confirm which engineers can run batches, who approves them and whether they have tested a reset or termination in a lower environment.

What drives the effort of a Temporal batch job?

Effort depends on four factors: the complexity of the visibility query that selects the workflows, the visibility backend in use, the number of workflow types involved, and how much review and audit evidence the change requires. A simple query on one workflow type is quick to define and verify. Selections that span several workflow types, rely on custom search attributes or must be reviewed before execution add preparation time. Visibility backend limits also matter, because Temporal recommends Elasticsearch or OpenSearch for anything beyond a few workflow executions, so confirm which store your deployment uses before planning.

Does a batch job cost more on self-hosted Temporal or Temporal Cloud?

The cost structure differs. On self-hosted Temporal, you pay for the infrastructure, the persistence store, the visibility store and the staff who run them, and batch jobs add load to all of these. On Temporal Cloud, pay-as-you-go pricing starts at 50 US dollars per million actions, with active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour, according to the Temporal Cloud pricing page. Because actions and storage vary with the number of workflows touched, ask your team to count the affected workflows and any signals or history events the batch will generate before estimating its cost.

How long does a Temporal batch take, and what controls the duration?

Duration depends on how many workflows match the query, the batch rate that the CLI runs at, the load the batch places on the frontend and history services, and the health of the visibility store. Batches that run during a quiet period and against a well-sized cluster finish faster than those competing with peak traffic. Track progress through the batch job's status while it runs and watch service latency and error metrics. Ask the team to test the rate on a sample set before committing to a window, because no fixed figure applies to every cluster.

What must we provide before a batch operation can be scoped?

Provide access to the target namespace with permissions that allow the intended operation, such as signalling, cancelling, terminating or resetting. Share the visibility store details, including the backend type, version and the search attributes you rely on, so queries can be validated. Name the change approver and the rollback owner, and confirm the workflow types and task queues involved. Finally, agree on whether the batch needs an audit record of who selected which workflows and when. Without these inputs, the query and the blast radius cannot be checked accurately.

Which controls should be in place before we run a batch that terminates or resets workflows?

Confirm first that your access model limits who can start batch jobs, because self-hosted Temporal uses a noopAuthorizer by default that allows every API request until an Authorizer is configured. Require a written change approval, a tested query that returns only the intended workflows and a sample run on a lower environment. Plan for the audit trail and for who decides whether a reset or termination should proceed. Teams in regulated sectors should also review these steps against their change management and access control policies.

When should we bring in outside help for Temporal batch operations?

Bring in outside help when batches affect large numbers of workflows, when the visibility store is not yet sized for the query load, when the team has no one who has run a reset or termination at scale, or when the change must be audited to a compliance standard. DeployOpen implements and supports self-hosted open-source platforms in your own infrastructure, and can plan a batch runbook, test queries in a non-production namespace and document the approval steps under a fixed-scope agreement. Scope and cost follow from a written agreement based on your environment.

How DeployOpen works on this

DeployOpen scopes Temporal batch operations from the CLI as a written piece of work, tied to your namespaces, visibility store and runbooks. We build and test the batch procedures in a non-production environment, then hand them over with documentation your operators can run and audit.

How we scope

  • Inventory the namespaces, workflow types and visibility queries that batch jobs would touch in your deployment.
  • Agree which batch actions are in scope, such as signal, cancel, terminate or reset, and who approves each one.
  • Confirm the visibility store your Temporal Server uses, since query behavior depends on it, before any job is designed.

How we build

  • Write and version the CLI batch commands and query filters, with a dry-run count step before any action runs.
  • Test each batch job against a staging namespace seeded with representative workflows, including failure and partial-completion cases.
  • Set up progress tracking for each batch job so operators can see completed, failed and remaining executions.

How we hand over

  • Deliver a runbook covering each batch command, its query, its preconditions and the rollback or recovery steps.
  • Document the approval steps, the audit trail expected from each job and the access needed to run it.
  • Walk your operators through a supervised run in staging so they can repeat the procedure without us.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, Temporal Server upgrades and continuous testing are available as retainers after handover.
  • Changes to the batch procedures are reviewed against your Temporal version and visibility configuration before rollout.

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.