Rules

Create Rule

POST
/v1/households/{household_id}/rules

Creates a transaction rule at the top of the household's priority list. All set criteria must match; a rule with no criteria matches nothing.

Set apply_to_existing: true to run the rule over existing visible transactions and return applied_count; otherwise, existing transactions stay as they are. Manually locked categories and merchants are never overwritten, and tag actions add to existing tags. Referenced accounts, categories, merchants, and tags must belong to the household. amount_filter.currency defaults to the household's currency when omitted.

Authorization

PersonalApiToken
AuthorizationBearer <token>

Personal API token (penny_pat_…). Paste only the token; the Bearer prefix is added automatically. Read-only tokens only allow read requests, and read/write tokens follow your current household membership and role. See https://penny.finance/docs/api#authentication.

In: header

Path Parameters

household_id*string

ID of the household that owns the resource. GET /v1/households lists the households you can access.

Request Body

application/json

filter_uncategorized?boolean

Whether the rule only matches transactions that have no category. A rule with this criterion is a fallback: it runs after all other rules, only when none of them assigned a category, and only fills in actions that no other rule took.

Defaultfalse
account_ids?array<string>|

Only match transactions on one of these accounts. Omit it, or send null or [], to match any account. Deleted accounts' transactions are skipped by dry runs and apply_to_existing, though transactions synced while deleted still run through rules. Saving a rule rejects a deleted account it doesn't already have.

merchant_ids?array<string>|

Only match transactions assigned to one of these merchants (transactions without a merchant never match). Omit it, or send null or [], to skip this check. A deleted merchant matches nothing, and saving rejects one the rule doesn't already have.

category_ids?array<string>|

Only match transactions currently in one of these categories (uncategorized transactions never match). Omit it, or send null or [], to skip this check. A deleted category matches nothing, and saving rejects one the rule doesn't already have.

amount_filter?|

Only match transactions on the given side (income or expense) whose amount passes the comparison. Omit it or send null to match any direction and amount.

classifications?array<>|

Only match transactions whose classification is one of these values (transactions without one never match). Omit it, or send null or [], to skip this check.

name_conditions?array<>|

Only match transactions whose name matches at least one of these conditions. Omit it, or send null or [], to skip this check.

set_category_id?|

Category action: the category assigned to matching transactions. null leaves the category alone. A category set directly on a transaction is never overwritten, and when several matching rules set one, the highest-priority rule wins. A deleted category is never assigned, and saving a rule refuses one the rule doesn't already have.

set_merchant_id?|

Merchant action: the merchant assigned to matching transactions. null leaves the merchant alone. A merchant set directly on a transaction is never overwritten, and when several matching rules set one, the highest-priority rule wins. A deleted merchant is never assigned, and saving a rule refuses one the rule doesn't already have.

apply_tag_ids?array<string>|

Tag action: tags added to matching transactions. Existing tags are kept, and the tags of every matching rule are combined. null or [] adds none. A deleted tag is never added, and saving a rule refuses one the rule doesn't already have.

set_hidden?boolean

Whether the rule hides matching transactions, which takes them out of regular lists and totals. false takes no action: a rule never unhides a transaction.

Defaultfalse
set_needs_review?|

Whether the rule changes a matching transaction's needs_review flag: true flags it for review, false clears the flag, and null leaves the flag alone. When several matching rules set it, the highest-priority rule wins.

apply_to_existing?boolean

Whether to also apply the saved rule to the household's existing transactions, skipping hidden and deleted ones; the response reports how many as applied_count. Only this rule is evaluated, so it takes effect even where a higher-priority rule would otherwise win. When false, the rule only affects transactions created or changed afterwards.

Defaultfalse

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.penny.finance/v1/households/Hh4vK8pQ2sLm/rules" \  -H "Authorization: Bearer $PENNY_API_TOKEN" \  -H "Content-Type: application/json" \  --data-raw '{}'
{  "id": "Rl9cF3nV7sQa",  "priority": 1,  "account_ids": [    "Ac7kP2mN9qRs"  ],  "deleted_accounts": [],  "merchant_ids": null,  "deleted_merchants": [],  "category_ids": null,  "deleted_categories": [],  "amount_filter": {    "currency": "USD",    "direction": "expense",    "operator": "between",    "value": "20.00",    "value_upper": "200.00"  },  "classifications": [    "FOOD_AND_DRINK_GROCERIES"  ],  "name_conditions": [    {      "pattern": "trader joe",      "mode": "contains"    }  ],  "filter_uncategorized": false,  "set_category_id": "Ct5nR8wY1jFu",  "set_merchant_id": null,  "apply_tag_ids": [    "Tg8qN1cK5rWd"  ],  "deleted_tags": [],  "set_hidden": false,  "set_needs_review": null,  "applied_count": null}