Create Rule
Create a new automation rule for opportunities.
**Payload fields:**
- `name` (required): Rule name - max 191 chars
- `description` (optional): Free text - max 1000 chars
- `entity_type` (required): "opportunity" for this endpoint
- `trigger_type` (required): Valid TriggerType enum (e.g. OPPORTUNITY_STAGE_CHANGED, OPPORTUNITY_WON, OPPORTUNITY_LOST)
- `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 (see Leads/Create Rule for sub-keys)
- `actions[]` (required, min 1): Array of action rows (see Leads/Create Rule for sub-keys)
**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: “opportunity” 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. opportunity.opportunity_stage_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

