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
| Field | Required | Type | Description |
|---|---|---|---|
lead_id | Yes | string (UUID) | The lead to test the rule against |
rule | Yes | object | The rule configuration to test |
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 | Comparison operator: 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",
"currentScore": 50,
"projectedScore": 80,
"matchingEvents": 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 |
currentScore | number | Lead's current engagement score |
projectedScore | number | Projected score after applying this rule |
matchingEvents | number | Count 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
| Field | Required | Type | Description |
|---|---|---|---|
lead_id | Yes | string (UUID) | The lead to test the rule against |
rule | Yes | object | The profile rule configuration to test |
rule.profile_property | Yes | string | Profile property to evaluate (e.g., "job_title", "seniority") |
rule.condition | Yes | string | Condition operator: equals, contains, in, greater_than, less_than |
rule.comparison_value | Yes | string | Value to compare property against |
rule.weight | Yes | number | Points 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
| Field | Type | Description |
|---|---|---|
matches | boolean | Whether the rule condition is satisfied |
reason | string | Explanation of match result |
currentScore | number | Lead's current profile fit score |
projectedScore | number | Projected score after applying this rule |
matchingValue | string | The 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
| Field | Required | Type | Description |
|---|---|---|---|
lead_id | Yes | string (UUID) | The lead whose account to test against |
rule | Yes | object | The account rule configuration to test |
rule.account_property | Yes | string | Account property to evaluate (e.g., "industry", "employee_count") |
rule.condition | Yes | string | Condition operator: equals, contains, in, greater_than_or_equal, between |
rule.comparison_value | Yes | string | Value to compare property against |
rule.weight | Yes | number | Points 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
| Field | Type | Description |
|---|---|---|
matches | boolean | Whether the rule condition is satisfied |
reason | string | Explanation of match result |
currentScore | number | Account's current fit score |
projectedScore | number | Projected score after applying this rule |
matchingValue | string | The actual property value from the account |
Common Errors
| Status | Meaning | Solution |
|---|---|---|
| 400 | Invalid request body | Check that all required fields are present and properly formatted |
| 401 | Unauthorized | Verify your API credentials are correct |
| 404 | Lead not found | Confirm the lead_id exists in the specified OU |
| 422 | Invalid rule configuration | Check that condition operators and values are valid for the property type |
| 500 | Server error | Retry 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
reasonfield 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