Skip to main content

POST /api/v1/qualification-rules/reach-estimate

Estimates the impact of a proposed qualification rule by querying the actual customer data in a schema table. Returns qualifying/excluded counts, field distribution statistics, and a breakdown by segment.

Request Body

FieldTypeRequiredDescription
ruleTypestringYesRule type identifier
fieldstringYesField name to evaluate (e.g., age, credit_score)
operatorstringYesComparison operator (see table below)
valuestring, number, boolean, or arrayYesValue to compare against
schemastringYesSchema name containing the customer data
sampleSizeintegerNoMax rows to sample (100-10000, default: 1000)

Supported Operators

OperatorSQL EquivalentDescription
eq=Equals
neq!=Not equals
gt>Greater than
gte>=Greater than or equal
lt<Less than
lte<=Less than or equal
inINValue in array
not_inNOT INValue not in array
containsLIKEString contains
not_containsNOT LIKEString does not contain

Example

curl -X POST https://playground.kaireonai.com/api/v1/qualification-rules/reach-estimate \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: my-tenant" \
  -d '{
    "ruleType": "attribute_condition",
    "field": "credit_score",
    "operator": "gte",
    "value": 720,
    "schema": "customers",
    "sampleSize": 5000
  }'

Response

{
  "totalSampled": 5000,
  "qualifying": 3250,
  "excluded": 1750,
  "qualifyPercent": 65.0,
  "excludedBySegment": [
    { "segment": "New Customers", "excluded": 820 },
    { "segment": "Low Risk", "excluded": 430 }
  ],
  "fieldDistribution": {
    "min": 300,
    "max": 850,
    "avg": 695.42,
    "median": 710,
    "p25": 620,
    "p75": 760
  }
}

Response Fields

FieldTypeDescription
totalSampledintegerNumber of rows sampled
qualifyingintegerRows matching the condition
excludedintegerRows not matching the condition
qualifyPercentnumberPercentage of qualifying rows
excludedBySegmentarrayBreakdown of excluded customers by segment (if segments exist)
fieldDistributionobject or nullStatistical distribution for numeric fields (min, max, avg, median, p25, p75)
Field distribution statistics are only available for numeric fields. For text fields, fieldDistribution is null.

Roles

admin, editor See also: Qualification Rules