Skip to main content
POST
Create Rule

Authorizations

Authorization
string
header
required

Use Tuner API key (tr_api_...) or user session token. Find your API key in Workspace Settings > API Keys.

Path Parameters

agent_id
string
required

Tuner's numeric agent ID, or your Agent ID from Agent Settings > Agent Connection. Digits-only values are read as the numeric ID.

workspace_id
integer
required

Workspace ID. Find this in Workspace > General Settings.

Body

application/json

Schema for creating a rule.

Describe the condition with condition_tree.

condition_tree
RuleConditionGroup · object
required

The condition a call must match. The root is always a group (AND or OR) of predicates and nested groups, even for a single condition, and every node needs a type (group or predicate). Build each predicate from an item in List Rule Conditions: for an eval, a data extraction field or a voice metric, lhs is the item's name, source its source_type and field_id its id; for a latency percentile, lhs is the item's id (such as "p90_latency"); for Call Outcome, Call Intent, Call Duration, Call Cost, Call Outcome Type and Call Ended Reason, lhs is call_outcome, call_intent, call_duration, call_cost, call_outcome_type or call_ended_reason; for Extra Metadata, lhs is metadata.<key>. op is a word (eq, neq, gt, gte, lt, lte, exists, not_exists, contains, starts_with), not the symbol List Rule Conditions returns. eq, neq, contains and starts_with on text ignore case. exists and not_exists work on any field, even where List Rule Conditions doesn't list them. A field with no value for the call counts as not existing. A field the analysis skipped, such as an eval that didn't run or the intent of a call whose outcome stopped the analysis, matches only not_exists, not even neq. Groups nest at most 10 levels deep, and a tree holds at most 50 conditions.

Examples:
output_type
enum<string>
required

Whether a matching call gets a label or a red flag. Any other value returns a 422.

Available options:
label,
red_flag
Example:

"red_flag"

output_tag_name
string
required

Tag applied to matching calls. Appears on the call record and as a value in the labels_and_redflags filter on List Calls.

Required string length: 1 - 200
Example:

"Missed disclosure"

output_description
string | null

Optional note explaining what this rule is for.

Example:

"Flags calls where the required disclosure was missed."

state
enum<string>
default:active

paused rules don't run on new calls. Defaults to active.

Available options:
active,
paused
Example:

"active"

Response

Successful Response

Response schema for a rule.

id
integer
required

Tuner's ID for this rule.

output_type
string
required

Whether matching calls get a label or a red flag.

output_tag_name
string
required

Tag applied to matching calls.

state
string
required

active when the rule runs on new calls, paused when it doesn't.

Example:

"active"

created_at
string<date-time>
required

When the rule was created.

updated_at
string<date-time>
required

When the rule was last updated.

condition_tree
Condition Tree · object | null

The rule's conditions: a group of predicates and nested groups, in the format condition_tree takes when you create or update a rule. For an eval, a voice metric or a data extraction field, lhs is the item's current name. null only for an older rule whose condition could not be converted; it never matches.

Example:
output_description
string | null

Note explaining what this rule is for.

paused_reason
string | null

Why Tuner paused this rule, such as Eval deleted when the eval its condition used was deleted. Null when it is active or a person paused it.

Example:

null