---
title: "Create a transaction rule"
method: POST
path: "/v1/transaction/rules"
tags: ["Transaction rule"]
---

# Create a transaction rule

`POST /v1/transaction/rules`

Creates a transaction rule. Requires the `transactions_rules_manage` permission. The
`company_id` and `user_id` are taken from the authenticated context and `company-id` header.

## Headers

- `company-id` string, uuid, required

## Request body

- TransactionRuleCreate — Payload to create a transaction rule. Requires the `transactions_rules_manage` permission. `company_id` and `user_id` are set from the authenticated context and the `company-id` header, not from the body.
  - `name` string, required
  - `enabled` boolean
  - `hidden` boolean
  - `constraints` object — Match expression evaluated against transactions.
  - `custom_column_change_effects` object[] — The custom-column changes to apply. Include an `id` to update an existing effect and `_destroy: true` to remove one. `target_custom_column_id` is accepted as an alias for `custom_column_id`.
    - `id` string, uuid
    - `custom_column_id` string, uuid
    - `target_custom_column_id` string, uuid
    - `target_value` string
    - `_destroy` boolean

## Response `201`

Rule created

- TransactionRule — A transaction rule — an automation that matches transactions against `constraints` and applies custom-column change effects (categorization). Rules are company-scoped and gated by the `transactions_rules_view` / `transactions_rules_manage` permissions.
  - `id` string, uuid, required
  - `company_id` string, uuid, required
  - `user_id` string — The user who created the rule.
  - `name` string, required
  - `constraints` object — Match expression evaluated against transactions (MongoDB-style operators, e.g. `$or` with per-merchant clauses).
  - `enabled` boolean
  - `hidden` boolean
  - `related_merchants` object[] — Merchants referenced by the rule's constraints.
    - `id` string, uuid
    - `name` string
    - `image_url` string, nullable
  - `custom_column_change_effects` object[] — The custom-column changes applied when the rule matches.
    - `id` string, uuid
    - `rule_id` string, uuid
    - `type` string
    - `custom_column_id` string, uuid, nullable
    - `target_attribute` string, nullable
    - `target_value` string, nullable
    - `created_at` string, date-time
    - `updated_at` string, date-time
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

- `401` — Unauthorized
- `404` — The `company-id` header is missing or the caller is not a member of the company
- `422` — Validation error

---

[API](https://skmtc.net/cardda/apis/banking-api.md) · [All operations](https://skmtc.net/cardda/apis/banking-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cardda/banking-api/versions/ff1aeb3fda8b/schema)
