Skip to main content

Using Transaction Rules

Transaction rules empower end users to automatically assign a chosen category to all transactions that match a specific description — even if that category differs from the one assigned by MX's data enhancement. Every past and future transaction which matches the pattern will automatically be assigned to that category.

Rules have a string used to find matching transactions (match_description), a category that the transactions will be put into (category_guid), and an optional description that overwrites the transaction’s original description.

This guide will take you through the process of creating, updating, and deleting a transaction rule.

Step 1

Create a Rule

First, you'll need to create a new transaction rule — but keep a few things in mind:

  • When an end user creates a rule, the MX Platform will find all past and future transactions that match the match_description you provide. The category and description of all matching transactions will then change to those provided by the end user.
  • The end user will decide on the category and optional description.. The category can be either a default MX category (accessible through the list default categories endpoint) or a custom category created by the end user (accessible through the list all categories endpoint). You must determine the best match_description.
  • Matching is always performed between the match_description and the current transaction description. If a transaction's description has been changed, it's the current transaction description that will be compared, not any previous or original description. If a rule updates the description of a transaction, and then you create another rule that matches the updated transaction description, that transaction will be associated with the newer rule — including updating to whatever the new rule's description specifies.
  • If you try to create a rule that has the same match_description as an existing rule on the same user object, a 409 Conflict error will be returned.

Endpoint: POST /users/{user_guid}/transaction_rules

Request
Response
Language:shell

_11
curl -i -X POST 'https://int-api.mx.com/users/USR-11141024-90b3-1bce-cac9-c06ced52ab4c/transaction_rules' \
_11
-H 'Accept: application/vnd.mx.api.v1+json' \
_11
-u 'client_id:api_key' \
_11
-H 'Content-Type: application/json' \
_11
-d '{
_11
"transaction_rule": {
_11
"category_guid": "CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0",
_11
"description": "Wal-mart food storage",
_11
"match_description": "Wal-mart"
_11
}
_11
}'

Automatic Creation

The MX system automatically creates rules under certain conditions. An automatic rule won't be created if the transaction is already associated with an existing rule.

  • If the end user changes either the category or description of similar transactions three times, a rule will be created with the following attributes:
    • match_description will be set to the original transaction description.
    • category_guid will be the category set by the end user.
    • description will be the one set by the end user, if applicable.
Step 2

Update a Rule

End users may want to change something about their rule, such as the category or description. The update transaction rule endpoint accomplishes this.

When updating a rule:

  • When the category_guid or description is updated, all transactions associated with the rule (past and future) will have the change applied.
  • However, updating the match_description has no effect on existing associated transactions; instead, the rule will be applied to future transactions according to the new match_description.

Endpoint: PUT /users/{user_guid}/transaction_rules/{transaction_rule_guid}

Request
Response
Language:shell

_11
curl -i -X PUT 'https://int-api.mx.com/users/USR-11141024-90b3-1bce-cac9-c06ced52ab4c/transaction_rules/UTR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3' \
_11
-H 'Accept: application/vnd.mx.api.v1+json' \
_11
-u 'client_id:api_key' \
_11
-H 'Content-Type: application/json' \
_11
-d '{
_11
"transaction_rule": {
_11
"category_guid": "CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0",
_11
"description": "Wal-mart food storage",
_11
"match_description": "Wal-mart"
_11
}
_11
}'

Step 3

Delete a Rule

To delete a transaction rule, use the delete transaction rule endpoint.

Endpoint: DELETE /users/{user_guid}/transaction_rules/{transaction_rule_guid}

Request
Language:shell

_10
curl -i -X DELETE 'https://int-api.mx.com/users/USR-11141024-90b3-1bce-cac9-c06ced52ab4c/transaction_rules/UTR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3' \
_10
-H 'Accept: application/vnd.mx.api.v1+json' \
_10
-u 'client_id:api_key'