Skip to main content

Test Scoring Rules

Test how a scoring rule would affect a specific lead before activating it in production. These endpoints perform dry-run scoring calculations without modifying actual lead scores.

POST /api/v1/ou/{ouId}/scoring-rules/test

Test an engagement scoring rule against a specific lead to preview its impact.

Request

curl -X POST "https://api.leadvibe.com/api/v1/ou/org-123/scoring-rules/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_idYesstring (UUID)The lead to test the rule against
ruleYesobjectThe rule configuration to test
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")
operatorstringComparison operator: equals, contains, starts_with, gte, lte
valuestringValue to compare against

Response

Status: 200 OK

{
"matches": true,
"reason": "Lead has 3 page_view events matching filters",
"currentScore": 50,
"projectedScore": 80,
"matchingEvents": 3
}

Response Fields

FieldTypeDescription
matchesbooleanWhether the rule would apply to this lead
reasonstringExplanation of why the rule matches or doesn't match
currentScorenumberLead's current engagement score
projectedScorenumberProjected score after applying this rule
matchingEventsnumberCount of events that match the rule criteria

Example: Rule Matches

{
"matches": true,
"reason": "Lead has 5 page_view events matching filters",
"currentScore": 42,
"projectedScore": 92,
"matchingEvents": 5
}

In this example, the lead has 5 matching events. If the rule weight is +10, the lead would gain 50 points (5 events × 10 points).

Example: Rule Doesn't Match

{
"matches": false,
"reason": "No matching events found",
"currentScore": 42,
"projectedScore": 42,
"matchingEvents": 0
}

The rule doesn't match because the lead has no events of the specified type or the attribute filters excluded all events.

POST /api/v1/ou/{ouId}/profile-scoring/test

Test a profile scoring rule against a specific lead.

Request

curl -X POST "https://api.leadvibe.com/api/v1/ou/org-123/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_idYesstring (UUID)The lead to test the rule against
ruleYesobjectThe profile rule configuration to test
rule.profile_propertyYesstringProfile property to evaluate (e.g., "job_title", "seniority")
rule.conditionYesstringCondition operator: equals, contains, in, greater_than, less_than
rule.comparison_valueYesstringValue to compare property against
rule.weightYesnumberPoints to award if condition matches

Response

Status: 200 OK

{
"matches": true,
"reason": "Profile property 'job_title' contains 'Engineer'",
"currentScore": 30,
"projectedScore": 45,
"matchingValue": "Software Engineer"
}

Response Fields

FieldTypeDescription
matchesbooleanWhether the rule condition is satisfied
reasonstringExplanation of match result
currentScorenumberLead's current profile fit score
projectedScorenumberProjected score after applying this rule
matchingValuestringThe actual property value from the lead's profile

POST /api/v1/ou/{ouId}/account-scoring/test

Test an account scoring rule against a specific account.

Request

curl -X POST "https://api.leadvibe.com/api/v1/ou/org-123/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_idYesstring (UUID)The lead whose account to test against
ruleYesobjectThe account rule configuration to test
rule.account_propertyYesstringAccount property to evaluate (e.g., "industry", "employee_count")
rule.conditionYesstringCondition operator: equals, contains, in, greater_than_or_equal, between
rule.comparison_valueYesstringValue to compare property against
rule.weightYesnumberPoints to award if condition matches

Response

Status: 200 OK

{
"matches": true,
"reason": "Account property 'industry' equals 'Technology'",
"currentScore": 40,
"projectedScore": 65,
"matchingValue": "Technology"
}

Response Fields

FieldTypeDescription
matchesbooleanWhether the rule condition is satisfied
reasonstringExplanation of match result
currentScorenumberAccount's current fit score
projectedScorenumberProjected score after applying this rule
matchingValuestringThe actual property value from the account

Common Errors

StatusMeaningSolution
400Invalid request bodyCheck that all required fields are present and properly formatted
401UnauthorizedVerify your API credentials are correct
404Lead not foundConfirm the lead_id exists in the specified OU
422Invalid rule configurationCheck that condition operators and values are valid for the property type
500Server errorRetry the request; contact support if the error persists

Use Cases

1. Validate Rule Before Activation

Test a new rule against your top 5 leads to ensure it produces expected scores before enabling it:

# Test against multiple leads
for lead_id in lead-1 lead-2 lead-3 lead-4 lead-5; do
curl -X POST "https://api.leadvibe.com/api/v1/ou/org-123/scoring-rules/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d "{\"lead_id\": \"$lead_id\", \"rule\": {...}}"
done

2. Calibrate Point Values

Test the same rule with different weights to find the optimal point value:

# Test weight of 10
curl -X POST ".../scoring-rules/test" -d '{"lead_id": "...", "rule": {"weight": 10, ...}}'

# Test weight of 25
curl -X POST ".../scoring-rules/test" -d '{"lead_id": "...", "rule": {"weight": 25, ...}}'

# Compare projected scores

3. Debug Why a Rule Isn't Matching

Use the test endpoint to understand why a rule doesn't match expected leads:

curl -X POST "https://api.leadvibe.com/api/v1/ou/org-123/scoring-rules/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"}
]
}
}'

The reason field in the response explains whether the issue is:

  • No events of this type exist
  • Events exist but attribute filters exclude them
  • Property value doesn't match the condition

4. Verify Attribute Filter Logic

Test complex attribute filter configurations to ensure they work as intended:

curl -X POST ".../scoring-rules/test" \
-u "CLIENT_ID:CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"lead_id": "lead-789",
"rule": {
"event_type": "page_view",
"weight": 15,
"attribute_filters": [
{"field": "path", "operator": "contains", "value": "pricing"},
{"field": "engaged_time_ms", "operator": "gte", "value": "30000"}
]
}
}'

This tests whether the rule correctly requires both conditions (pricing page AND engaged for 30+ seconds).

Best Practices

Test with Representative Leads

  • Include high-engagement, medium-engagement, and low-engagement leads
  • Verify rules match your target audience and exclude others

Check Projected Score Ranges

  • Ensure projected scores fall within reasonable ranges
  • Confirm high-value actions produce proportional score increases

Validate Filter Logic

  • Test attribute filters against leads with varied event metadata
  • Verify case sensitivity and exact match requirements

Use Reason Field for Debugging

  • Read the reason field to understand match failures
  • Adjust filters or conditions based on the explanation

Document Test Results

  • Keep notes on which leads you tested and their results
  • Use test results to justify point value choices to stakeholders