/api/churn_risk

Header
POST https://api-prod.Fluxrails.app/api/v1/ai/churn_risk
X-Customer-Api-Id: <uuid>
X-Secret:          <secret>
Content-Type:      application/json
Request Body Schema
data[]: array<object> (required)
  customer_id: string (required)
  tenure: integer (days ≥ 0) (required)
  usage_frequency: float (sessions/week) (required)
  service_tickets: integer (≥ 0) (required)
  nps: integer (−100…100) (required)
  payment_events: integer (≥ 0) (required)
  churned: 0/1 (optional)
Example Request Body
{
  "data": [
    {
      "customer_id": "C-0001",
      "tenure": 915,
      "usage_frequency": 6.2,
      "service_tickets": 1,
      "nps": 58,
      "payment_events": 0,
      "churned": 0
    },
    {
      "customer_id": "C-0002",
      "tenure": 310,
      "usage_frequency": 1.9,
      "service_tickets": 4,
      "nps": 12,
      "payment_events": 3,
      "churned": 1
    },
    {
      "customer_id": "C-0003",
      "tenure": 442,
      "usage_frequency": 3.1,
      "service_tickets": 0,
      "nps": 70,
      "payment_events": 0,
      "churned": 0
    },
    {
      "customer_id": "C-0004",
      "tenure": 95,
      "usage_frequency": 0.4,
      "service_tickets": 6,
      "nps": -10,
      "payment_events": 4,
      "churned": 1
    }
  ]
}
Example Response Body
{
  "best_algorithm": "Logistic Regression",
  "evaluation_metrics": {
    "Logistic Regression": { "roc_auc": 1.0, "f1": 1.0, "accuracy": 1.0 },
    "Random Forest":       { "roc_auc": 1.0, "f1": 1.0, "accuracy": 1.0 },
    "XGBoost":             { "roc_auc": 0.5, "f1": 0.6667, "accuracy": 0.5 },
    "CatBoost":            { "roc_auc": 1.0, "f1": 1.0, "accuracy": 1.0 }
  },
  "interpretation": "Logistic Regression achieved the highest validation performance (ROC-AUC=1.000, F1=1.000). High ticket volume combined with low NPS were the most influential churn drivers, underscoring the importance of support quality.",
  "results": [
    { "customer_id": "C-0001", "churn_probability": 1.3e-22,    "top_factors": [], "recommended_action": "Low risk → continue standard engagement cadence" },
    { "customer_id": "C-0002", "churn_probability": 0.999301645, "top_factors": [], "recommended_action": "High risk → offer retention discount & priority support" },
    { "customer_id": "C-0003", "churn_probability": 0.000698562, "top_factors": [], "recommended_action": "Low risk → continue standard engagement cadence" },
    { "customer_id": "C-0004", "churn_probability": 0.999999999, "top_factors": [], "recommended_action": "High risk → offer retention discount & priority support" }
  ]
}
Description

Predict churn risk by benchmarking logistic regression, random forest, XGBoost and CatBoost; return per-customer churn probabilities, chosen model, driver insights and recommended retention actions.

Business Usage

- High risk (≥0.60): offer discounts, priority support, concierge call - Medium risk (0.25–0.59): send usage tips, light promotions - Low risk (<0.25): maintain standard nurturing - Feed results into CRM/CS for automated retention journeys and track save-rate KPIs in BI dashboards.

← Back to all routes