---
title: "Create a rule"
method: POST
path: "/v1/erp/payouts/rules"
tags: ["Rule"]
---

# Create a rule

`POST /v1/erp/payouts/rules`

## Request

- Base URL: `https://api.cardda.com`
- URL: `https://api.cardda.com/v1/erp/payouts/rules`
- Auth: HTTP bearer

Creates an automation rule with its constraints and effects. `applicable_model` is set
once here and is immutable afterwards.

## Parameters

- `#/paths/~1v1~1erp~1payouts~1rules/get/parameters/0` (unresolved $ref)

## Request body

- object: Body used to create or update a rule. On update, `applicable_model` is ignored (immutable after creation). Effects are passed as nested attribute arrays.
  - `name` string
  - `company_id` string, uuid
  - `enabled` boolean
  - `inheritable` boolean
  - `applicable_model` string: Target bucket. Defaults to `tradables`. Only honored on create.
  - `constraints` object: Constraint tree as a flat map of dotted paths to values, expanded server-side into nested constraint attributes.
  - `attribute_change_effects` object[]
    - `target_attribute` string
    - `target_value` string
  - `custom_column_change_effects` object[]
    - `target_custom_column_id` string, uuid
    - `target_value` string
  - `reviewer_assigner_effects` object[]
    - `reviewer_user_id` string
    - `reviewer_order` integer

## Response `201`

The created rule.

- Rule: An automation rule that applies categorization or approval effects to payables (or purchase orders) matching its constraints.
  - `id` string, uuid, required
  - `name` string
  - `user_id` string: The user that created the rule.
  - `company_id` string, uuid, required
  - `constraints` object, nullable: The JSON constraint tree that determines which records the rule matches.
  - `enabled` boolean
  - `inheritable` boolean: Whether child companies in the corporate group inherit this rule.
  - `applicable_model` string: Target model bucket the rule applies to. Defaults to `tradables` (payables). Set once at creation and immutable thereafter.
  - `hidden` boolean
  - `overrides_rule_id` string, uuid, nullable
  - `inherit_override` boolean
  - `created_at` string, date-time
  - `updated_at` string, date-time
  - `attribute_change_effects` object[]
    - `id` string, uuid
    - `target_attribute` string
    - `target_value` string
  - `custom_column_change_effects` object[]
    - `id` string, uuid
    - `target_custom_column_id` string, uuid
    - `target_value` string
  - `reviewer_assigner_effects` object[]: Approval effects that assign reviewers. Present only for approval rules.
    - `id` string, uuid
    - `reviewer_user_id` string
    - `reviewer_order` integer
  - `related_partners` object[]: Business partners referenced by the rule's constraints. Included only in the `show` response (via the `related_partners` method).

## Other responses

- `401`: Unauthorized
- `422`: Unprocessable Entity

---

[API](https://skmtc.dev/cardda/apis/erp-api.md) - [All operations](https://skmtc.dev/cardda/apis/erp-api/llms.txt) - [OpenAPI document](https://skmtc.dev/cardda/apis/erp-api/revisions/0730ed26bc3c?raw)
