---
title: /payments/cost/usage-cost
slug: amberflo-api/paymentscostusage-cost
docTags: 
createdAt: 2024-11-07T15:10:16.978Z
---

{
  "id": "2Y7sZKe8mcxMWotEL94IA",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/cost/usage-cost",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/cost/usage-cost"
      }
    ],
    "name": "",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment.cost.UsageCostsKey.in",
          "schema": [
            {
              "name": "productId",
              "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": "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": "filters",
              "kind": "optional",
              "type": "map",
              "example": "",
              "customType": "map<string, string[]>",
              "schema": []
            },
            {
              "name": "groupBy",
              "kind": "optional",
              "type": "array",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "page",
              "kind": "optional",
              "type": "object",
              "description": "",
              "modelRef": "#/components/schemas/payment.common.Page.in",
              "customType": "payment.common.Page.in",
              "schema": [
                {
                  "name": "number",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "example": 0
                },
                {
                  "name": "size",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "example": 0
                },
                {
                  "name": "token",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                }
              ]
            },
            {
              "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": ""
                }
              ]
            }
          ],
          "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": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "payment.cost.UsageCosts.out",
            "schema": [
              {
                "name": "key",
                "kind": "optional",
                "type": "object",
                "description": "",
                "modelRef": "#/components/schemas/payment.cost.UsageCostsKey.out",
                "customType": "payment.cost.UsageCostsKey.out",
                "schema": [
                  {
                    "name": "productId",
                    "kind": "optional",
                    "type": "string",
                    "example": ""
                  },
                  {
                    "name": "timeRange",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.common.TimeRange.out",
                    "customType": "payment.common.TimeRange.out",
                    "schema": [
                      {
                        "name": "startTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      },
                      {
                        "name": "endTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      }
                    ]
                  },
                  {
                    "name": "timeGroupingInterval",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "modelRef": "#/components/schemas/com.amberflo.service.common.aggregation.AggregationInterval.out",
                    "customType": "com.amberflo.service.common.aggregation.AggregationInterval.out",
                    "schema": []
                  },
                  {
                    "name": "filters",
                    "kind": "optional",
                    "type": "map",
                    "example": "",
                    "customType": "map<string, string[]>",
                    "schema": []
                  },
                  {
                    "name": "groupBy",
                    "kind": "optional",
                    "type": "array",
                    "example": "",
                    "itemType": "string",
                    "customType": "string[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "page",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.common.Page.out",
                    "customType": "payment.common.Page.out",
                    "schema": [
                      {
                        "name": "number",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "example": 0
                      },
                      {
                        "name": "size",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "example": 0
                      },
                      {
                        "name": "token",
                        "kind": "optional",
                        "type": "string",
                        "example": ""
                      }
                    ]
                  },
                  {
                    "name": "take",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.common.Take.out",
                    "customType": "payment.common.Take.out",
                    "schema": [
                      {
                        "name": "limit",
                        "kind": "optional",
                        "type": "integer<int32>",
                        "example": 0
                      },
                      {
                        "name": "isAscending",
                        "kind": "optional",
                        "type": "boolean",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "secondsSinceEpochIntervals",
                "kind": "optional",
                "type": "array",
                "example": "",
                "itemType": "integer",
                "customType": "integer[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "costList",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/payment.cost.UsageGroupCosts.out",
                "customType": "payment.cost.UsageGroupCosts.out[]",
                "schema": [
                  {
                    "name": "groupInfos",
                    "kind": "optional",
                    "type": "map",
                    "example": "",
                    "customType": "map<string, string>",
                    "schema": []
                  },
                  {
                    "name": "meteredUnits",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "price",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "priceBeforeDiscounts",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "prepaidUsed",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "priceMinusPrepaid",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "payAsYouGoPromotionUsed",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "nonPayAsYouGoPromotionUsed",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "priceAfterPayAsYouGoPromotion",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "priceAfterNonPayAsYouGoPromotion",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "costs",
                    "kind": "optional",
                    "type": "array",
                    "description": "",
                    "modelRef": "#/components/schemas/payment.cost.UsageGroupCostValue.out",
                    "customType": "payment.cost.UsageGroupCostValue.out[]",
                    "schema": [
                      {
                        "name": "startTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      },
                      {
                        "name": "meteredUnits",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "price",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "pricePercentageDiff",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "meterUnitsPercentageDiff",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "priceBeforeDiscounts",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "prepaidUsed",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "payAsYouGoPromotionUsed",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "pageInfo",
                "kind": "optional",
                "type": "object",
                "description": "",
                "modelRef": "#/components/schemas/payment.common.PageInfo.out",
                "customType": "payment.common.PageInfo.out",
                "schema": [
                  {
                    "name": "pageNumber",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "example": 0
                  },
                  {
                    "name": "pageSize",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "example": 0
                  },
                  {
                    "name": "pageToken",
                    "kind": "optional",
                    "type": "string",
                    "example": ""
                  },
                  {
                    "name": "totalPages",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "example": 0
                  },
                  {
                    "name": "totalResults",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "example": 0
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/payment.cost.UsageCosts.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "FYGlXi82X7QGqJRWmSNLh",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/cost/usage-cost \\\n     --header 'accept: application/json'"
        },
        {
          "id": "foHrbkGgyYdSJSJULAZax",
          "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-cost\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "qaAFCrKbMPW0rXcPrEFvM",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/cost/usage-cost\")\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": "4S9MNquAd3b47H0Wo8yKq",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/cost/usage-cost\"\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": "FYGlXi82X7QGqJRWmSNLh"
    },
    "results": {
      "languages": [
        {
          "id": "MSosYRVTPclDuWcsjMRkr",
          "language": "200",
          "code": "// Successful request\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  \"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}"
        }
      ],
      "selectedLanguageId": "MSosYRVTPclDuWcsjMRkr"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}