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
| Field | Required | Type | Description |
|---|---|---|---|
lead_id | Yes | string | The lead to test the rule against |
rule | Yes | object | The rule configuration to evaluate |
rule.event_type | Yes | string | Event type to match (e.g., Page View, Email Open) |
rule.weight | Yes | number | Points to award if rule matches (can be negative) |
rule.attribute_filters | No | array | Optional filters on event metadata fields |
Attribute Filter Fields:
| Field | Type | Description |
|---|---|---|
field | string | Event metadata field name (e.g., path, referrer) |
operator | string | equals, contains, starts_with, gte, lte |
value | string | Value 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
| Field | Type | Description |
|---|---|---|
matches | boolean | Whether the rule would apply to this lead |
reason | string | Explanation of why the rule matches or doesn't match |
current_score | number | Lead's current engagement score |
projected_score | number | Projected score after applying this rule |
matching_events | number | Count 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
| Field | Required | Type | Description |
|---|---|---|---|
lead_id | Yes | string | The lead to test the rule against |
rule.profile_property | Yes | string | Profile property to evaluate (e.g., job_title, seniority) |
rule.condition | Yes | string | equals, contains, in, greater_than, less_than |
rule.comparison_value | Yes | string | Value to compare the property against |
rule.weight | Yes | number | Points 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
| Field | Required | Type | Description |
|---|---|---|---|
lead_id | Yes | string | The lead whose account to test against |
rule.account_property | Yes | string | Account property to evaluate (e.g., industry, employee_count) |
rule.condition | Yes | string | equals, contains, in, greater_than_or_equal, between |
rule.comparison_value | Yes | string | Value to compare the property against |
rule.weight | Yes | number | Points 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
| Field | Required | Type | Description |
|---|---|---|---|
deal_id | Yes | string | The deal to test the rule against |
rule.deal_property | Yes | string | Deal property to evaluate (e.g., stage, amount) |
rule.condition | Yes | string | equals, contains, in, greater_than_or_equal, between |
rule.comparison_value | Yes | string | Value to compare the property against |
rule.weight | Yes | number | Points 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
| Status | Meaning | Solution |
|---|---|---|
| 400 | Invalid request body | Check all required fields are present and properly formatted |
| 401 | Unauthorized | Verify your API credentials are correct |
| 404 | Lead or deal not found | Confirm the ID exists in your active organization |
| 422 | Invalid rule configuration | Check 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.
Related Endpoints
- Engagement Rules - Create and manage engagement rules
- Profile Scoring Rules - Create and manage profile rules
- Engagement Rulesets - Manage engagement rulesets