Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt

Use this file to discover all available pages before exploring further.

Qualification rules define conditions that offers must satisfy before they can be recommended to a customer. Rules are evaluated during the qualification stage of a Decision Flow and can be scoped globally or to a specific segment, channel, category, sub-category, offer, or placement.
See the Qualification Rules feature page for UI guidance and conceptual overview.

Base path

/api/v1/qualification-rules

List qualification rules

GET /api/v1/qualification-rules
Returns a paginated list of qualification rules, ordered by priority (highest first), then creation date (newest first).

Query parameters

ParameterRequiredTypeDescription
limitNointegerMaximum results per page. Default 25.
cursorNostringCursor for keyset pagination.
includeDeletedNobooleanInclude soft-deleted records. Default false.

Response 200

{
  "data": [
    {
      "id": "qr_001",
      "tenantId": "t_001",
      "name": "Gold Tier Required",
      "description": "Only show to gold tier or above.",
      "status": "active",
      "scope": "segment",
      "scopeId": "seg_gold",
      "scopes": [{ "id": "qs_001", "qualificationRuleId": "qr_001", "scope": "global", "scopeId": null, "createdAt": "2026-03-10T12:00:00.000Z" }],
      "ruleType": "segment_required",
      "config": { "requiredSegments": ["gold", "platinum"] },
      "priority": 80,
      "stage": "qualification",
      "version": 1,
      "deletedAt": null,
      "createdAt": "2026-03-10T12:00:00.000Z",
      "updatedAt": "2026-03-12T09:30:00.000Z"
    }
  ],
  "pagination": {
    "total": 15,
    "limit": 25,
    "hasMore": false,
    "cursor": null
  }
}

Create a qualification rule

POST /api/v1/qualification-rules
Creates a new qualification rule. Requires the admin role.

Request body

FieldRequiredTypeDescription
nameYesstring (1-255)Unique rule name.
descriptionNostringRule description.
statusNoenumdraft, active (default), paused, archived.
scopeNoenumglobal (default), segment, channel, category, subcategory, offer, placement.
scopeIdNostring | nullID of the scoped entity (required when scope is not global).
ruleTypeYesenumOne of: segment_required, attribute_condition, propensity_threshold, recency_check, metric_condition.
configNoobjectRule-type-specific configuration.
priorityNointeger (0-100)Evaluation priority (higher = evaluated first). Default 50.
stageNoenumqualification (default) or fit.
scopesNoarrayArray of scope assignments. Each item: { scope: "global"|"category"|"subcategory"|"channel"|"offer"|"creative", scopeId: "entity-UUID" }. When provided, overrides the legacy scope/scopeId fields. A rule can have multiple scope assignments simultaneously.

Rule types

TypeDescriptionConfig example
segment_requiredCustomer must be in any of the listed segments (OR logic).{ "requiredSegments": ["premium", "vip"] }
attribute_conditionCustomer attribute must match a condition. Supports eq, neq, gt, gte, lt, lte, in, not_in, exists, not_exists.{ "attribute": "customer.age", "operator": "gte", "value": 18 }
propensity_thresholdModel score or enriched attribute must exceed a threshold.Model: { "propensityModel": "mod_01", "minScore": 0.3 } or Attribute: { "attribute": "customer.churn_risk", "operator": "lt", "threshold": 0.8 }
recency_checkCustomer attribute representing days since last activity must be within a window.{ "attribute": "customer.last_purchase_days", "maxDays": 90 }
metric_conditionA behavioral metric must meet a condition.{ "metricId": "open_rate", "operator": "gte", "threshold": 0.1 }

Example request

{
  "name": "Minimum Age 18",
  "ruleType": "attribute_condition",
  "scope": "global",
  "config": {
    "attribute": "age",
    "operator": "gte",
    "value": 18
  },
  "priority": 90,
  "stage": "qualification"
}

Response 201

Returns the created qualification rule object.

Validation

All fields are validated via Zod schemas:
  • name: 1-255 characters, must be unique per tenant.
  • ruleType: Must be one of the five enum values.
  • scope: Must be one of the seven enum values.
  • priority: Integer, 0-100.
  • stage: Must be qualification or fit.

Error codes

CodeReason
400Validation error (missing name or ruleType, invalid scope/priority).
409A qualification rule with that name already exists.
415Content-Type is not application/json.

Update a qualification rule

PUT /api/v1/qualification-rules
Updates an existing qualification rule. Only provided fields are changed. Requires the admin role.

Request body

All fields from the create schema are accepted as optional, plus:
FieldRequiredTypeDescription
idYesstringThe rule ID to update.

Example request

{
  "id": "qr_001",
  "priority": 95,
  "status": "paused"
}

Response 200

Returns the updated qualification rule object.

Delete a qualification rule

DELETE /api/v1/qualification-rules?id={ruleId}
Soft-deletes a qualification rule by ID. The record is marked as deleted but retained in the database for audit purposes. The response includes warnings if the rule is still referenced by any Decision Flow’s draftConfig.

Query parameters

ParameterRequiredTypeDescription
idYesstringRule ID to delete.

Response 200

{
  "deleted": true,
  "warnings": [
    "Referenced by decision flow \"Credit Card NBA\" — it will skip this rule."
  ]
}
This endpoint uses soft-delete — the record is not physically removed from the database. It is excluded from GET results by default. To include soft-deleted records, pass ?includeDeleted=true on the GET request.
Unlike most DELETE endpoints that return 204, this endpoint returns 200 with a body so it can communicate ghost-reference warnings. The API checks all Decision Flows in the tenant for references to this rule ID in their draftConfig.stages.filter.qualificationRuleIds array.

Error codes

CodeReason
400Missing id query parameter, or soft-delete failed.

Role requirements

MethodMinimum role
GETviewer
POSTadmin
PUTadmin
DELETEadmin

Soft-delete and audit

Qualification rules use soft-delete with audit snapshots. When a rule is deleted:
  1. The deletedAt timestamp is set (record is retained).
  2. An audit snapshot is captured with the full state before deletion.
  3. Ghost reference warnings are returned if the rule is still referenced by any Decision Flow.
Updates also create audit snapshots via auditedUpdate, incrementing the rowVersion on each change. This provides a full change history for compliance and debugging. To include soft-deleted rules in GET responses, add ?includeDeleted=true to the query string.
Multi-scope rules are evaluated differently: global-scoped rules are evaluated in the Decision Flow’s Qualify node, while entity-scoped rules (offer, category, channel, creative) are automatically evaluated per-candidate during the recommend pipeline.

Qualification Rules

Learn more about configuring qualification rules in the platform UI.