Create Rule
Create a new automation rule for leads.
**Payload fields:**
- `name` (required): Rule name - max 191 chars
- `description` (optional): Free text - max 1000 chars
- `entity_type` (required): "lead" for this endpoint
- `trigger_type` (required): Valid TriggerType enum (e.g. LEAD_CREATED)
- `priority` (optional): Integer 0-100 - lower fires first - default 50
- `is_active` (optional): Boolean - default true
- `stop_subsequent_rules` (optional): Boolean - if true, halts rule chain on match
- `cooldown_hours` (optional): Integer hours - dedupe within window - null = no cooldown
- `conditions[]` (required, min 1): Array of condition rows
- `field_path` (required): Dotted accessor (e.g. lead.lead_source_id)
- `operator` (required): EQUALS|NOT_EQUALS|IN|NOT_IN|GT|GTE|LT|LTE|CONTAINS|EXISTS|...
- `value_int` / `value_string` / `value_array` / `value_bool` / `value_datetime` (one required, polymorphic by operator)
- `sort_order` (optional): Integer - default 0
- `actions[]` (required, min 1): Array of action rows
- `action_type` (required): ASSIGN_USER|CHANGE_STAGE|TAG|NOTIFY|...
- `sort_order` (optional): Integer
- `assign_pool_id` (conditional): UUID of user pool when action_type=ASSIGN_USER
- Other action_type-specific keys vary
**Payload fields:**
- `name` (required): Rule name - max 191 chars
- `description` (optional): Free text - max 1000 chars
- `entity_type` (required): "lead" or "opportunity" matching the route
- `trigger_type` (required): Valid TriggerType enum case
- `priority` (optional): Integer 0-100 - lower fires first - default 50
- `is_active` (optional): Boolean - default true
- `stop_subsequent_rules` (optional): Boolean - halts chain when true
- `cooldown_hours` (optional): Integer hours - dedupe within window - blank = no cooldown
- `conditions[i][...]` (required, min 1): condition rows. Each row has `field_path`, `operator`, one of `value_int|value_string|value_array|value_bool|value_datetime` (polymorphic by operator), and optional `sort_order`.
- `actions[i][...]` (required, min 1): action rows. Each row has `action_type`, `sort_order`, and action_type-specific keys (e.g. `assign_pool_id` for `ASSIGN_USER`).
Headers
{{tenant_key_name}}
Request
This endpoint expects a multipart form.
name
Required: Rule name - max 191 chars
priority
Optional: Integer 0-100 - lower fires first - default 50
is_active
Optional: bool - default true
description
Optional: Free text - max 1000 chars
entity_type
Required: “lead” for this endpoint
trigger_type
Required: Valid TriggerType enum case
stop_subsequent_rules
Optional: bool - halts chain on match
actions[0][sort_order]
Optional: Integer - default 0
actions[0][action_type]
Required: ASSIGN_USER|CHANGE_STAGE|TAG|NOTIFY|…
conditions[0][operator]
Required: EQUALS|NOT_EQUALS|IN|NOT_IN|GT|GTE|LT|LTE|CONTAINS|EXISTS|…
conditions[0][field_path]
Required: Dotted accessor (e.g. lead.lead_source_id)
conditions[0][sort_order]
Optional: Integer - default 0
actions[0][assign_pool_id]
Conditional: required when action_type=ASSIGN_USER. User pool UUID.
Response
Successful response

