---
title: Return a list of usage events scoped to the customer
slug: reference/return-a-list-of-usage-events-scoped-to-the-customer
docTags: 
createdAt: 2024-09-30T17:03:00.667Z
---

{
  "id": "0dj6pwwAlzrxPuAynSDJj",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://app.amberflo.io/customer-portal/usage-events",
    "servers": [
      {
        "url": "https://app.amberflo.io/customer-portal/usage-events"
      }
    ],
    "name": "Return a list of usage events scoped to the customer",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "optional",
          "name": "meterApiName",
          "type": "string",
          "description": "<p>Filter by <code>meterApiName</code>, as in the <a>meter API</a>.</p>"
        },
        {
          "kind": "optional",
          "name": "startTimeInSeconds",
          "type": "integer",
          "description": "<p>Fetch events later than this time (in seconds since <a href=\"https://en.wikipedia.org/wiki/Unix_time\" target=\"_blank\">UNIX epoch</a>).</p>"
        },
        {
          "kind": "optional",
          "name": "endTimeInSeconds",
          "type": "integer",
          "description": "<p>Fetch events earlier than this time (in seconds since <a href=\"https://en.wikipedia.org/wiki/Unix_time\" target=\"_blank\">UNIX epoch</a>).</p>"
        },
        {
          "kind": "optional",
          "name": "isAscending",
          "type": "boolean",
          "description": "<p>If true, return earliest events first.</p>"
        },
        {
          "kind": "optional",
          "name": "limit",
          "type": "integer",
          "description": "<p>Maximum number of records to fetch, between 1 and 1000 (defaults to 100).</p>"
        },
        {
          "kind": "optional",
          "name": "dimensions",
          "type": "object",
          "description": "Filter by dimension",
          "customType": "map<string, string>",
          "schema": []
        },
        {
          "kind": "required",
          "name": "sessionToken",
          "type": "string",
          "description": "<p>A required session token used to authenticate API calls made on behalf of a customer. This token is obtained from the <code>Create a session</code> endpoint and must be included with every request to authorize access.</p>"
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "api_key",
          "name": "x-api-key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful response",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "array",
            "example": "[{\"uniqueId\":\"15add96f-9187-4593-b1b8-3f40f6224c33\",\"customerId\":\"myCustomerId\",\"meterApiName\":\"ApiCalls\",\"meterValue\":200,\"meterTimeInMillis\":1649258679563,\"dimensions\":{\"region\":\"Tech\",\"zone\":\"us-east-2\"}}]",
            "description": "",
            "customType": "usage-event-list-response",
            "schema": [
              {
                "name": "customerId",
                "kind": "optional",
                "type": "string",
                "description": "customerId obtained from the Customer Portal API context.",
                "example": "myCustomerId"
              },
              {
                "name": "meterApiName",
                "kind": "optional",
                "type": "string",
                "description": "meterApiName as defined in meter-definition API.",
                "example": "ApiCalls"
              },
              {
                "name": "meterValue",
                "kind": "optional",
                "type": "number",
                "description": "Meter value to be ingested. This will be used for aggregation.",
                "example": 5
              },
              {
                "name": "meterTimeInMillis",
                "kind": "optional",
                "type": "integer",
                "description": "Number of milliseconds since the Unix Epoch (1970-01-01T00:00:00Z) and using UTC for time representation.",
                "example": 1619445706909
              },
              {
                "name": "dimensions",
                "kind": "optional",
                "type": "map",
                "description": "Dimension values for keys defined in dimensions in the meter-definition API.",
                "example": "{\"region\":\"us-west-2\"}",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/usage-event-list-response",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "D6AS_eDIgmotViZBppTal",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url 'https://app.amberflo.io/customer-portal/usage-events?dimensions=object&sessionToken=string' \\\n     --header 'accept: application/json'"
        },
        {
          "id": "-s-RVLnpCfeMsTSdL8lKA",
          "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: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/customer-portal/usage-events?dimensions=object&sessionToken=string\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "0vkMpTFcjyls4DfS4Dyne",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/customer-portal/usage-events?dimensions=object&sessionToken=string\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "yTzRldcMfipdefT8zjGLG",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/customer-portal/usage-events?dimensions=object&sessionToken=string\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "D6AS_eDIgmotViZBppTal"
    },
    "results": {
      "languages": [
        {
          "id": "RJCZxxvcqsbgOpOQlDHPm",
          "language": "200",
          "code": "// Successful response\n[\n  {\n    \"customerId\": \"myCustomerId\",\n    \"meterApiName\": \"ApiCalls\",\n    \"meterValue\": 5,\n    \"meterTimeInMillis\": 1619445706909,\n    \"dimensions\": \"{\\\"region\\\":\\\"us-west-2\\\"}\"\n  }\n]"
        }
      ],
      "selectedLanguageId": "RJCZxxvcqsbgOpOQlDHPm"
    }
  },
  "children": [
    {
      "text": "",
      "id": "du2sLQ0SpS8B7TPgNdpAU"
    }
  ]
}