Apply a Rule to Existing Transactions
Rules normally run on new transactions only. You can also apply a rule to transactions you already have, to fix history in one step. This is a deliberate action: it only works on a set you have just previewed, it leaves reconciled transactions alone unless you say otherwise, and you can undo the whole run.
You can apply a rule from the rule editor in the app, through the Budget Thing API, and from AI assistants connected with the Budget Thing MCP server.
Apply from the rule editor
- Open a saved rule and expand Test on past transactions.
- Optionally pick an account and a date range, then select Run test.
- Check the examples. If the rule would change anything, the button reads Apply to these N transactions. It applies exactly what you previewed, with the same account and dates. Change the rule or the filters and you need to run the test again. The button is only available for a saved rule with no unsaved changes, so save first, then reopen the rule to apply exactly what you saved.
- One apply changes at most 500 transactions (see what gets changed). When more would change, the button never promises more than one run does, for example Apply to the first 500 of 1,200 transactions, and a note says the rest need another run.
- If some of the changes would touch reconciled transactions, a checkbox Also change reconciled transactions appears, off by default. N counts only the transactions that will actually change, so it goes up when you tick it.
- Select the button. The editor waits while the run finishes in the background, then shows the result. If the run is slow, the result says it is still finishing and shows what it has changed so far; a run that stopped early says so, keeps its changes and can be undone. The result shows how many transactions were changed and how many were left unchanged (reconciled, or splits that kept their category). If more are still to change, it says N more still to change. Run the test again and apply to continue.
- To reverse a run, select Undo on that run in the result. Every run from this editor session stays in the list, newest first, each with its own Undo, so a large rule applied in several runs can be put back run by run. Undo stays available if you run the test again, but only until you leave the editor; after that, undo through the API or an AI assistant instead.
Apply all your rules at once
Through the Budget Thing API you can also run every enabled rule over your existing transactions in one go, instead of one rule at a time. This is useful after an import, when you want your whole rule set to clean up history the way it would have cleaned new transactions.
POST /v1/workspaces/{workspaceID}/transaction-rules/preview-all-existingreports what the rules would change (read-only), andPOST /v1/workspaces/{workspaceID}/transaction-rules/apply-all-existingapplies it. Like applying one rule, the apply answers at once with the run and finishes in the background; check itsstatuswithGET .../transaction-rules/runs/{runID}. Both take the same optionalaccountId,dateFrom,dateToandincludeReconciledfilters, so what the preview reports (wouldApply) is what the apply does.- The rules run in the order shown on the Rules page, exactly as they do on an import: every matching rule applies, a rule set to overwrite only when empty leaves a filled-in field alone, and a rule set to stop processing keeps the rules after it from running on that transaction. A rule your plan doesn't include is skipped, as on an import.
- It is one run with one undo. Each field a rule changed is recorded in that rule's History (marked Applied to existing transactions). When two rules set the same field, the one that ran last gets the credit.
- Everything in What gets changed below holds as well: the
newest 5,000 transactions, at most 500 changed per run (apply again for the
rest), reconciled transactions skipped unless you opt in, and no transfers.
Undo with
POST .../transaction-rules/runs/{runID}/undo; a transaction changed by several rules counts once in the undo result. - Applying needs the same
transaction-rules:writeandtransactions:writescopes as applying one rule, and the preview needstransaction-rules:read. AI assistants apply one rule at a time.
What gets changed
An apply examines exactly what the preview does:
- the newest 5,000 transactions that fit the filters (optionally one account and a date range), newest first. When more fit, the result says it was truncated; narrow the account or dates and run again to reach older ones,
- never transfers, and never the category of a split transaction (any other change to a split transaction is still made). The Split transaction action never touches a transaction that is already split or reconciled,
- only transactions where the rule would actually change a value.
One apply changes at most 500 transactions, and it is undone as one step. When
the rule would change more, the preview's wouldApply shows the full number, the
run's remainingCount says how many are left, and applyLimit shows the cap. Apply the same rule again to
change the next ones: transactions already changed no longer differ, so each
run takes up to 500 more. Each run has its own undo.
It changes the payee, category, memo, tags, needs review flag and cleared status, as the rule's actions say. It never changes an amount, a date or an account.
Changes to payee, category, memo and tags are recorded and announced like a
manual edit, so they appear in the audit log and send transaction.updated
webhooks. The needs review flag is the exception: it isn't part of the
transaction record those carry, so a change to the flag alone (by an apply or
by an undo) sends no transaction.updated webhook and adds no audit-log entry.
The run and its rule history
still record it.
Reconciled transactions are skipped
Transactions that are part of a reconciliation are skipped by default, and the result tells you how many were skipped. Only include them if you mean to: their amount, date and account stay locked either way, but their payee, category, memo and tags change like any other.
Runs finish in the background
An apply, and an undo, don't make you wait for the whole job. Starting one
returns straight away with the run in the status running (undoing for an
undo), and the changes are made in the background in small batches, so the rest
of your workspace stays usable while it works: bank sync and your own edits
wait for one batch at a time, never for the whole run.
Check on a run to see its progress. A run has one of these statuses:
| Status | Meaning |
|---|---|
running | Changes are still being made. appliedCount grows as batches finish. |
completed | Every transaction in the run was handled. |
failed | A batch hit an error, or the run made no progress for 5 minutes (for example the server restarted). It keeps the changes it already made, and you can undo them. |
undoing | An undo is putting changes back. |
undone | The undo finished. |
A few rules follow from this:
- The set is fixed when the run starts. A transaction you add or import
while it runs is never touched. A transaction you edit or delete mid-run is
looked at again just before it is changed: if it no longer matches the rule it
is left alone and counted in
skippedChangedCount. - You can't undo a run that is still
runningorundoing. The request is refused with a409until it finishes. An undo can't be started twice at once either, and a run that was alreadyundoneis refused with a409too. - A failed run can be undone. The undo reverses whatever the run changed before it stopped.
Through an AI assistant, the apply and undo tools wait up to about 20 seconds for the run to finish and then report its status; the assistant checks again until it is done.
Preview first
The preview and the apply take the same rule and filters, so what the preview
reports (wouldApply and wouldSkipReconciled) is what the apply does.
When the preview's wouldApply is more than the applyLimit of 500, an apply
changes the first 500 and you apply again for the rest.
AI assistants can't apply without a fresh preview: the first call returns the
preview and a short-lived confirmation token, and the apply only runs when it is
repeated with that token, within ten minutes, with the same rule and filters.
Undo the whole run
Every apply is one run. Each changed transaction gets a rule application in the rule's History marked Applied to existing transactions, and undoing the run puts every change back in one step.
Split transaction gives each matching single-category transaction its lines, summing exactly to its amount. Undoing the run puts the original single category back, unless you edited that transaction's categories or reconciled it since, in which case it is left as you have it and counted as left alone.
Mark as cleared only clears transactions that are not cleared yet, and never touches a reconciled one. Undoing the run un-clears the transactions it cleared, except any you have reconciled since, which stay cleared and are counted as left alone.
An undo never overwrites your later edits: a field you changed after the run is left as you have it, and the result counts those transactions. A completed or failed run can be undone once.