Rule Schema Reference
Complete reference for the AppFig rule schema (v2.0.0).
Rule Structure
A feature can have one or more rules. Each rule has:
{
"conditions": {
"events": { /* event conditions */ },
"user_properties": [ /* user property conditions */ ],
"user_properties_operator": "AND" | "OR",
"device": [ /* device conditions */ ],
"device_operator": "AND" | "OR"
},
"value": any // What to return if conditions match
}
All three condition types must pass for a rule to match (AND logic between types).
Event Conditions
Events can be checked in two modes: Simple and Sequence.
Simple Mode
Check if events exist with certain criteria.
{
"mode": "simple",
"operator": "AND" | "OR",
"items": [
{
"key": "event_name",
"count": {
"operator": "==" | "!=" | ">" | "<" | ">=" | "<=",
"value": number
},
"within_last_days": number,
"param": {
"param_name": {
"operator": "==" | "!=" | ">" | "<" | ">=" | "<=" | "in" | "not_in" | "contains",
"value": any
}
},
"not": boolean
}
]
}
Fields:
mode- Must be"simple"operator- How to combine items:"AND"(all must match) or"OR"(any can match)items- Array of event conditions
Item fields:
key(required) - Event name to matchcount(optional) - How many times event must occurwithin_last_days(optional) - Only count events in last N daysparam(optional) - Match event parametersnot(optional) - Negate the condition (default: false)
Example: User completed 10+ levels AND made a purchase
{
"mode": "simple",
"operator": "AND",
"items": [
{
"key": "level_complete",
"count": {
"operator": ">=",
"value": 10
}
},
{
"key": "purchase_made",
"count": {
"operator": ">=",
"value": 1
}
}
]
}
Example: User opened app recently OR completed tutorial
{
"mode": "simple",
"operator": "OR",
"items": [
{
"key": "app_open",
"count": {
"operator": ">=",
"value": 1
},
"within_last_days": 7
},
{
"key": "tutorial_complete",
"count": {
"operator": ">=",
"value": 1
}
}
]
}
Example: User has NOT made a purchase
{
"mode": "simple",
"operator": "AND",
"items": [
{
"key": "purchase_made",
"count": {
"operator": ">=",
"value": 1
},
"not": true
}
]
}
Sequence Mode
Check if events occurred in a specific order.
{
"mode": "sequence",
"ordering": "direct" | "indirect",
"steps": [
{
"key": "event_name",
"count": {
"operator": "==" | "!=" | ">" | "<" | ">=" | "<=",
"value": number
},
"within_last_days": number,
"param": {
"param_name": {
"operator": "==" | "!=" | ">" | "<" | ">=" | "<=" | "in" | "not_in" | "contains",
"value": any
}
}
}
]
}
Fields:
mode- Must be"sequence"ordering- Sequence type:"direct"- Events must be consecutive (no other events between them)"indirect"- Events must be in order but can have other events between
steps- Array of events in required order
Example: Onboarding flow (direct)
{
"mode": "sequence",
"ordering": "direct",
"steps": [
{ "key": "tutorial_start" },
{ "key": "tutorial_step_1" },
{ "key": "tutorial_step_2" },
{ "key": "tutorial_complete" }
]
}
Example: Engagement pattern (indirect)
{
"mode": "sequence",
"ordering": "indirect",
"steps": [
{ "key": "app_open" },
{ "key": "level_complete" },
{ "key": "purchase_made" }
]
}
User Property Conditions
Check attributes of the user.
{
"user_properties": [
{
"key": "property_name",
"value": {
"operator": "==" | "!=" | ">" | "<" | ">=" | "<=" | "in" | "not_in" | "contains",
"value": any
},
"not": boolean
}
],
"user_properties_operator": "AND" | "OR"
}
Fields:
key(required) - Property namevalue.operator(required) - Comparison operatorvalue.value(required) - Value to compare againstnot(optional) - Negate the condition (default: false)user_properties_operator- How to combine multiple properties (default:"AND")
Example: Premium users
{
"user_properties": [
{
"key": "subscription_tier",
"value": {
"operator": "==",
"value": "premium"
}
}
],
"user_properties_operator": "AND"
}
Example: Premium OR trial users
{
"user_properties": [
{
"key": "subscription_tier",
"value": {
"operator": "==",
"value": "premium"
}
},
{
"key": "trial_active",
"value": {
"operator": "==",
"value": "true"
}
}
],
"user_properties_operator": "OR"
}
Example: Account older than 30 days
{
"user_properties": [
{
"key": "account_age_days",
"value": {
"operator": ">=",
"value": 30
}
}
]
}
Device Conditions
Check device/platform attributes (auto-detected by SDK).
{
"device": [
{
"key": "property_name",
"value": {
"operator": "==" | "!=" | ">" | "<" | ">=" | "<=" | "in" | "not_in" | "contains",
"value": any
},
"not": boolean
}
],
"device_operator": "AND" | "OR"
}
Auto-detected device properties:
| Property | Example Values | Description |
|---|---|---|
platform |
"iOS", "Android", "Windows", "macOS" |
Operating system |
os_version |
"17.0", "13", "11.0" |
OS version string |
language |
"en-US", "ja", "es-ES" |
System language |
country |
"US", "JP", "GB" |
Country code (auto- detected from CDN) |
timezone |
"America/Los_Angeles", "Asia/Tokyo" |
Timezone identifier |
device_brand |
"Apple", "Samsung", "Google" |
Device manufacturer |
device_model |
"iPhone 15", "Galaxy S23" |
Device model |
app_version |
"1.2.3" |
App version (if set manually) |
Example: Mobile platforms only
{
"device": [
{
"key": "platform",
"value": {
"operator": "in",
"value": ["iOS", "Android"]
}
}
]
}
Example: US users only
{
"device": [
{
"key": "country",
"value": {
"operator": "==",
"value": "US"
}
}
]
}
Example: Exclude old OS versions
{
"device": [
{
"key": "os_version",
"value": {
"operator": ">=",
"value": "15.0"
}
}
]
}
Operators
Comparison Operators
| Operator | Description | Example |
|---|---|---|
== |
Equals | "premium" == "premium" → true |
!= |
Not equals | "free" != "premium" → true |
> |
Greater than | 10 > 5 → true |
< |
Less than | 5 < 10 → true |
>= |
Greater or equal | 10 >= 10 → true |
<= |
Less or equal | 5 <= 10 → true |
Type handling:
- Strings compared lexicographically
- Numbers parsed and compared numerically
- Booleans compared as strings
Array Operators
| Operator | Description | Example |
|---|---|---|
in |
Value in array | "iOS" in ["iOS", "Android"] → true |
not_in |
Value not in array | "Windows" not_in ["iOS", "Android"] → true |
String Operators
| Operator | Description | Example |
|---|---|---|
contains |
String contains substring | "hello world" contains "world" → true |
Value Types
A value is one switch, number or text, stored as a string:
Boolean:
{ "value": "on" } // Checked with IsFeatureEnabled()
{ "value": "off" }
String:
{ "value": "Welcome back!" }
Number:
{ "value": "5" } // Stored as string, parse in your app
{ "value": "99.99" }
One value per feature. There are no object or list values. A Remote Config parameter that holds a whole JSON object is read field by field instead: each field becomes its own feature, and the JSON answers whenever AppFig has no value (see Guided Setup). Fields that change together go in one experiment.
Complete Example
Feature: "premium_features"
Rules:
- Show "full" premium to paying users
- Show "trial" premium to trial users who completed onboarding
- Show nothing to everyone else (no matching rule)
{
"premium_features": [
{
"conditions": {
"events": {
"mode": "simple",
"operator": "AND",
"items": []
},
"user_properties": [
{
"key": "subscription_tier",
"value": {
"operator": "==",
"value": "premium"
}
}
],
"user_properties_operator": "AND",
"device": [],
"device_operator": "AND"
},
"value": "full"
},
{
"conditions": {
"events": {
"mode": "sequence",
"ordering": "indirect",
"steps": [
{ "key": "onboarding_start" },
{ "key": "onboarding_complete" }
]
},
"user_properties": [
{
"key": "trial_active",
"value": {
"operator": "==",
"value": "true"
}
}
],
"user_properties_operator": "AND",
"device": [],
"device_operator": "AND"
},
"value": "trial"
}
]
}
Empty Conditions
To match all users (always-on feature), use empty condition arrays:
{
"conditions": {
"events": {
"mode": "simple",
"operator": "AND",
"items": []
},
"user_properties": [],
"user_properties_operator": "AND",
"device": [],
"device_operator": "AND"
},
"value": "on"
}
This rule always matches and returns "on".
Next Steps
- A/B Testing - Use a rule's return value to run an experiment instead of a static value
- Rule Prioritization - Control which RuleSet wins when several could match
- Testing Guide - Test your rules
- Unity SDK - Use rules in Unity
- React SDK - Use rules in React