Create Rule
API Reference
Create Rule
Create a new rule for risk detection and compliance monitoring β in the gu1 rules engine for compliance and risk detection, with examples for create use cases.
POST
Create Rule
Overview
Creates a new rule for automated risk detection, compliance monitoring, and fraud prevention. Every create runs a synchronous AI review (included; not debited from your AI token wallet) before the rule is persisted. New rules are always stored asin_progress with enabled: false so you can review suggestions and activate manually.
Request fields
status and enabled on create are ignored β the API coerces status: in_progress and enabled: false. Expect several seconds of latency while the review completes. Bundle or template flows that create many rules run one review per rule.Endpoint
Authentication
Requires a valid API key in the Authorization header:Request Body
string
required
Descriptive name for the rule
string
required
Detailed description of what the rule detects
string
required
Category of the rule:
kyc, kyb, aml, fraud, compliance, customarray
required
Array of entity types this rule applies to:
["person"], ["company"], ["transaction"], ["person", "company"]object
required
Condition logic structure (see Condition Structure below)
boolean
Ignored on create β rules are always stored with
enabled: false.number
default:"50"
Rule priority (1-100). Higher values = higher priority
number
Risk score to assign when rule matches (0-100). Used in score-based risk matrices
string
Ignored on create β rules are always stored as
in_progress (configuration).string
default:"async"
Evaluation mode:
sync (immediate) or async (background processing)string
UUID of the risk matrix to associate this rule with
array
Array of ISO country codes to restrict rule execution:
["BR", "AR", "US"]object
Additional scope configuration including temporal windows and triggers
array
Array of tags for organizing rules:
["high-risk", "pep", "sanctions"]object
Optional origin metadata persisted on the rule. If omitted, the API defaults to
sourceType: api (API key) or user (session). Fields: sourceType (user | agent | import_json | template | bundle | api), conversationId, messageId, platformAgentCategory, triggeredByUserId.Condition Structure
Rules use a nested condition structure with logical operators:Condition Fields
- operator: Logical operator connecting conditions (
AND,OR,NOT,XOR) - conditions: Array of condition objects (can be nested for complex logic)
- id: Unique identifier for the condition
- type: Condition type (
simple,complex,array,object) - field: Field path to evaluate (e.g.,
taxId,entityData.company.revenue,enrichmentData.normalized.sanctions.$.type) - operator: Comparison operator (see Operators below)
- value: Value to compare against
- filters: Array of filters for array/object fields
- countryMetadata: Country-specific metadata for the condition
Operators
Comparison Operators
eq- Equalsneq- Not equalsgt- Greater thangte- Greater than or equallt- Less thanlte- Less than or equal
String Operators
contains- Contains substringnotContains- Does not contain substringstartsWith- Starts withendsWith- Ends withregex- Matches regular expression
Array Operators
in- Value is in arraynotIn- Value is not in arrayhasAny- Has any of the valueshasAll- Has all of the values
List Operators
inList- Value exists in a data listnotInList- Value does not exist in a data list
Existence Operators
exists- Field existsnotExists- Field does not existisEmpty- Field is empty/nullisNotEmpty- Field is not empty/null
Boolean Operators
isTrue- Boolean field is trueisFalse- Boolean field is false
Array Field Syntax
For fields within arrays, use the$ symbol:
sanctions array has type equal to "terrorism".
Filters
You can pre-filter array items before evaluation:Actions
Rules support multiple action types:Create Alert
Update Entity Status
Send Notification
Create Case
Example Requests
Simple KYC Rule - Check Tax ID
Complex Rule - Sanctions Check with Multiple Conditions
Transaction Monitoring Rule
Response
string
UUID of the created rule
string
Rule name
string
Rule description
string
Your organization ID
string
Current rule status
boolean
Whether rule is enabled
number
Rule version number
string
ISO timestamp of creation
string
User ID who created the rule
object
Origin metadata (
sourceType, optional agent chat ids).object
Synchronous AI review summary:
verified, reason, functionalityDescription, suggestions, issues.Response Example
Error Responses
400 Bad Request - Invalid Condition
400 Bad Request - Missing Required Fields
401 Unauthorized
Best Practices
- Start with Shadow Mode: Use
status: "shadow"to test rules without affecting production - Use Descriptive Names: Make rule names clear and searchable
- Set Appropriate Priorities: Higher priority rules execute first (1-100 scale)
- Tag Your Rules: Use tags for organization and filtering
- Country-Specific Rules: Use
scope.countriesfor geo-specific compliance - Test Thoroughly: Test rules with sample data before enabling
- Monitor Performance: Use sync mode for critical real-time rules, async for batch processing
- Score Strategically: Align scores with your risk matrix thresholds
See Also
- Condition Fields Reference - Complete list of available condition fields by entity type and country
- Execute Rule - Test rules against specific entities
- List Rules - Query and filter rules
- Update Rule - Modify existing rules