---
title: /payments/analysis/by-rule-revenue-calculator
slug: amberflo-api/paymentsanalysisby-rule-revenue-calculator
docTags: 
createdAt: 2024-11-07T15:10:16.975Z
---

{
  "id": "OdDM6ITLJOd1lFuPxw_-_",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/analysis/by-rule-revenue-calculator",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/analysis/by-rule-revenue-calculator"
      }
    ],
    "name": "",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment.analysis.modeling.by_rule.ByRulePriceAnalysisModel.in",
          "schema": [
            {
              "name": "key",
              "kind": "optional",
              "type": "object",
              "description": "",
              "modelRef": "#/components/schemas/payment.analysis.modeling.PriceAnalysisModelKey.in",
              "customType": "payment.analysis.modeling.PriceAnalysisModelKey.in",
              "schema": [
                {
                  "name": "accountId",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "id",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                }
              ]
            },
            {
              "name": "type",
              "kind": "optional",
              "type": "string",
              "example": "",
              "default": "by-rule"
            },
            {
              "name": "name",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "timeRange",
              "kind": "optional",
              "type": "object",
              "description": "",
              "modelRef": "#/components/schemas/payment.common.TimeRange.in",
              "customType": "payment.common.TimeRange.in",
              "schema": [
                {
                  "name": "startTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "example": 0
                },
                {
                  "name": "endTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "example": 0
                }
              ]
            },
            {
              "name": "analysisProductPlans",
              "kind": "optional",
              "type": "array",
              "description": "",
              "modelRef": "#/components/schemas/payment.analysis.modeling.AnalysisProductPlan.in",
              "customType": "payment.analysis.modeling.AnalysisProductPlan.in[]",
              "schema": [
                {
                  "name": "id",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "referencePlan",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "planBillingPeriod",
                  "kind": "optional",
                  "type": "object",
                  "description": "",
                  "modelRef": "#/components/schemas/payment.pricing.BillingPeriod.in",
                  "customType": "payment.pricing.BillingPeriod.in",
                  "schema": [
                    {
                      "name": "interval",
                      "kind": "optional",
                      "type": "string",
                      "description": "",
                      "modelRef": "#/components/schemas/payment.pricing.BillingPeriodInterval.in",
                      "customType": "payment.pricing.BillingPeriodInterval.in",
                      "schema": []
                    },
                    {
                      "name": "intervalsCount",
                      "kind": "optional",
                      "type": "integer<int32>",
                      "example": 0
                    }
                  ]
                },
                {
                  "name": "itemToPriceIdsOverrides",
                  "kind": "optional",
                  "type": "map",
                  "example": "",
                  "customType": "map<string, string>",
                  "schema": []
                },
                {
                  "name": "meterNameToPriceOverrides",
                  "kind": "optional",
                  "type": "map",
                  "example": "",
                  "customType": "map<string, payment.pricing.price.PriceStateMachineNode.in>",
                  "schema": []
                }
              ]
            },
            {
              "name": "timeGroupingInterval",
              "kind": "optional",
              "type": "string",
              "description": "",
              "modelRef": "#/components/schemas/com.amberflo.service.common.aggregation.AggregationInterval.in",
              "customType": "com.amberflo.service.common.aggregation.AggregationInterval.in",
              "schema": []
            },
            {
              "name": "updateTimeInSeconds",
              "kind": "optional",
              "type": "integer<int64>",
              "example": 0
            },
            {
              "name": "customersBaseQuery",
              "kind": "optional",
              "type": "object",
              "description": "",
              "modelRef": "#/components/schemas/payment.analysis.modeling.by_rule.CustomersSampleSpaceKey.in",
              "customType": "payment.analysis.modeling.by_rule.CustomersSampleSpaceKey.in",
              "schema": [
                {
                  "name": "filters",
                  "kind": "optional",
                  "type": "map",
                  "example": "",
                  "customType": "map<string, string[]>",
                  "schema": []
                },
                {
                  "name": "take",
                  "kind": "optional",
                  "type": "object",
                  "description": "",
                  "modelRef": "#/components/schemas/payment.common.Take.in",
                  "customType": "payment.common.Take.in",
                  "schema": [
                    {
                      "name": "limit",
                      "kind": "optional",
                      "type": "integer<int32>",
                      "example": 0
                    },
                    {
                      "name": "isAscending",
                      "kind": "optional",
                      "type": "boolean",
                      "example": ""
                    }
                  ]
                }
              ]
            },
            {
              "name": "customerSource",
              "kind": "optional",
              "type": "string",
              "description": "",
              "modelRef": "#/components/schemas/payment.analysis.modeling.by_rule.CustomersSourceType.in",
              "customType": "payment.analysis.modeling.by_rule.CustomersSourceType.in",
              "schema": []
            },
            {
              "name": "usageSource",
              "kind": "optional",
              "type": "string",
              "description": "",
              "modelRef": "#/components/schemas/payment.analysis.modeling.by_rule.UsageSourceType.in",
              "customType": "payment.analysis.modeling.by_rule.UsageSourceType.in",
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/payment.analysis.modeling.by_rule.ByRulePriceAnalysisModel.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": "payment.analysis.modeling.revenue.AnalyzedPlansRevenues.out",
            "schema": [
              {
                "name": "analyzedPlanRevenueList",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/payment.analysis.modeling.revenue.AnalyzedPlanRevenue.out",
                "customType": "payment.analysis.modeling.revenue.AnalyzedPlanRevenue.out[]",
                "schema": [
                  {
                    "name": "analysisPlanId",
                    "kind": "optional",
                    "type": "string",
                    "example": ""
                  },
                  {
                    "name": "revenue",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "revenuePercentageDiffFromPivotPlan",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "customerGroupRevenueMap",
                    "kind": "optional",
                    "type": "map",
                    "example": "",
                    "customType": "map<string, payment.analysis.modeling.revenue.CustomerGroupRevenue.out>",
                    "schema": []
                  },
                  {
                    "name": "revenueValues",
                    "kind": "optional",
                    "type": "array",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.analysis.modeling.revenue.RevenueValue.out",
                    "customType": "payment.analysis.modeling.revenue.RevenueValue.out[]",
                    "schema": [
                      {
                        "name": "startTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      },
                      {
                        "name": "revenue",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "pivotPlanRevenue",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "revenuePercentageDiffFromPivotPlan",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      }
                    ]
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/payment.analysis.modeling.revenue.AnalyzedPlansRevenues.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "vytqW21YpTadXJFg7at9-",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/analysis/by-rule-revenue-calculator \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"type\": \"by-rule\"\n     }'"
        },
        {
          "id": "pFJA8ml0PeQ3u7V3J9e63",
          "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   \"type\": \"by-rule\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/payments/analysis/by-rule-revenue-calculator\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "NiwDgqAx0YL2aiWP5N5D1",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/analysis/by-rule-revenue-calculator\")\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   \"type\": \"by-rule\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "Zatl6bYx5Fy_xVAB4Yzss",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/analysis/by-rule-revenue-calculator\"\n\npayload = json.dumps({\n   \"type\": \"by-rule\"\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": "vytqW21YpTadXJFg7at9-"
    },
    "results": {
      "languages": [
        {
          "id": "8wJE3mN2DWkck9VenRUhl",
          "language": "200",
          "code": "// Successful request\n{\n  \"analyzedPlanRevenueList\": [\n    {\n      \"analysisPlanId\": \"\",\n      \"revenue\": 0,\n      \"revenuePercentageDiffFromPivotPlan\": 0,\n      \"customerGroupRevenueMap\": \"\",\n      \"revenueValues\": [\n        {\n          \"startTimeInSeconds\": \"\",\n          \"revenue\": 0,\n          \"pivotPlanRevenue\": 0,\n          \"revenuePercentageDiffFromPivotPlan\": 0\n        }\n      ]\n    }\n  ]\n}"
        }
      ],
      "selectedLanguageId": "8wJE3mN2DWkck9VenRUhl"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}