Skip to main content

Ruleset Rules API

List all engagement scoring rules within a specific ruleset, and reorder them by priority. Use this to audit scoring logic, compare rulesets, export ruleset configuration, or programmatically update rule evaluation order.

GET /engagement-scoring/rulesets/{id}/rules​

Returns all engagement rules for the specified ruleset.

Request​

ParameterTypeRequiredDescription
idstringYesRuleset identifier (path parameter)

Response​

200 OK

{
"rules": [
{
"id": "rule-123",
"ruleset_id": "ruleset-abc",
"event_type": "Email Open",
"weight": 5,
"active": true,
"created_at": "2025-01-15T10:00:00Z"
},
{
"id": "rule-456",
"ruleset_id": "ruleset-abc",
"event_type": "Page View",
"weight": 10,
"active": true,
"created_at": "2025-01-15T10:05:00Z"
},
{
"id": "rule-789",
"ruleset_id": "ruleset-abc",
"event_type": "Demo Request",
"weight": 50,
"active": true,
"created_at": "2025-01-15T10:10:00Z"
}
]
}

Response Fields​

FieldTypeDescription
rulesarrayArray of rule objects
rules[].idstringUnique rule identifier
rules[].ruleset_idstringParent ruleset identifier
rules[].event_typestringEvent type this rule scores
rules[].weightintegerPoints awarded per event
rules[].activebooleanWhether the rule is active
rules[].created_attimestampWhen the rule was created

Example​

curl -X GET "https://api.kenbun.io/engagement-scoring/rulesets/ruleset-abc/rules" \
-H "Authorization: Bearer <token>"

Common Errors​

StatusMeaningSolution
401UnauthorizedCheck authentication credentials
404Not FoundVerify the ruleset ID is correct

PUT /engagement-scoring/rulesets/{id}/reorder​

Atomically reorder all rules within a ruleset by providing the desired priority order. Use this endpoint to persist a drag-and-drop reorder operation or to set rule priority programmatically.

All rules in the ruleset must be included in the request; the order of the rule_ids array becomes the new priority order (first item = highest priority).

Request​

ParameterTypeRequiredDescription
idstringYesRuleset identifier (path parameter)

Request Body​

FieldTypeRequiredDescription
rule_idsarray of stringsYesRule IDs in the desired priority order (highest priority first)

Response​

204 No Content — Order updated successfully. No response body.

Example​

curl -X PUT "https://api.kenbun.io/engagement-scoring/rulesets/ruleset-abc/reorder" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"rule_ids": ["rule-789", "rule-123", "rule-456"]
}'

In this example, rule-789 becomes the highest-priority rule, followed by rule-123, then rule-456.

Common Errors​

StatusMeaningSolution
400Empty or missing rule_idsProvide at least one rule ID
400Invalid rule ID formatEnsure all IDs are valid rule identifiers
400Rule does not belong to rulesetOnly include rules that are part of this ruleset
401UnauthorizedCheck authentication credentials
404Ruleset not foundVerify the ruleset ID is correct

Notes​

  • Each rule belongs to exactly one ruleset
  • The same event type can have different weights in different rulesets (e.g., Email Open worth 5 points in one ruleset and 10 in another)
  • When multiple rules match the same event, the highest-priority rule (lowest index in the ordered list) is credited for scoring attribution
  • Use PUT /engagement-scoring/rulesets/{id}/reorder to set priority order; use GET /engagement-scoring/rulesets/{id}/rules to read the current order