Create categorisation rule

POSThttps://app.speybooks.com/api/v1/categorisation-rules/

Creates a new categorisation rule. If a rule with the same field, operator, and value already exists, its target account is updated rather than creating a duplicate (upsert semantics).

For description rules the value is normalised before storage (uppercased, common bank prefixes stripped, trailing digits removed), which improves matching against varying bank formats.

Each organisation is limited to 100 rules.

Body parameters

fieldstringrequired
Transaction field to match against (description, contact_name, amount, reference, or metadata.* fields).
descriptioncontact_nameamountreferencemetadata.categorymetadata.projectmetadata.departmentmetadata.tag
namestringrequired
Rule display name (1-100 characters).
operatorstringrequired
Match operator (contains, equals, starts_with, ends_with, greater_than, less_than, regex).
containsequalsstarts_withends_withgreater_thanless_thanregex
targetAccountIdstringrequired
Target account ID (e.g. acc_4000). The account transactions will be categorised to when this rule matches.
valuestringrequired
Value to match (1-500 characters). Description values are auto-normalised. Regex patterns are validated.
activebooleanoptional
Whether the rule is active. Default true.
descriptionstringoptional
Optional rule description (max 500 characters).
priorityintegeroptional
Rule priority (0-999). Higher priority rules are evaluated first. Default 0.

Response

201Rule created (or upserted if same field+operator+value exists). Returns rule details with resolved account.
Show response fields
activeboolean
fieldstring
idinteger
namestring
operatorstring
priorityinteger
targetAccountCodestring
targetAccountIdstring
targetAccountNamestring
valuestring

Error codes

400Validation error: invalid regex, invalid account ID, or organisation rule limit reached (100).
404Target account not found.