/api/segmentation_report_json?lang=en

Header
X-Customer-Api-Id: <uuid> 
X-Secret:          <secret> 
Content-Type:      application/json 
Request Body Schema
customers: array<object>  
  id: string  
  frequency: int  
  amount_spent: float  
  product_types: array<string>  
labels: object<customer_id: cluster_id>  
dendrogram: object {  
    linkage_matrix: 2-D array,  
    leaf_labels:    array<string>,  
    cluster_legend: array<object>  
} (optional) 
Example Request Body
{
  "customers": [
    { "id": "C001", "frequency": 28, "amount_spent": 4120.75, "product_types": ["laptop","mouse","keyboard","monitor"] },
    { "id": "C002", "frequency":  5, "amount_spent":  190.40, "product_types": ["tea","coffee"] },
    { "id": "C003", "frequency": 12, "amount_spent":  845.10, "product_types": ["jeans","t-shirt","sneakers"] },
    { "id": "C004", "frequency":  2, "amount_spent":   75.00, "product_types": ["notebook"] },
    { "id": "C005", "frequency": 17, "amount_spent": 1324.55, "product_types": ["smartphone","earbuds"] },
    { "id": "C006", "frequency":  8, "amount_spent":  510.30, "product_types": ["dog food","cat food"] },
    { "id": "C007", "frequency": 24, "amount_spent": 2780.90, "product_types": ["smart-tv","soundbar","hdmi-cable"] },
    { "id": "C008", "frequency": 10, "amount_spent":  660.00, "product_types": ["yogurt","milk","cheese"] },
    { "id": "C009", "frequency":  3, "amount_spent":  120.00, "product_types": ["stationery"] },
    { "id": "C010", "frequency": 15, "amount_spent":  975.65, "product_types": ["beer","wine","snacks"] },
    { "id": "C011", "frequency":  7, "amount_spent":  450.25, "product_types": ["books","pens"] },
    { "id": "C012", "frequency": 25, "amount_spent": 3015.90, "product_types": ["tablet","stylus","cover"] },
    { "id": "C013", "frequency":  6, "amount_spent":  210.10, "product_types": ["pasta","sauce"] },
    { "id": "C014", "frequency": 20, "amount_spent": 1884.00, "product_types": ["fitness-watch"] },
    { "id": "C015", "frequency":  1, "amount_spent":   40.00, "product_types": ["batteries"] },
    { "id": "C016", "frequency": 13, "amount_spent": 1105.35, "product_types": ["printer","ink"] },
    { "id": "C017", "frequency":  4, "amount_spent":  160.00, "product_types": ["flour","sugar","eggs"] },
    { "id": "C018", "frequency": 30, "amount_spent": 4522.60, "product_types": ["gaming-pc","rgb-mouse","gaming-chair","headset"] },
    { "id": "C019", "frequency": 11, "amount_spent":  720.00, "product_types": ["makeup","skincare"] },
    { "id": "C020", "frequency":  9, "amount_spent":  585.40, "product_types": ["toys","board-games"] },
    { "id": "C021", "frequency":  2, "amount_spent":   55.00, "product_types": ["candles"] },
    { "id": "C022", "frequency": 18, "amount_spent": 1410.70, "product_types": ["camera","sd-card"] },
    { "id": "C023", "frequency": 14, "amount_spent":  992.00, "product_types": ["office-chair","desk-lamp"] },
    { "id": "C024", "frequency":  3, "amount_spent":  135.00, "product_types": ["juice","cookies"] },
    { "id": "C025", "frequency": 12, "amount_spent":  830.20, "product_types": ["running-shoes","sports-socks"] },
    { "id": "C026", "frequency": 23, "amount_spent": 2560.00, "product_types": ["fridge","water-filter"] },
    { "id": "C027", "frequency":  6, "amount_spent":  260.40, "product_types": ["vitamins"] },
    { "id": "C028", "frequency":  5, "amount_spent":  195.99, "product_types": ["wine","cheese"] },
    { "id": "C029", "frequency": 19, "amount_spent": 1599.95, "product_types": ["e-reader","ebooks"] },
    { "id": "C030", "frequency": 22, "amount_spent": 2345.00, "product_types": ["washing-machine","detergent"] },
    { "id": "C031", "frequency":  4, "amount_spent":  175.50, "product_types": ["herbs","spices"] },
    { "id": "C032", "frequency":  8, "amount_spent":  540.00, "product_types": ["diapers","baby-wipes","formula"] },
    { "id": "C033", "frequency": 27, "amount_spent": 3350.80, "product_types": ["console","controller","games"] },
    { "id": "C034", "frequency": 10, "amount_spent":  705.35, "product_types": ["sunscreen","after-sun"] },
    { "id": "C035", "frequency":  3, "amount_spent":  150.00, "product_types": ["frozen-pizza"] },
    { "id": "C036", "frequency": 16, "amount_spent": 1240.60, "product_types": ["tool-set","drill"] },
    { "id": "C037", "frequency":  9, "amount_spent":  610.10, "product_types": ["organic-vegetables"] },
    { "id": "C038", "frequency": 21, "amount_spent": 2105.00, "product_types": ["air-fryer","cookbook"] },
    { "id": "C039", "frequency":  7, "amount_spent":  435.75, "product_types": ["flowers","vase"] },
    { "id": "C040", "frequency": 14, "amount_spent": 1015.90, "product_types": ["winter-jacket","gloves","scarf"] }
  ],
  "labels": {
    "C001":2,"C002":0,"C003":0,"C004":0,"C005":0,"C006":0,"C007":1,"C008":0,
    "C009":0,"C010":0,"C011":0,"C012":1,"C013":0,"C014":1,"C015":0,"C016":0,
    "C017":0,"C018":2,"C019":0,"C020":0,"C021":0,"C022":0,"C023":0,"C024":0,
    "C025":0,"C026":1,"C027":0,"C028":0,"C029":0,"C030":1,"C031":0,"C032":0,
    "C033":1,"C034":0,"C035":0,"C036":0,"C037":0,"C038":1,"C039":0,"C040":0
  },
  "dendrogram": {
    "linkage_matrix": [
      [1.0,27.0,5.5900115966796875,2.0],
      [16.0,34.0,10.246950765959598,2.0],
      [10.0,38.0,14.5,2.0],
      [18.0,33.0,14.684114387072421,2.0],
      [2.0,24.0,14.933482805184708,2.0],
      [14.0,20.0,15.033296378372908,2.0],
      [8.0,23.0,15.033296378372908,2.0],
      [9.0,22.0,16.41102378466232,2.0],
      [12.0,40.0,19.554342797373597,3.0],
      [30.0,41.0,23.67840084690405,3.0],
      [19.0,36.0,24.720185838561353,2.0],
      [5.0,31.0,29.71684244831212,2.0],
      [3.0,45.0,31.75951301054011,3.0],
      [39.0,47.0,37.04603277151646,3.0],
      [46.0,49.0,53.204636389447614,5.0],
      [7.0,43.0,60.837535989873956,3.0],
      [26.0,48.0,75.42189702647553,4.0],
      [4.0,35.0,83.95602895187841,2.0],
      [50.0,51.0,102.69139093644127,4.0],
      [15.0,53.0,135.75478433757996,4.0],
      [54.0,56.0,139.4687935795597,9.0],
      [21.0,57.0,147.95607449395212,3.0],
      [42.0,58.0,193.4435440607144,6.0],
      [25.0,29.0,215.00232556881798,2.0],
      [44.0,55.0,220.82693991432996,5.0],
      [13.0,37.0,221.00452484055614,2.0],
      [6.0,11.0,235.00212764994276,2.0],
      [52.0,60.0,256.36800922508723,12.0],
      [28.0,61.0,336.40545943552,4.0],
      [0.0,17.0,401.8550746056813,2.0],
      [32.0,66.0,522.3946688588159,3.0],
      [62.0,64.0,537.5921954390619,11.0],
      [63.0,65.0,647.7163731140352,4.0],
      [59.0,68.0,743.4835774228395,8.0],
      [70.0,72.0,1528.9174504219059,7.0],
      [67.0,71.0,1623.9774150881199,23.0],
      [73.0,75.0,2865.3048816814076,31.0],
      [69.0,74.0,3076.681261272462,9.0],
      [76.0,77.0,8866.563988339083,40.0]
    ],
    "columns":["child1","child2","distance","sample_count"],
    "leaf_labels":["C001","C002","C003","C004","C005","C006","C007","C008","C009","C010","C011","C012","C013","C014","C015","C016","C017","C018","C019","C020","C021","C022","C023","C024","C025","C026","C027","C028","C029","C030","C031","C032","C033","C034","C035","C036","C037","C038","C039","C040"],
    "cluster_legend":[
      {"cluster_id":0,"n_customers":31,"avg_spend":591.11,"avg_frequency":8.81,"top_categories":"wine, cheese, diapers"},
      {"cluster_id":1,"n_customers":7,"avg_spend":2577.37,"avg_frequency":23.14,"top_categories":"smart-tv, soundbar, hdmi-cable"},
      {"cluster_id":2,"n_customers":2,"avg_spend":4321.68,"avg_frequency":29.0,"top_categories":"laptop, mouse, keyboard"}
    ]
  }
}
Example Response Body
{
  "language":"English",
  "generated_on":"2025-05-20T17:47:09",
  "executive_summary":"The segmentation analysis has revealed three distinct customer clusters among the 40 customers...",
  "cluster_analysis":"The dendrogram and cluster legend provide a thorough breakdown of each cluster...",
  "customer_insights":"Each customer segment exhibits distinct characteristics that can be leveraged for targeted communication...",
  "marketing_recommendations":"Based on the detailed segmentation, it is recommended that marketing campaigns be highly personalized...",
  "channel_strategy":"The channel strategy must be diversified to meet the varied preferences of each customer segment...",
  "product_cross_sell_ideas":"There exists significant potential for cross-selling across the different customer clusters...",
  "retention_actions":"Retention efforts should focus on creating cohesive loyalty programs and personalized support...",
  "next_steps":"The next steps involve a detailed review of the segmentation findings by the marketing, data science, and product teams...",
  "auto_insights":[
    "Cluster 0 has the most customers (31).",
    "Cluster 2 shows the highest average ticket (4,322).",
    "Cluster 0 generates 40.7% of total revenue."
  ],
  "dendrogram_insights":"• The clusters can be thought of as segments on a continuum from lower to higher spend and frequency...",
  "cluster_metrics":[
    {"cluster_id":0,"n_customers":31,"avg_spend":591.11,"avg_frequency":8.81,"top_categories":"wine, cheese, diapers","share_revenue_pct":40.71},
    {"cluster_id":1,"n_customers":7,"avg_spend":2577.37,"avg_frequency":23.14,"top_categories":"smart-tv, soundbar, hdmi-cable","share_revenue_pct":40.08},
    {"cluster_id":2,"n_customers":2,"avg_spend":4321.68,"avg_frequency":29.0,"top_categories":"laptop, mouse, keyboard","share_revenue_pct":19.20}
  ],
  "raw_payload":{ /* echo of the full request */ }
}
Description

End-to-End Narrative Generator – auto-writes a complete JSON report (exec summary, cluster KPIs, marketing guidance, slide copy) from raw segmentation artefacts.

Business Usage

• CMO / VP Marketing: 3-min board-ready briefs • Growth Manager: campaign copy & cross-sell ideas • Merchandising Lead: data-backed bundle suggestions • Data-Ops: automate PPT/BI dashboard generation

← Back to all routes