---
title: Query usage costs, revenue and profit
slug: reference/query-usage-costs-revenue-and-profit
docTags: 
createdAt: 2025-10-13T16:37:16.778Z
---

{
  "id": "NUaBiRb8lZSI-Qql5ktx9",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/cost/usage-query",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/cost/usage-query"
      }
    ],
    "name": "Query usage costs, revenue and profit",
    "description": "<p>Retrieves detailed usage costs, revenue, and profit analysis for your account.\nThis endpoint provides a comprehensive view of your billing metrics over time, combining both revenue generated from usage and associated costs.</p>\n<p>Use this endpoint to:</p>\n<ul>\n<li>Analyze profitability by customer, product, or custom dimensions</li>\n<li>Track revenue trends and cost drivers over time</li>\n<li>Generate financial reports with granular time breakdowns</li>\n<li>Monitor usage patterns and their financial impact</li>\n</ul>\n<p>The response includes three key components: usage revenue (what customers are billed), usage costs (your costs to deliver the service), and usage profit (revenue minus costs).\nResults can be filtered by multiple dimensions and grouped by time intervals ranging from seconds to years.</p>\n<p><strong>Important Note:</strong> Time ranges are automatically expanded to include complete time intervals based on your specified granularity.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "Input parameters for usage cost calculation request specifying product scope, time range, and aggregation preferences.",
          "customType": "payment.cost.UsageCostsKey.in",
          "schema": [
            {
              "name": "productId",
              "kind": "optional",
              "type": "string",
              "description": "Unique identifier of the product for which usage costs should be calculated.",
              "example": ""
            },
            {
              "name": "timeRange",
              "kind": "optional",
              "type": "object",
              "description": "Start and end timestamps defining the period for usage cost analysis.",
              "modelRef": "#/components/schemas/payment.common.TimeRange.in",
              "customType": "payment.common.TimeRange.in",
              "schema": [
                {
                  "name": "startTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "description": "Unix timestamp marking the beginning of the time range in seconds",
                  "example": 0
                },
                {
                  "name": "endTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "description": "Unix timestamp marking the end of time range or null for open-ended ranges",
                  "example": 0
                }
              ]
            },
            {
              "name": "timeGroupingInterval",
              "kind": "optional",
              "type": "string",
              "description": "Time interval for grouping usage data in the cost calculation results.",
              "modelRef": "#/components/schemas/common.aggregation.AggregationInterval.in",
              "customType": "common.aggregation.AggregationInterval.in",
              "schema": []
            },
            {
              "name": "filters",
              "kind": "optional",
              "type": "map",
              "description": "Dimensional filters to apply to the usage data. Keys are dimension names, values are arrays of allowed values.",
              "example": "",
              "customType": "map<string, string[]>",
              "schema": []
            },
            {
              "name": "groupBy",
              "kind": "optional",
              "type": "array",
              "description": "Dimensions to group results by, such as customerId or custom dimensions.",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "page",
              "kind": "optional",
              "type": "object",
              "description": "Pagination configuration for handling large result sets.",
              "modelRef": "#/components/schemas/payment.common.Page.in",
              "customType": "payment.common.Page.in",
              "schema": [
                {
                  "name": "number",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "description": "One-indexed page number to retrieve with token required for pages beyond first",
                  "example": 0
                },
                {
                  "name": "size",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "description": "Number of items per page with valid range between 1 and 1000 inclusive",
                  "example": 0
                },
                {
                  "name": "token",
                  "kind": "optional",
                  "type": "string",
                  "description": "Pagination token required for navigating to pages beyond the first page",
                  "example": ""
                }
              ]
            },
            {
              "name": "take",
              "kind": "optional",
              "type": "object",
              "description": "Limit configuration for the number of cost records to return.",
              "modelRef": "#/components/schemas/payment.common.Take.in",
              "customType": "payment.common.Take.in",
              "schema": [
                {
                  "name": "limit",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "description": "Maximum number of results to return for query with minimum value of 1",
                  "example": 0
                },
                {
                  "name": "isAscending",
                  "kind": "optional",
                  "type": "boolean",
                  "description": "Sort order direction with true for ascending and false for descending order",
                  "example": ""
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/payment.cost.UsageCostsKey.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successfully retrieved usage costs, revenue and profit analysis",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Comprehensive financial analysis combining revenue, costs, and profit calculations.",
            "customType": "payment.cost.UsageDetail.out",
            "schema": [
              {
                "name": "key",
                "kind": "optional",
                "type": "object",
                "description": "Original query parameters used to generate this analysis.",
                "modelRef": "#/components/schemas/payment.cost.UsageCostsKey.out",
                "customType": "payment.cost.UsageCostsKey.out",
                "schema": [
                  {
                    "name": "productId",
                    "kind": "optional",
                    "type": "string",
                    "description": "Unique identifier of the product for which usage costs should be calculated",
                    "example": ""
                  },
                  {
                    "name": "timeRange",
                    "kind": "optional",
                    "type": "object",
                    "description": "Start and end timestamps defining the period for usage cost analysis",
                    "modelRef": "#/components/schemas/payment.common.TimeRange.in",
                    "customType": "payment.common.TimeRange.in",
                    "schema": [
                      {
                        "name": "startTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "description": "Unix timestamp marking the beginning of the time range in seconds",
                        "example": 0
                      },
                      {
                        "name": "endTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "description": "Unix timestamp marking the end of time range or null for open-ended ranges",
                        "example": 0
                      }
                    ]
                  },
                  {
                    "name": "timeGroupingInterval",
                    "kind": "optional",
                    "type": "string",
                    "description": "Time interval for grouping usage data in the cost calculation results",
                    "modelRef": "#/components/schemas/common.aggregation.AggregationInterval.in",
                    "customType": "common.aggregation.AggregationInterval.in",
                    "schema": []
                  },
                  {
                    "name": "filters",
                    "kind": "optional",
                    "type": "map",
                    "description": "Additional filtering criteria applied to usage data before cost calculation",
                    "example": "",
                    "customType": "map<string, string[]>",
                    "schema": []
                  },
                  {
                    "name": "groupBy",
                    "kind": "optional",
                    "type": "array",
                    "description": "Field names for grouping and aggregating usage costs in the response",
                    "example": "",
                    "itemType": "string",
                    "customType": "string[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "page",
                    "kind": "optional",
                    "type": "object",
                    "description": "Pagination configuration for handling large result sets",
                    "modelRef": "#/components/schemas/payment.common.Page.in",
                    "customType": "payment.common.Page.in",
                    "schema": [
                      {
                        "name": "number",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "One-indexed page number to retrieve with token required for pages beyond first",
                        "example": 0
                      },
                      {
                        "name": "size",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Number of items per page with valid range between 1 and 1000 inclusive",
                        "example": 0
                      },
                      {
                        "name": "token",
                        "kind": "optional",
                        "type": "string",
                        "description": "Pagination token required for navigating to pages beyond the first page",
                        "example": ""
                      }
                    ]
                  },
                  {
                    "name": "take",
                    "kind": "optional",
                    "type": "object",
                    "description": "Limit configuration for the number of cost records to return",
                    "modelRef": "#/components/schemas/payment.common.Take.in",
                    "customType": "payment.common.Take.in",
                    "schema": [
                      {
                        "name": "limit",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Maximum number of results to return for query with minimum value of 1",
                        "example": 0
                      },
                      {
                        "name": "isAscending",
                        "kind": "optional",
                        "type": "boolean",
                        "description": "Sort order direction with true for ascending and false for descending order",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "usageRevenue",
                "kind": "optional",
                "type": "object",
                "description": "Revenue generated from customer usage based on pricing plans.",
                "modelRef": "#/components/schemas/payment.cost.UsageCosts.out",
                "customType": "payment.cost.UsageCosts.out",
                "schema": [
                  {
                    "name": "key",
                    "kind": "optional",
                    "type": "object",
                    "description": "Request parameters that were used to generate this usage cost calculation.",
                    "modelRef": "#/components/schemas/payment.cost.UsageCostsKey.out",
                    "customType": "payment.cost.UsageCostsKey.out",
                    "schema": [
                      {
                        "name": "productId",
                        "kind": "optional",
                        "type": "string",
                        "description": "Unique identifier of the product for which usage costs should be calculated",
                        "example": ""
                      },
                      {
                        "name": "timeRange",
                        "kind": "optional",
                        "type": "object",
                        "description": "Start and end timestamps defining the period for usage cost analysis",
                        "modelRef": "#/components/schemas/payment.common.TimeRange.in",
                        "customType": "payment.common.TimeRange.in",
                        "schema": [
                          {
                            "name": "startTimeInSeconds",
                            "kind": "optional",
                            "type": "integer<int64>",
                            "description": "Unix timestamp marking the beginning of the time range in seconds",
                            "example": 0
                          },
                          {
                            "name": "endTimeInSeconds",
                            "kind": "optional",
                            "type": "integer<int64>",
                            "description": "Unix timestamp marking the end of time range or null for open-ended ranges",
                            "example": 0
                          }
                        ]
                      },
                      {
                        "name": "timeGroupingInterval",
                        "kind": "optional",
                        "type": "string",
                        "description": "Time interval for grouping usage data in the cost calculation results",
                        "modelRef": "#/components/schemas/common.aggregation.AggregationInterval.in",
                        "customType": "common.aggregation.AggregationInterval.in",
                        "schema": []
                      },
                      {
                        "name": "filters",
                        "kind": "optional",
                        "type": "map",
                        "description": "Additional filtering criteria applied to usage data before cost calculation",
                        "example": "",
                        "customType": "map<string, string[]>",
                        "schema": []
                      },
                      {
                        "name": "groupBy",
                        "kind": "optional",
                        "type": "array",
                        "description": "Field names for grouping and aggregating usage costs in the response",
                        "example": "",
                        "itemType": "string",
                        "customType": "string[]",
                        "itemExample": "",
                        "itemDefault": ""
                      },
                      {
                        "name": "page",
                        "kind": "optional",
                        "type": "object",
                        "description": "Pagination configuration for handling large result sets",
                        "modelRef": "#/components/schemas/payment.common.Page.in",
                        "customType": "payment.common.Page.in",
                        "schema": [
                          {
                            "name": "number",
                            "kind": "optional",
                            "type": "integer<int32>",
                            "description": "One-indexed page number to retrieve with token required for pages beyond first",
                            "example": 0
                          },
                          {
                            "name": "size",
                            "kind": "optional",
                            "type": "integer<int32>",
                            "description": "Number of items per page with valid range between 1 and 1000 inclusive",
                            "example": 0
                          },
                          {
                            "name": "token",
                            "kind": "optional",
                            "type": "string",
                            "description": "Pagination token required for navigating to pages beyond the first page",
                            "example": ""
                          }
                        ]
                      },
                      {
                        "name": "take",
                        "kind": "optional",
                        "type": "object",
                        "description": "Limit configuration for the number of cost records to return",
                        "modelRef": "#/components/schemas/payment.common.Take.in",
                        "customType": "payment.common.Take.in",
                        "schema": [
                          {
                            "name": "limit",
                            "kind": "optional",
                            "type": "integer<int32>",
                            "description": "Maximum number of results to return for query with minimum value of 1",
                            "example": 0
                          },
                          {
                            "name": "isAscending",
                            "kind": "optional",
                            "type": "boolean",
                            "description": "Sort order direction with true for ascending and false for descending order",
                            "example": ""
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "name": "secondsSinceEpochIntervals",
                    "kind": "optional",
                    "type": "array",
                    "description": "Unix timestamp intervals representing the time periods covered in the cost analysis.",
                    "example": "",
                    "itemType": "integer",
                    "customType": "integer[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "costList",
                    "kind": "optional",
                    "type": "array",
                    "description": "Grouped usage cost results broken down by the specified grouping criteria.",
                    "modelRef": "#/components/schemas/payment.cost.UsageGroupCosts.out",
                    "customType": "payment.cost.UsageGroupCosts.out[]",
                    "schema": [
                      {
                        "name": "groupInfos",
                        "kind": "optional",
                        "type": "map",
                        "description": "Grouping criteria key-value pairs used to aggregate these usage costs together",
                        "example": "",
                        "customType": "map<string, string>",
                        "schema": []
                      },
                      {
                        "name": "meteredUnits",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total metered usage units consumed across all time periods for this group",
                        "example": ""
                      },
                      {
                        "name": "price",
                        "kind": "optional",
                        "type": "number",
                        "description": "Final aggregated price after applying all discounts and promotional adjustments for group",
                        "example": ""
                      },
                      {
                        "name": "priceBeforeDiscounts",
                        "kind": "optional",
                        "type": "number",
                        "description": "Original calculated price before applying any prepaid credits or promotional discounts",
                        "example": ""
                      },
                      {
                        "name": "prepaidUsed",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total amount of prepaid credits consumed to reduce charges for this group",
                        "example": ""
                      },
                      {
                        "name": "priceMinusPrepaid",
                        "kind": "optional",
                        "type": "number",
                        "description": "Price after subtracting prepaid credits but before applying promotional discounts",
                        "example": ""
                      },
                      {
                        "name": "payAsYouGoPromotionUsed",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total value of pay-as-you-go promotional discounts applied to reduce charges",
                        "example": ""
                      },
                      {
                        "name": "nonPayAsYouGoPromotionUsed",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total value of non-pay-as-you-go promotional discounts applied to reduce charges",
                        "example": ""
                      },
                      {
                        "name": "priceAfterPayAsYouGoPromotion",
                        "kind": "optional",
                        "type": "number",
                        "description": "Price after applying pay-as-you-go promotions but before other discount types",
                        "example": ""
                      },
                      {
                        "name": "priceAfterNonPayAsYouGoPromotion",
                        "kind": "optional",
                        "type": "number",
                        "description": "Price after applying non-pay-as-you-go promotions showing final promotional impact",
                        "example": ""
                      },
                      {
                        "name": "costs",
                        "kind": "optional",
                        "type": "array",
                        "description": "Time-series cost values showing usage and pricing statistics for each time interval",
                        "modelRef": "#/components/schemas/payment.cost.UsageGroupCostValue.out",
                        "customType": "payment.cost.UsageGroupCostValue.out[]",
                        "schema": [
                          {
                            "name": "startTimeInSeconds",
                            "kind": "optional",
                            "type": "integer<int64>",
                            "description": "Unix timestamp marking the beginning of this cost calculation time period",
                            "example": 0
                          },
                          {
                            "name": "meteredUnits",
                            "kind": "optional",
                            "type": "number",
                            "description": "Total metered usage units consumed during this time period for billing calculations",
                            "example": ""
                          },
                          {
                            "name": "price",
                            "kind": "optional",
                            "type": "number",
                            "description": "Final calculated price after applying all discounts and promotional adjustments",
                            "example": ""
                          },
                          {
                            "name": "pricePercentageDiff",
                            "kind": "optional",
                            "type": "number",
                            "description": "Percentage change in price compared to previous time period for trend analysis",
                            "example": ""
                          },
                          {
                            "name": "meterUnitsPercentageDiff",
                            "kind": "optional",
                            "type": "number",
                            "description": "Percentage change in metered units compared to previous time period for usage trends",
                            "example": ""
                          },
                          {
                            "name": "priceBeforeDiscounts",
                            "kind": "optional",
                            "type": "number",
                            "description": "Original calculated price before applying prepaid credits and promotional discounts",
                            "example": ""
                          },
                          {
                            "name": "prepaidUsed",
                            "kind": "optional",
                            "type": "number",
                            "description": "Amount of prepaid credits consumed to reduce customer charges for this period",
                            "example": ""
                          },
                          {
                            "name": "payAsYouGoPromotionUsed",
                            "kind": "optional",
                            "type": "number",
                            "description": "Value of pay-as-you-go promotional discounts applied to reduce customer charges",
                            "example": ""
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "name": "pageInfo",
                    "kind": "optional",
                    "type": "object",
                    "description": "Pagination metadata for navigating through large cost calculation result sets.",
                    "modelRef": "#/components/schemas/payment.common.PageInfo.out",
                    "customType": "payment.common.PageInfo.out",
                    "schema": [
                      {
                        "name": "pageNumber",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Current page number being returned in this response using one-indexed numbering",
                        "example": 0
                      },
                      {
                        "name": "pageSize",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Number of items per page configured for this paginated query response",
                        "example": 0
                      },
                      {
                        "name": "pageToken",
                        "kind": "optional",
                        "type": "string",
                        "description": "Token for accessing the next page of results in subsequent pagination requests",
                        "example": ""
                      },
                      {
                        "name": "totalPages",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Total number of pages available for this query across all results",
                        "example": 0
                      },
                      {
                        "name": "totalResults",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Total count of all items available across all pages for this query",
                        "example": 0
                      }
                    ]
                  }
                ]
              },
              {
                "name": "usageCost",
                "kind": "optional",
                "type": "object",
                "description": "Costs associated with providing the service for this usage.",
                "modelRef": "#/components/schemas/payment.cost.UsageCosts.out",
                "customType": "payment.cost.UsageCosts.out",
                "schema": [
                  {
                    "name": "key",
                    "kind": "optional",
                    "type": "object",
                    "description": "Request parameters that were used to generate this usage cost calculation.",
                    "modelRef": "#/components/schemas/payment.cost.UsageCostsKey.out",
                    "customType": "payment.cost.UsageCostsKey.out",
                    "schema": [
                      {
                        "name": "productId",
                        "kind": "optional",
                        "type": "string",
                        "description": "Unique identifier of the product for which usage costs should be calculated",
                        "example": ""
                      },
                      {
                        "name": "timeRange",
                        "kind": "optional",
                        "type": "object",
                        "description": "Start and end timestamps defining the period for usage cost analysis",
                        "modelRef": "#/components/schemas/payment.common.TimeRange.in",
                        "customType": "payment.common.TimeRange.in",
                        "schema": [
                          {
                            "name": "startTimeInSeconds",
                            "kind": "optional",
                            "type": "integer<int64>",
                            "description": "Unix timestamp marking the beginning of the time range in seconds",
                            "example": 0
                          },
                          {
                            "name": "endTimeInSeconds",
                            "kind": "optional",
                            "type": "integer<int64>",
                            "description": "Unix timestamp marking the end of time range or null for open-ended ranges",
                            "example": 0
                          }
                        ]
                      },
                      {
                        "name": "timeGroupingInterval",
                        "kind": "optional",
                        "type": "string",
                        "description": "Time interval for grouping usage data in the cost calculation results",
                        "modelRef": "#/components/schemas/common.aggregation.AggregationInterval.in",
                        "customType": "common.aggregation.AggregationInterval.in",
                        "schema": []
                      },
                      {
                        "name": "filters",
                        "kind": "optional",
                        "type": "map",
                        "description": "Additional filtering criteria applied to usage data before cost calculation",
                        "example": "",
                        "customType": "map<string, string[]>",
                        "schema": []
                      },
                      {
                        "name": "groupBy",
                        "kind": "optional",
                        "type": "array",
                        "description": "Field names for grouping and aggregating usage costs in the response",
                        "example": "",
                        "itemType": "string",
                        "customType": "string[]",
                        "itemExample": "",
                        "itemDefault": ""
                      },
                      {
                        "name": "page",
                        "kind": "optional",
                        "type": "object",
                        "description": "Pagination configuration for handling large result sets",
                        "modelRef": "#/components/schemas/payment.common.Page.in",
                        "customType": "payment.common.Page.in",
                        "schema": [
                          {
                            "name": "number",
                            "kind": "optional",
                            "type": "integer<int32>",
                            "description": "One-indexed page number to retrieve with token required for pages beyond first",
                            "example": 0
                          },
                          {
                            "name": "size",
                            "kind": "optional",
                            "type": "integer<int32>",
                            "description": "Number of items per page with valid range between 1 and 1000 inclusive",
                            "example": 0
                          },
                          {
                            "name": "token",
                            "kind": "optional",
                            "type": "string",
                            "description": "Pagination token required for navigating to pages beyond the first page",
                            "example": ""
                          }
                        ]
                      },
                      {
                        "name": "take",
                        "kind": "optional",
                        "type": "object",
                        "description": "Limit configuration for the number of cost records to return",
                        "modelRef": "#/components/schemas/payment.common.Take.in",
                        "customType": "payment.common.Take.in",
                        "schema": [
                          {
                            "name": "limit",
                            "kind": "optional",
                            "type": "integer<int32>",
                            "description": "Maximum number of results to return for query with minimum value of 1",
                            "example": 0
                          },
                          {
                            "name": "isAscending",
                            "kind": "optional",
                            "type": "boolean",
                            "description": "Sort order direction with true for ascending and false for descending order",
                            "example": ""
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "name": "secondsSinceEpochIntervals",
                    "kind": "optional",
                    "type": "array",
                    "description": "Unix timestamp intervals representing the time periods covered in the cost analysis.",
                    "example": "",
                    "itemType": "integer",
                    "customType": "integer[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "costList",
                    "kind": "optional",
                    "type": "array",
                    "description": "Grouped usage cost results broken down by the specified grouping criteria.",
                    "modelRef": "#/components/schemas/payment.cost.UsageGroupCosts.out",
                    "customType": "payment.cost.UsageGroupCosts.out[]",
                    "schema": [
                      {
                        "name": "groupInfos",
                        "kind": "optional",
                        "type": "map",
                        "description": "Grouping criteria key-value pairs used to aggregate these usage costs together",
                        "example": "",
                        "customType": "map<string, string>",
                        "schema": []
                      },
                      {
                        "name": "meteredUnits",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total metered usage units consumed across all time periods for this group",
                        "example": ""
                      },
                      {
                        "name": "price",
                        "kind": "optional",
                        "type": "number",
                        "description": "Final aggregated price after applying all discounts and promotional adjustments for group",
                        "example": ""
                      },
                      {
                        "name": "priceBeforeDiscounts",
                        "kind": "optional",
                        "type": "number",
                        "description": "Original calculated price before applying any prepaid credits or promotional discounts",
                        "example": ""
                      },
                      {
                        "name": "prepaidUsed",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total amount of prepaid credits consumed to reduce charges for this group",
                        "example": ""
                      },
                      {
                        "name": "priceMinusPrepaid",
                        "kind": "optional",
                        "type": "number",
                        "description": "Price after subtracting prepaid credits but before applying promotional discounts",
                        "example": ""
                      },
                      {
                        "name": "payAsYouGoPromotionUsed",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total value of pay-as-you-go promotional discounts applied to reduce charges",
                        "example": ""
                      },
                      {
                        "name": "nonPayAsYouGoPromotionUsed",
                        "kind": "optional",
                        "type": "number",
                        "description": "Total value of non-pay-as-you-go promotional discounts applied to reduce charges",
                        "example": ""
                      },
                      {
                        "name": "priceAfterPayAsYouGoPromotion",
                        "kind": "optional",
                        "type": "number",
                        "description": "Price after applying pay-as-you-go promotions but before other discount types",
                        "example": ""
                      },
                      {
                        "name": "priceAfterNonPayAsYouGoPromotion",
                        "kind": "optional",
                        "type": "number",
                        "description": "Price after applying non-pay-as-you-go promotions showing final promotional impact",
                        "example": ""
                      },
                      {
                        "name": "costs",
                        "kind": "optional",
                        "type": "array",
                        "description": "Time-series cost values showing usage and pricing statistics for each time interval",
                        "modelRef": "#/components/schemas/payment.cost.UsageGroupCostValue.out",
                        "customType": "payment.cost.UsageGroupCostValue.out[]",
                        "schema": [
                          {
                            "name": "startTimeInSeconds",
                            "kind": "optional",
                            "type": "integer<int64>",
                            "description": "Unix timestamp marking the beginning of this cost calculation time period",
                            "example": 0
                          },
                          {
                            "name": "meteredUnits",
                            "kind": "optional",
                            "type": "number",
                            "description": "Total metered usage units consumed during this time period for billing calculations",
                            "example": ""
                          },
                          {
                            "name": "price",
                            "kind": "optional",
                            "type": "number",
                            "description": "Final calculated price after applying all discounts and promotional adjustments",
                            "example": ""
                          },
                          {
                            "name": "pricePercentageDiff",
                            "kind": "optional",
                            "type": "number",
                            "description": "Percentage change in price compared to previous time period for trend analysis",
                            "example": ""
                          },
                          {
                            "name": "meterUnitsPercentageDiff",
                            "kind": "optional",
                            "type": "number",
                            "description": "Percentage change in metered units compared to previous time period for usage trends",
                            "example": ""
                          },
                          {
                            "name": "priceBeforeDiscounts",
                            "kind": "optional",
                            "type": "number",
                            "description": "Original calculated price before applying prepaid credits and promotional discounts",
                            "example": ""
                          },
                          {
                            "name": "prepaidUsed",
                            "kind": "optional",
                            "type": "number",
                            "description": "Amount of prepaid credits consumed to reduce customer charges for this period",
                            "example": ""
                          },
                          {
                            "name": "payAsYouGoPromotionUsed",
                            "kind": "optional",
                            "type": "number",
                            "description": "Value of pay-as-you-go promotional discounts applied to reduce customer charges",
                            "example": ""
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "name": "pageInfo",
                    "kind": "optional",
                    "type": "object",
                    "description": "Pagination metadata for navigating through large cost calculation result sets.",
                    "modelRef": "#/components/schemas/payment.common.PageInfo.out",
                    "customType": "payment.common.PageInfo.out",
                    "schema": [
                      {
                        "name": "pageNumber",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Current page number being returned in this response using one-indexed numbering",
                        "example": 0
                      },
                      {
                        "name": "pageSize",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Number of items per page configured for this paginated query response",
                        "example": 0
                      },
                      {
                        "name": "pageToken",
                        "kind": "optional",
                        "type": "string",
                        "description": "Token for accessing the next page of results in subsequent pagination requests",
                        "example": ""
                      },
                      {
                        "name": "totalPages",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Total number of pages available for this query across all results",
                        "example": 0
                      },
                      {
                        "name": "totalResults",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "description": "Total count of all items available across all pages for this query",
                        "example": 0
                      }
                    ]
                  }
                ]
              },
              {
                "name": "usageProfit",
                "kind": "optional",
                "type": "object",
                "description": "Calculated profit (revenue minus costs) for each group and time period.",
                "modelRef": "#/components/schemas/payment.cost.UsageProfit.out",
                "customType": "payment.cost.UsageProfit.out",
                "schema": [
                  {
                    "name": "secondsSinceEpochIntervals",
                    "kind": "optional",
                    "type": "array",
                    "description": "Array of Unix timestamps marking the start of each time interval.",
                    "example": "",
                    "itemType": "integer",
                    "customType": "integer[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "profitsList",
                    "kind": "optional",
                    "type": "array",
                    "description": "Profit breakdown for each group across all time intervals.",
                    "modelRef": "#/components/schemas/payment.cost.UsageGroupProfits.out",
                    "customType": "payment.cost.UsageGroupProfits.out[]",
                    "schema": [
                      {
                        "name": "groupInfos",
                        "kind": "optional",
                        "type": "map",
                        "description": "Dimension values that define this group, such as customerId or product.",
                        "example": "",
                        "customType": "map<string, string>",
                        "schema": []
                      },
                      {
                        "name": "priceList",
                        "kind": "optional",
                        "type": "array",
                        "description": "Array of profit values (revenue minus cost) for each time interval.",
                        "example": "",
                        "itemType": "number",
                        "customType": "number[]",
                        "itemExample": "",
                        "itemDefault": ""
                      }
                    ]
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/payment.cost.UsageDetail.out",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid request parameters such as malformed time range or invalid filters",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "401",
        "description": "Authentication required or invalid API key",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "Insufficient permissions to access billing analysis data",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "Requested product or customer not found",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "500",
        "description": "Internal server error occurred while processing the analysis",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "eLWV51mjpzk68k087FM6z",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/cost/usage-query \\\n     --header 'accept: application/json'"
        },
        {
          "id": "Ql3P9GInhCMyqnFeMviGB",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/payments/cost/usage-query\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "C0LDxYqjQxOHMbL5J-kBa",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/cost/usage-query\")\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\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "uYSecgKuPFfLXKlYYnEK2",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/cost/usage-query\"\n\npayload = {}\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": "eLWV51mjpzk68k087FM6z"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successfully retrieved usage costs, revenue and profit analysis\n{\n  \"key\": {\n    \"productId\": \"\",\n    \"timeRange\": {\n      \"startTimeInSeconds\": \"\",\n      \"endTimeInSeconds\": \"\"\n    },\n    \"timeGroupingInterval\": \"\",\n    \"filters\": \"\",\n    \"groupBy\": [\n      \"\"\n    ],\n    \"page\": {\n      \"number\": \"\",\n      \"size\": \"\",\n      \"token\": \"\"\n    },\n    \"take\": {\n      \"limit\": \"\",\n      \"isAscending\": false\n    }\n  },\n  \"usageRevenue\": {\n    \"key\": {\n      \"productId\": \"\",\n      \"timeRange\": {\n        \"startTimeInSeconds\": \"\",\n        \"endTimeInSeconds\": \"\"\n      },\n      \"timeGroupingInterval\": \"\",\n      \"filters\": \"\",\n      \"groupBy\": [\n        \"\"\n      ],\n      \"page\": {\n        \"number\": \"\",\n        \"size\": \"\",\n        \"token\": \"\"\n      },\n      \"take\": {\n        \"limit\": \"\",\n        \"isAscending\": false\n      }\n    },\n    \"secondsSinceEpochIntervals\": [\n      0\n    ],\n    \"costList\": [\n      {\n        \"groupInfos\": \"\",\n        \"meteredUnits\": 0,\n        \"price\": 0,\n        \"priceBeforeDiscounts\": 0,\n        \"prepaidUsed\": 0,\n        \"priceMinusPrepaid\": 0,\n        \"payAsYouGoPromotionUsed\": 0,\n        \"nonPayAsYouGoPromotionUsed\": 0,\n        \"priceAfterPayAsYouGoPromotion\": 0,\n        \"priceAfterNonPayAsYouGoPromotion\": 0,\n        \"costs\": [\n          {\n            \"startTimeInSeconds\": \"\",\n            \"meteredUnits\": 0,\n            \"price\": 0,\n            \"pricePercentageDiff\": 0,\n            \"meterUnitsPercentageDiff\": 0,\n            \"priceBeforeDiscounts\": 0,\n            \"prepaidUsed\": 0,\n            \"payAsYouGoPromotionUsed\": 0\n          }\n        ]\n      }\n    ],\n    \"pageInfo\": {\n      \"pageNumber\": \"\",\n      \"pageSize\": \"\",\n      \"pageToken\": \"\",\n      \"totalPages\": \"\",\n      \"totalResults\": \"\"\n    }\n  },\n  \"usageCost\": {\n    \"key\": {\n      \"productId\": \"\",\n      \"timeRange\": {\n        \"startTimeInSeconds\": \"\",\n        \"endTimeInSeconds\": \"\"\n      },\n      \"timeGroupingInterval\": \"\",\n      \"filters\": \"\",\n      \"groupBy\": [\n        \"\"\n      ],\n      \"page\": {\n        \"number\": \"\",\n        \"size\": \"\",\n        \"token\": \"\"\n      },\n      \"take\": {\n        \"limit\": \"\",\n        \"isAscending\": false\n      }\n    },\n    \"secondsSinceEpochIntervals\": [\n      0\n    ],\n    \"costList\": [\n      {\n        \"groupInfos\": \"\",\n        \"meteredUnits\": 0,\n        \"price\": 0,\n        \"priceBeforeDiscounts\": 0,\n        \"prepaidUsed\": 0,\n        \"priceMinusPrepaid\": 0,\n        \"payAsYouGoPromotionUsed\": 0,\n        \"nonPayAsYouGoPromotionUsed\": 0,\n        \"priceAfterPayAsYouGoPromotion\": 0,\n        \"priceAfterNonPayAsYouGoPromotion\": 0,\n        \"costs\": [\n          {\n            \"startTimeInSeconds\": \"\",\n            \"meteredUnits\": 0,\n            \"price\": 0,\n            \"pricePercentageDiff\": 0,\n            \"meterUnitsPercentageDiff\": 0,\n            \"priceBeforeDiscounts\": 0,\n            \"prepaidUsed\": 0,\n            \"payAsYouGoPromotionUsed\": 0\n          }\n        ]\n      }\n    ],\n    \"pageInfo\": {\n      \"pageNumber\": \"\",\n      \"pageSize\": \"\",\n      \"pageToken\": \"\",\n      \"totalPages\": \"\",\n      \"totalResults\": \"\"\n    }\n  },\n  \"usageProfit\": {\n    \"secondsSinceEpochIntervals\": [\n      0\n    ],\n    \"profitsList\": [\n      {\n        \"groupInfos\": \"\",\n        \"priceList\": [\n          0\n        ]\n      }\n    ]\n  }\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid request parameters such as malformed time range or invalid filters\n"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Authentication required or invalid API key\n"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Insufficient permissions to access billing analysis data\n"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Requested product or customer not found\n"
        },
        {
          "id": "response-5-500",
          "language": "500",
          "code": "// Internal server error occurred while processing the analysis\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}