Skip to main content
Routing rules allow you to automatically assign reviews to specific users or teams based on conditions. This guide explains how to create and manage routing rules.

Overview

Routing rules evaluate reviews and assign them to reviewers based on:
  • Task type
  • Urgency level
  • Confidence score
  • Custom metadata
  • Priority (rule evaluation order)

Creating Routing Rules

Via API

import httpx

async with httpx.AsyncClient() as client:
    # Create routing rule
    response = await client.post(
        "https://api.humancheck.dev/reviews",
        headers={
            "Authorization": "Bearer your-api-key-here",
            "Content-Type": "application/json"
        },
        json={
            "name": "High-value payments to finance team",
            "organization_id": 1,
            "priority": 100,
            "conditions": {
                "task_type": {"operator": "=", "value": "payment"},
                "metadata.amount": {"operator": ">", "value": 10000}
            },
            "assign_to_team_id": 5,  # Finance team
            "is_active": True
        }
    )
    rule = response.json()

Rule Structure

{
  "name": "Rule name",
  "organization_id": 1,
  "priority": 100,
  "conditions": {
    "task_type": {"operator": "=", "value": "payment"},
    "urgency": {"operator": "in", "value": ["high", "critical"]},
    "confidence_score": {"operator": "<", "value": 0.8}
  },
  "assign_to_user_id": 2,
  "assign_to_team_id": 5,
  "is_active": true
}

Condition Operators

Equality

"task_type": {"operator": "=", "value": "payment"}

Comparison

"confidence_score": {"operator": "<", "value": 0.8}
"metadata.amount": {"operator": ">", "value": 10000}

In List

"urgency": {"operator": "in", "value": ["high", "critical"]}
"task_type": {"operator": "in", "value": ["payment", "data_deletion"]}

Contains

"proposed_action": {"operator": "contains", "value": "DELETE"}

Metadata Access

"metadata.amount": {"operator": ">", "value": 10000}
"metadata.user_id": {"operator": "=", "value": 123}

Priority System

Rules are evaluated in priority order (highest first). The first matching rule is used.
# High priority (evaluated first)
{
    "priority": 200,
    "conditions": {"urgency": "critical"}
}

# Medium priority
{
    "priority": 100,
    "conditions": {"task_type": "payment"}
}

# Low priority (catch-all)
{
    "priority": 10,
    "conditions": {}
}

Common Examples

Route by Task Type

{
    "name": "SQL reviews to DBA team",
    "priority": 100,
    "conditions": {
        "task_type": {"operator": "=", "value": "sql_execution"}
    },
    "assign_to_team_id": 4
}

Route by Urgency

{
    "name": "Critical reviews to on-call",
    "priority": 200,
    "conditions": {
        "urgency": {"operator": "=", "value": "critical"}
    },
    "assign_to_user_id": 10  # On-call user
}

Route by Confidence

{
    "name": "Low confidence to senior reviewers",
    "priority": 100,
    "conditions": {
        "confidence_score": {"operator": "<", "value": 0.7}
    },
    "assign_to_team_id": 3  # Senior reviewers team
}

Route by Metadata

{
    "name": "High-value payments to finance",
    "priority": 100,
    "conditions": {
        "task_type": {"operator": "=", "value": "payment"},
        "metadata.amount": {"operator": ">", "value": 10000}
    },
    "assign_to_team_id": 5
}

Catch-All Rule

{
    "name": "Default assignment",
    "priority": 10,
    "conditions": {},  # Matches everything
    "assign_to_team_id": 1  # Default team
}

Best Practices

  1. Use priority wisely: Higher priority rules should be more specific
  2. Create catch-all rules: Ensure all reviews get assigned
  3. Test rules: Test rules with sample reviews before going live
  4. Document rules: Use descriptive names and comments
  5. Monitor assignments: Check that reviews are being assigned correctly

Next Steps