Skip to main content

What is a Fact Definition?

A Fact Definition declares an input variable that your rules can reference in conditions and actions. Think of it like a function parameter — you define the name, type, and whether it’s required before writing the logic. Facts are tenant-wide: once defined, they’re available across all policy groups and versions.

System Facts

Every tenant has 7 pre-registered system facts available immediately after account creation. These cannot be deleted:
KeyTypeRequiredDescription
user_idSTRINGUser identifier
payment_amountNUMBERPayment amount
phone_numberSTRINGPhone number
emailSTRINGEmail address
device_tokenSTRINGDevice token (for push notifications)
user_tagsLIST_STRINGUser tags
total_pointNUMBERCurrent point balance
System facts can be used in conditions and actions immediately — no registration needed.

Custom Facts

Any input variable beyond the 7 system facts must be registered before use. For example, customer_tier, order_region, or product_category are custom facts.
lexq facts create --key customer_tier --name "Customer Tier" --type STRING
lexq facts create --key order_region --name "Order Region" --type STRING --required

Supported Types

TypeJSONExample Value
STRING"string""VIP"
NUMBERnumber100000
BOOLEANtrue / falsetrue
LIST_STRING["a", "b"]["KR", "US"]
LIST_NUMBER[1, 2][10000, 20000]

Naming Conventions

Fact keys must follow snake_case naming. Keys are case-sensitive.
  • payment_amount, customer_tier, user_region
  • paymentAmount, Payment-Amount, PAYMENT AMOUNT

Required vs Optional Facts

  • Required facts must be present in every execution request. If missing, the engine returns an INVALID_INPUT error.
  • Optional facts can be omitted. Rules referencing missing optional facts evaluate their conditions as false (no match).

Managing Facts

Facts are managed in the Console under Management → Fact Definitions, or via the CLI:
lexq facts list
lexq facts create --key order_total --name "Order Total" --type NUMBER --required
lexq facts update --id <factId> --name "Total Order Amount"
lexq facts delete --id <factId>
Use lexq analytics requirements (CLI) or the Engine API’s GET /groups/{groupId}/requirements endpoint to see exactly which facts a deployed version needs.
Deleting a fact does not automatically remove it from existing rules. Rules referencing a deleted fact will evaluate that condition as false. Always review rule dependencies before deleting.

Next Steps

Policy Rules

Use facts in rule conditions and actions.

Policy Execution

See how facts are passed during execution.