---
title: Generate segmentation for customers
slug: amberflo-api
docTags: 
createdAt: 2024-11-07T15:10:16.968Z
---

{
  "id": "PWplW4m6rJXCizvoiFyv6",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/pricing/segmentation",
    "servers": [
      {
        "url": "https://app.amberflo.io/pricing/segmentation"
      }
    ],
    "name": "Generate segmentation for customers",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "com.amberflo.analysis.segmentation.CustomerSegmentationRequest.in",
          "schema": [
            {
              "name": "meterApiNames",
              "kind": "required",
              "type": "array",
              "description": "A set of meter-api-names which will be used for segmentation.",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "meterGroupInfos",
              "kind": "optional",
              "type": "map",
              "description": "A map from meter-api-name to a list of dimensions",
              "example": "",
              "customType": "map<string, payment.meters.GroupInfo.in[]>",
              "schema": []
            },
            {
              "name": "minSegmentRatio",
              "kind": "optional",
              "type": "number",
              "description": "Minimum customer ratio of any produced segment (0.1 is the default, and it means that each cluster is at least 10% of customers).",
              "example": ""
            },
            {
              "name": "amountOfSegments",
              "kind": "optional",
              "type": "integer<int32>",
              "description": "Amount of segments to produce (default to 1).",
              "example": 0
            },
            {
              "name": "amountOfMonthsToConsider",
              "kind": "optional",
              "type": "integer<int32>",
              "description": "Amount of months of data to consider for the segmentation (default to 3).",
              "example": 0
            }
          ],
          "modelRef": "#/components/schemas/com.amberflo.analysis.segmentation.CustomerSegmentationRequest.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "com.amberflo.analysis.segmentation.AccountCustomerSegments.out",
            "schema": [
              {
                "name": "customerSegments",
                "kind": "optional",
                "type": "array",
                "description": "A set of segments which are the result of the customers clustering.",
                "modelRef": "#/components/schemas/com.amberflo.analysis.segmentation.AccountUsageClusterSegment.out",
                "customType": "com.amberflo.analysis.segmentation.AccountUsageClusterSegment.out[]",
                "schema": [
                  {
                    "name": "meterUsageClusterSegments",
                    "kind": "optional",
                    "type": "array",
                    "description": "A list of usage statics for each meter requested.",
                    "modelRef": "#/components/schemas/com.amberflo.analysis.segmentation.MeterUsageClusterSegment.out",
                    "customType": "com.amberflo.analysis.segmentation.MeterUsageClusterSegment.out[]",
                    "schema": [
                      {
                        "name": "meterApiName",
                        "kind": "optional",
                        "type": "string",
                        "description": "The meter-api-name.",
                        "example": ""
                      },
                      {
                        "name": "groupInfo",
                        "kind": "optional",
                        "type": "object",
                        "description": "The dimension of the meter Api Name.",
                        "modelRef": "#/components/schemas/payment.meters.GroupInfo.out",
                        "customType": "payment.meters.GroupInfo.out",
                        "schema": [
                          {
                            "name": "gi",
                            "kind": "optional",
                            "type": "map",
                            "example": "",
                            "customType": "map<string, string>",
                            "schema": []
                          }
                        ]
                      },
                      {
                        "name": "usageBucketList",
                        "kind": "optional",
                        "type": "array",
                        "description": "The list of the usage buckets in the customer cluster segment.",
                        "modelRef": "#/components/schemas/com.amberflo.analysis.segmentation.MeterUsageSegmentBucket.out",
                        "customType": "com.amberflo.analysis.segmentation.MeterUsageSegmentBucket.out[]",
                        "schema": [
                          {
                            "name": "usage",
                            "kind": "optional",
                            "type": "number",
                            "description": "The average usage for the customers in the bucket.",
                            "example": ""
                          },
                          {
                            "name": "amountOfCustomers",
                            "kind": "optional",
                            "type": "number",
                            "description": "The number of customers in the bucket.",
                            "example": ""
                          },
                          {
                            "name": "monthlyCustomerTrend",
                            "kind": "optional",
                            "type": "number",
                            "description": "How many customers on average to join or leave this bucket every month",
                            "example": ""
                          }
                        ]
                      },
                      {
                        "name": "averageUsage",
                        "kind": "optional",
                        "type": "number",
                        "description": "Avg usage over all customers.",
                        "example": ""
                      }
                    ]
                  },
                  {
                    "name": "customersInSegment",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "description": "Number of customers in the segment.",
                    "example": 0
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/com.amberflo.analysis.segmentation.AccountCustomerSegments.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "LSQp2urw0b3qIVyLFkBxf",
          "language": "curl",
          "label": "cURL",
          "code": "curl --location 'https://app.amberflo.io/pricing/segmentation' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n  \"meterApiNames\": [\n    \"\"\n  ],\n  \"meterGroupInfos\": \"\",\n  \"minSegmentRatio\": 0,\n  \"amountOfSegments\": 0,\n  \"amountOfMonthsToConsider\": 0\n}'"
        },
        {
          "id": "5tNgO2ixzSLe75OIGRQ0H",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"meterApiNames\": [\n      \"\"\n   ],\n   \"meterGroupInfos\": \"\",\n   \"minSegmentRatio\": 0,\n   \"amountOfSegments\": 0,\n   \"amountOfMonthsToConsider\": 0\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/pricing/segmentation\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "exjsjMFOl7r69xaHJClFn",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/pricing/segmentation\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"Content-Type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"meterApiNames\": [\n      \"\"\n   ],\n   \"meterGroupInfos\": \"\",\n   \"minSegmentRatio\": 0,\n   \"amountOfSegments\": 0,\n   \"amountOfMonthsToConsider\": 0\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "dVebYVL4W2u7XVRpwR5S5",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/pricing/segmentation\"\n\npayload = json.dumps({\n   \"meterApiNames\": [\n      \"\"\n   ],\n   \"meterGroupInfos\": \"\",\n   \"minSegmentRatio\": 0,\n   \"amountOfSegments\": 0,\n   \"amountOfMonthsToConsider\": 0\n})\nheaders = {\n   'Accept': 'application/json',\n   'Content-Type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "LSQp2urw0b3qIVyLFkBxf"
    },
    "results": {
      "languages": [
        {
          "id": "Z2cvKeBbcn3mAm-fYhMYi",
          "language": "200",
          "code": "// Successful request\n{\n  \"customerSegments\": [\n    {\n      \"meterUsageClusterSegments\": [\n        {\n          \"meterApiName\": \"\",\n          \"groupInfo\": {\n            \"gi\": \"\"\n          },\n          \"usageBucketList\": [\n            {\n              \"usage\": 0,\n              \"amountOfCustomers\": 0,\n              \"monthlyCustomerTrend\": 0\n            }\n          ],\n          \"averageUsage\": 0\n        }\n      ],\n      \"customersInSegment\": \"\"\n    }\n  ]\n}"
        }
      ],
      "selectedLanguageId": "Z2cvKeBbcn3mAm-fYhMYi"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}