Skip to main content

Test Scoring Rules

Test how a scoring rule would affect a specific lead or account before saving it. These endpoints perform a dry-run evaluation without modifying any production scores — useful for validating rule logic before it goes live.

You can also run rule tests directly from the kenbun UI using the Test Rule button on any scoring rule.

POST /engagement-scoring/test

Test an engagement scoring rule against a specific lead to preview how many points it would award.

Request

curl -X POST "https://api.kenbun.io/engagement-scoring/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"lead_id": "lead-456",
"rule": {
"event_type": "Page View",
"weight": 10,
"attribute_filters": [
{
"field": "path",
"operator": "equals",
"value": "/pricing"
}
]
}
}'

Request Body

FieldRequiredTypeDescription
lead_idYesstringThe lead to test the rule against
ruleYesobjectThe rule configuration to evaluate
rule.event_typeYesstringEvent type to match (e.g., Page View, Email Open)
rule.weightYesnumberPoints to award if rule matches (can be negative)
rule.attribute_filtersNoarrayOptional filters on event metadata fields

Attribute Filter Fields:

FieldTypeDescription
fieldstringEvent metadata field name (e.g., path, referrer)
operatorstringequals, contains, starts_with, gte, lte
valuestringValue to compare against

Response

Status: 200 OK

{
"matches": true,
"reason": "Lead has 3 Page View events matching filters",
"current_score": 50,
"projected_score": 80,
"matching_events": 3
}

Response Fields

FieldTypeDescription
matchesbooleanWhether the rule would apply to this lead
reasonstringExplanation of why the rule matches or doesn't match
current_scorenumberLead's current engagement score
projected_scorenumberProjected score after applying this rule
matching_eventsnumberCount of events matching the rule criteria

POST /profile-scoring/test

Test a profile scoring rule against a specific lead.

Request

curl -X POST "https://api.kenbun.io/profile-scoring/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"lead_id": "lead-456",
"rule": {
"profile_property": "job_title",
"condition": "contains",
"comparison_value": "Engineer",
"weight": 15
}
}'

Request Body

FieldRequiredTypeDescription
lead_idYesstringThe lead to test the rule against
rule.profile_propertyYesstringProfile property to evaluate (e.g., job_title, seniority)
rule.conditionYesstringequals, contains, in, greater_than, less_than
rule.comparison_valueYesstringValue to compare the property against
rule.weightYesnumberPoints to award if the condition matches

Response

Status: 200 OK

{
"matches": true,
"reason": "Profile property 'job_title' contains 'Engineer'",
"current_score": 30,
"projected_score": 45,
"matching_value": "Software Engineer"
}

POST /account-scoring/test

Test an account scoring rule against a specific account.

Request

curl -X POST "https://api.kenbun.io/account-scoring/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"lead_id": "lead-456",
"rule": {
"account_property": "industry",
"condition": "equals",
"comparison_value": "Technology",
"weight": 25
}
}'

Request Body

FieldRequiredTypeDescription
lead_idYesstringThe lead whose account to test against
rule.account_propertyYesstringAccount property to evaluate (e.g., industry, employee_count)
rule.conditionYesstringequals, contains, in, greater_than_or_equal, between
rule.comparison_valueYesstringValue to compare the property against
rule.weightYesnumberPoints to award if the condition matches

Response

Status: 200 OK

{
"matches": true,
"reason": "Account property 'industry' equals 'Technology'",
"current_score": 40,
"projected_score": 65,
"matching_value": "Technology"
}

POST /deal-scoring/test

Test a deal scoring rule against a specific deal.

Request

curl -X POST "https://api.kenbun.io/deal-scoring/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"deal_id": "deal-789",
"rule": {
"deal_property": "stage",
"condition": "equals",
"comparison_value": "Proposal Sent",
"weight": 30
}
}'

Request Body

FieldRequiredTypeDescription
deal_idYesstringThe deal to test the rule against
rule.deal_propertyYesstringDeal property to evaluate (e.g., stage, amount)
rule.conditionYesstringequals, contains, in, greater_than_or_equal, between
rule.comparison_valueYesstringValue to compare the property against
rule.weightYesnumberPoints to award if the condition matches

Response

Status: 200 OK

{
"matches": true,
"reason": "Deal property 'stage' equals 'Proposal Sent'",
"current_score": 20,
"projected_score": 50,
"matching_value": "Proposal Sent"
}

Common Errors

StatusMeaningSolution
400Invalid request bodyCheck all required fields are present and properly formatted
401UnauthorizedVerify your API credentials are correct
404Lead or deal not foundConfirm the ID exists in your active organization
422Invalid rule configurationCheck that condition operators are valid for the property type

Use Cases

Validate a Rule Before Activating It

Test a new rule against several leads to ensure it produces expected results:

# Test against multiple leads
for lead_id in lead-1 lead-2 lead-3; do
curl -X POST "https://api.kenbun.io/engagement-scoring/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d "{\"lead_id\": \"$lead_id\", \"rule\": {\"event_type\": \"Page View\", \"weight\": 10}}"
done

Calibrate Point Values

Test the same rule with different weights to find the right balance:

# Test weight of 10
curl -X POST "https://api.kenbun.io/engagement-scoring/test" \
-d '{"lead_id": "lead-123", "rule": {"event_type": "Page View", "weight": 10}}'

# Test weight of 25
curl -X POST "https://api.kenbun.io/engagement-scoring/test" \
-d '{"lead_id": "lead-123", "rule": {"event_type": "Page View", "weight": 25}}'

Debug Why a Rule Isn't Matching

The reason field in the response explains exactly why a rule did or didn't match — whether events are missing, attribute filters excluded all events, or a property value doesn't satisfy the condition.