/api/nps

Header
POST https://api-prod.Fluxrails.app/api/v1/ai/nps
X-Customer-Api-Id: <uuid>
X-Secret:          <secret>
Content-Type:      application/json
Request Body Schema
group_by: string (optional)
data: array<object> (required)
  customer_id: string (required)
  question: string (optional)
  answer: integer 0–10 (required)
  <group_by field>: any (conditional)
  date: string (ISO-8601) (optional)
Example Request Body
{
  "group_by": "group",
  "data": [
    {
      "customer_id": "C-0001",
      "question": "How likely are you to recommend our app?",
      "answer": 9,
      "group": "Store-A",
      "date": "2025-04-28"
    },
    {
      "customer_id": "C-0002",
      "question": "How likely are you to recommend our app?",
      "answer": 4,
      "group": "Store-A",
      "date": "2025-04-28"
    },
    {
      "customer_id": "C-0003",
      "question": "How likely are you to recommend our app?",
      "answer": 10,
      "group": "Store-B",
      "date": "2025-04-28"
    }
  ]
}
Example Response Body
{
  "overall": {
    "nps": 33.33,
    "promoters_pct": 66.67,
    "passives_pct": 0.0,
    "detractors_pct": 33.33,
    "responses": 3,
    "interpretation": "Fair – room for improvement"
  },
  "by_group": [
    {
      "group": "Store-A",
      "nps": 0.0,
      "promoters_pct": 50.0,
      "passives_pct": 0.0,
      "detractors_pct": 50.0,
      "responses": 2,
      "interpretation": "Fair – room for improvement"
    },
    {
      "group": "Store-B",
      "nps": 100.0,
      "promoters_pct": 100.0,
      "passives_pct": 0.0,
      "detractors_pct": 0.0,
      "responses": 1,
      "interpretation": "World-class loyalty"
    }
  ]
}
Description

Compute the overall Net Promoter Score by classifying responses into Promoters (9–10), Passives (7–8), and Detractors (0–6), then calculating (promoters% – detractors%) × 100. Optionally group by any categorical field to slice scores by store, region, plan, etc., with rounded percentages and interpretation bands.

Business Usage

• Track global and per-group loyalty trends in BI dashboards • Set up real-time alerts on Detractor spikes (>20 %) • Compare performance across stores, channels, or plans • Route Detractor segments to customer success for follow-up • Promote high-NPS groups in marketing materials

← Back to all routes