rule_apply
Applies one or all active categorization rules to posted lines on a suspense or category account; dry run first, then commit atomic, audited, undoable moves.
Instructions
Apply one rule, or every active rule in priority order, to lines already posted on a category or suspense account within from and to. Rules are not applied to asset or liability accounts: those return RULE_STATEMENT_ACCOUNT; use txn_bulk_recategorize for lines sitting on one. A direction condition holds only for a line on the opposite side of the transaction's single bank-side line. Each line moves to the first firing rule's account through the audited recategorize path, then gets the rule's counterparty and project; lines already on the rule's account get only missing actions (actions_only). Lines a guard refuses, such as reconciled or closed-period lines, are left out and listed in blocked. Call with dry_run first and pass its selection_token, which covers each line's rule version, destination and actions. Applies atomically up to 500 selected lines. A move is dated on the line's date, or on the day the line's last move was undone when later (effect.move_date). receipt_id is the first move's receipt, which audit_undo reverses as a unit; with no move there is no batch receipt and no_batch_receipt is actions_only. Undo never removes counterparty links: it lists those made on moved lines in remaining_counterparty_links, not those on actions-only lines; change a link with counterparty_associate. A rule with actions needs counterparty and project access. Propose-only credentials return one pending proposal that freezes the planned moves.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"company": "<company>",
"account": "<account>"
},
"name": "rule_apply"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Last transaction date to match (inclusive). | |
| from | No | First transaction date to match (inclusive). | |
| rule | No | Apply only this rule. Defaults to every active rule in priority order. | |
| account | Yes | Account holding the lines to categorize, usually suspense. | |
| company | Yes | ||
| dry_run | No | Validate the batch and return the matched count, totals and a sample without writing. | |
| on_conflict | No | ||
| selection_token | No | The `selection_token` from a dry run. If a line, its rule version, destination or actions changed, nothing is written and `SELECTION_CHANGED` is returned. | |
| posting_reference | No | Idempotency reference for the batch. Use `on_conflict` "skip" for an exact retry. |