Skip to main content
POST
Create a rule
A rule is a name and a condition. The condition is a CEL expression over what Prelude resolves for an evaluation, plus the values a recipe supplies, and it must return a boolean.
The expression is compiled before it is stored, so a typo in a name is refused here rather than turning into a rule that never fires. The error reports the offending identifier:
See Rules, recipes and flows for the language and the attr. and param. namespaces. The Prelude signal vocabulary is not published yet - contact us for the names available to your rules.

A rule on its own scores nothing

Creating a rule does not put it into service. It takes part in an evaluation once a recipe associates it and gives it a weight, and that recipe is referenced by a flow.

Rules bound to a recipe

An expression referencing attr.plan_tier or param.blocked_countries compiles here against those names declared as strings, which is how a recipe would declare them - string is the only type either supports. What is not checked here is whether any recipe declares them at all: that is the recipe’s check, since it is the recipe that declares them. So a rule reading attr. or param. names is usable only by recipes declaring them. Adding it to one that doesn’t is refused at recipe save time, against that rule’s entry.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string
required

A label for the rule. It is returned in evaluation results, so make it say what the rule looks for.

Maximum string length: 128
Example:

"free_plan_signup"

expression
string
required

The condition, written in CEL. It must evaluate to a boolean, and it is compiled before it is stored: an expression that does not compile is refused.

It may reference the signals Prelude resolves for an evaluation, a recipe's request attributes as attr.<key>, and a recipe's configured values as param.<key>. A rule that references either namespace is bound to the recipes declaring those names, and can only be used by them. See Rules, recipes and flows; the signal vocabulary is not published yet, so contact us for the names available to your rules.

Example:

"attr.plan_tier == \"free\""

Response

Created

id
string
required

The rule identifier. Reference it in a recipe's rules to score over it.

Example:

"rul_01jc0t6fwwfgfsq1md24mhyztj"

name
string
required
Example:

"free_plan_signup"

expression
string
required
Example:

"attr.plan_tier == \"free\""

type
enum<string>
required

Always CUSTOM. A rule you author is your own; Prelude's are a separate, read-only listing.

Available options:
CUSTOM