> This page is for API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.eon.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.eon.io/_mcp/server.

# Query Cost Data

POST https://%7Baccount-domain%7D.console.eon.io/api/v1/cost-data
Content-Type: application/json

Retrieves cost and usage data for the given time frame.

Use Query Cost Data to analyze backup costs by cloud provider, resource type, and resource.
For details on exploring your costs visually in the Eon console, see [About Cost Explorer](/data-protection/account-administration/administration/cost-explorer/about-the-cost-explorer).


Reference: https://docs.eon.io/api/api-reference/billing/query-cost-data

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Query parameters

- `pageSize` (integer, optional) — Maximum number of cost records to return in a single response.
- `pageToken` (string, optional) — Cursor that points to the first record of the next page of results. Get this value from the previous response. To preserve the results in the same order, use the same time frame, grouping, and filters in the first request as all subsequent requests.

### Body (application/json)

This endpoint expects a QueryCostDataRequest.

- `timeFrame` (TimeFrame, required) — Time range to retrieve cost data for.
- `costUnit` (enum, optional, default: CREDITS) — Currency unit for cost amounts. Use `CREDITS` for Eon credits and `USD` for U.S. dollars. `UNSPECIFIED` is supported only in responses.
  - Allowed values: `CREDITS`, `USD`, `UNSPECIFIED`
- `usageUnit` (enum, optional, default: BYTE_MONTHS) — Whether usage is returned in byte-months, raw bytes, operations, or object-months for the specified `timeFrame`. `UNSPECIFIED` is supported only in responses.
  - Allowed values: `BYTE_MONTHS`, `BYTES`, `UNSPECIFIED`
- `granularity` (enum, optional, default: MONTHLY) — Time granularity for cost aggregation.
  - Allowed values: `HOURLY`, `DAILY`, `MONTHLY`, `TOTAL`
- `filters` (CostDataFilters, optional) — Filter conditions for cost data query. If omitted, no filtering is applied.
- `groupBy` (enum, optional, default: SOURCE_ACCOUNT) — Dimensions to group cost data by.
  - Allowed values: `SOURCE_ACCOUNT`, `CLOUD_PROVIDER`, `RESOURCE_TYPE`, `RESOURCE`, `RESOURCE_AND_VAULT`
- `topN` (integer, optional) — Limits the response to the top _n_ resources by total cost over `timeFrame`, and folds all other matching resources into one aggregated record per time period in `granularity`. Use this when a resource-level query would return too many records—for example, to build an efficient top-spenders chart without requesting every resource for every period. Applies only when grouping by `RESOURCE` or `RESOURCE_AND_VAULT`. Otherwise, ignored. Omit to return all matching resources. Aggregated records have no dimensions and typically have `resourceCount` greater than 1.

## Response

### 200

Cost data retrieved.

- `records` (list of CostDataRecord, required) — Array of cost data records matching the requested query criteria. Each record contains cost and usage information grouped by the specified dimensions and time granularity.
- `totalCount` (integer, required) — Total number of cost records that matched the time frame and filter options.
- `resourceCount` (integer, required) — Total number of resources that incurred costs during the specified time frame.
- `nextToken` (string, optional) — Cursor that points to the first record of the next page of results. Pass this value in the next request.

## Errors

### 400 Bad Request Error

Invalid request.

- `error` (string, optional)

## Types

### TimeFrame

- `startTime` (datetime, required) — Start time for the cost data query in ISO 8601 format. Must be at least 24 hours before end time.
- `endTime` (datetime, required) — End time for the cost data query in ISO 8601 format.

### CostDataFilters

- `sourceAccountProviderId` (SourceAccountProviderIdFilters, optional) — Filters for the cloud-provider-assigned account IDs.
- `cloudProvider` (CloudProviderFilters, optional) — Filters for cloud providers.
- `resourceType` (ResourceTypeFilters, optional) — Filters for specific resource types.
- `resourceId` (IdFilters, optional) — Filters for Eon-assigned resource IDs.
- `tagKeys` (TagKeysFilters, optional) — Filters for resource tag keys.
- `tagKeyValues` (TagKeyValuesFilters, optional) — Filters for resource tag key-value pairs.

### CostDataRecord

Total cost for this metering dimension in the specified currency unit.

- `recordTimeFrame` (TimeFrame, required) — Time period covered by the cost record. Aligns with the requested granularity.
- `costs` (list of CostDataRecordCost, required) — Array of cost breakdowns by metering dimension.
- `resourceCount` (integer, optional) — Number of unique resources that contributed to costs in this record's time frame.
- `dimensions` (CostDataRecordDimensions, optional) — Grouping dimensions for the cost record.

### SourceAccountProviderIdFilters

- `in` (list of string, optional) — Matches if any value in this list equals `sourceAccountProviderId`.
- `notIn` (list of string, optional) — Matches if none of the values in this list equal `sourceAccountProviderId`.

### CloudProviderFilters

- `in` (list of enum, optional) — Matches if any value in this list equals `cloudProvider`.
  - Allowed values: `AWS`, `AZURE`, `GCP`, `MONGO_ATLAS`, `PROVIDER_UNSPECIFIED`
- `notIn` (list of enum, optional) — Matches if none of the values in this list equal `cloudProvider`.
  - Allowed values: `AWS`, `AZURE`, `GCP`, `MONGO_ATLAS`, `PROVIDER_UNSPECIFIED`

### ResourceTypeFilters

- `in` (list of enum, optional) — Matches if any value in this list equals `resourceType`.
  - Allowed values: `AWS_EC2`, `AWS_RDS`, `AWS_S3`, `AWS_EFS`, `AWS_FSX`, `AWS_EKS_NAMESPACE`, `AWS_DYNAMO_DB`, `AZURE_VIRTUAL_MACHINE`, `AZURE_FILE_SHARE`, `AZURE_STORAGE_ACCOUNT`, `AZURE_DISK`, `AZURE_SQL_DATABASE`, `AZURE_SQL_MANAGED_INSTANCE`, `AZURE_SQL_VIRTUAL_MACHINE`, `AZURE_MYSQL`, `AZURE_POSTGRESQL`, `AZURE_COSMOSDB_MONGODB`, `AZURE_COSMOSDB_NOSQL`, `ATLAS_MONGODB_CLUSTER`, `GCP_COMPUTE_ENGINE_INSTANCE`, `GCP_CLOUD_SQL_INSTANCE`, `GCP_CLOUD_STORAGE_BUCKET`, `RESOURCE_TYPE_UNSPECIFIED`
- `notIn` (list of enum, optional) — Matches if no value in this list equals `resourceType`.
  - Allowed values: `AWS_EC2`, `AWS_RDS`, `AWS_S3`, `AWS_EFS`, `AWS_FSX`, `AWS_EKS_NAMESPACE`, `AWS_DYNAMO_DB`, `AZURE_VIRTUAL_MACHINE`, `AZURE_FILE_SHARE`, `AZURE_STORAGE_ACCOUNT`, `AZURE_DISK`, `AZURE_SQL_DATABASE`, `AZURE_SQL_MANAGED_INSTANCE`, `AZURE_SQL_VIRTUAL_MACHINE`, `AZURE_MYSQL`, `AZURE_POSTGRESQL`, `AZURE_COSMOSDB_MONGODB`, `AZURE_COSMOSDB_NOSQL`, `ATLAS_MONGODB_CLUSTER`, `GCP_COMPUTE_ENGINE_INSTANCE`, `GCP_CLOUD_SQL_INSTANCE`, `GCP_CLOUD_STORAGE_BUCKET`, `RESOURCE_TYPE_UNSPECIFIED`

### IdFilters

- `in` (list of string, optional) — Matches if any string in this list equals `id`.
- `notIn` (list of string, optional) — Matches if no string in this list equals `id`.

### TagKeysFilters

- `containsAllOf` (list of string, optional) — Matches if any key in this list is in the `tags` keys list.
- `containsAnyOf` (list of string, optional) — Matches if none of the keys in this list are in the `tags` keys list.
- `containsNoneOf` (list of string, optional) — Matches if all keys in this list are in the `tags` keys list.

### TagKeyValuesFilters

- `containsAllOf` (list of string, optional) — Matches if any `{key}={value}` pair in this list is in the `tags` list.
- `containsAnyOf` (list of string, optional) — Matches if none of the `{key}={value}` pairs in this list are in the `tags` list.
- `containsNoneOf` (list of string, optional) — Matches if all `{key}={value}` pairs in this list are in the `tags` list.

### CostDataRecordCost

Cost and usage breakdown for a specific billable usage type.

- `meteringDimension` (enum, required) — Type of resource usage being metered and billed across different cloud providers. Each dimension represents a specific billable resource type, such as compute instances, storage volumes, database services, or data transfer. Used to categorize costs by service type for detailed analysis and chargeback reporting.
  - Allowed values: `AWS_EC2_METERING_DIMENSION`, `AWS_EC2_NATIVE_METERING_DIMENSION`, `AWS_RDS_METERING_DIMENSION`, `AWS_S3_METERING_DIMENSION`, `AWS_DYNAMO_DB_METERING_DIMENSION`, `AWS_EKS_METERING_DIMENSION`, `AZURE_VIRTUAL_MACHINE_METERING_DIMENSION`, `AZURE_STORAGE_ACCOUNT_METERING_DIMENSION`, `AZURE_SQL_VIRTUAL_MACHINE_METERING_DIMENSION`, `AZURE_SQL_DATABASE_METERING_DIMENSION`, `AZURE_POSTGRESQL_METERING_DIMENSION`, `GCP_VM_INSTANCE_METERING_DIMENSION`, `GCP_CLOUD_STORAGE_METERING_DIMENSION`, `GCP_CLOUD_SQL_POSTGRES_SQL_METERING_DIMENSION`, `GCP_CLOUD_SQL_MYSQL_METERING_DIMENSION`, `GCP_CLOUD_SQL_SQL_SERVER_METERING_DIMENSION`, `GCP_BIG_QUERY_METERING_DIMENSION`, `MONGO_ATLAS_CLUSTER_METERING_DIMENSION`, `DATA_TRANSFER_METERING_DIMENSION`, `CLASSIFICATION_METERING_DIMENSION`, `AWS_EC2_TO_AZURE_VAULT_METERING_DIMENSION`, `AWS_S3_TO_AZURE_VAULT_METERING_DIMENSION`, `AWS_RDS_TO_AZURE_VAULT_METERING_DIMENSION`, `AWS_DYNAMO_DB_TO_AZURE_VAULT_METERING_DIMENSION`, `AWS_EKS_TO_AZURE_VAULT_METERING_DIMENSION`, `AZURE_VIRTUAL_MACHINE_TO_AWS_VAULT_METERING_DIMENSION`, `AZURE_STORAGE_ACCOUNT_TO_AWS_VAULT_METERING_DIMENSION`, `AZURE_SQL_VIRTUAL_MACHINE_TO_AWS_VAULT_METERING_DIMENSION`, `GCP_VM_INSTANCE_TO_AZURE_VAULT_METERING_DIMENSION`, `GCP_CLOUD_STORAGE_TO_AZURE_VAULT_METERING_DIMENSION`, `AWS_EC2_TO_GCP_VAULT_METERING_DIMENSION`, `AWS_S3_TO_GCP_VAULT_METERING_DIMENSION`, `AWS_EKS_TO_GCP_VAULT_METERING_DIMENSION`, `AZURE_VIRTUAL_MACHINE_TO_GCP_VAULT_METERING_DIMENSION`, `AZURE_STORAGE_ACCOUNT_TO_GCP_VAULT_METERING_DIMENSION`, `GCP_VM_INSTANCE_TO_AWS_VAULT_METERING_DIMENSION`, `GCP_CLOUD_STORAGE_TO_AWS_VAULT_METERING_DIMENSION`, `STORAGE_GATEWAY_METERING_DIMENSION`, `RANSOMWARE_PROTECTED_STORAGE_METERING_DIMENSION`
- `cost` (Cost, required)
- `usage` (Usage, required) — Raw usage amount and unit that generated the associated cost.

### CostDataRecordDimensions

Grouping dimensions that categorize this cost record. Contains metadata about the cloud provider, resource type, resource ID, and source account that generated these costs.

- `cloudProvider` (enum, optional) — Cloud provider where the costs were incurred.
  - Allowed values: `AWS`, `AZURE`, `GCP`, `MONGO_ATLAS`, `PROVIDER_UNSPECIFIED`
- `resourceType` (enum, optional) — Type of cloud resource that generated the costs.
  - Allowed values: `AWS_EC2`, `AWS_RDS`, `AWS_S3`, `AWS_EFS`, `AWS_FSX`, `AWS_EKS_NAMESPACE`, `AWS_DYNAMO_DB`, `AZURE_VIRTUAL_MACHINE`, `AZURE_FILE_SHARE`, `AZURE_STORAGE_ACCOUNT`, `AZURE_DISK`, `AZURE_SQL_DATABASE`, `AZURE_SQL_MANAGED_INSTANCE`, `AZURE_SQL_VIRTUAL_MACHINE`, `AZURE_MYSQL`, `AZURE_POSTGRESQL`, `AZURE_COSMOSDB_MONGODB`, `AZURE_COSMOSDB_NOSQL`, `ATLAS_MONGODB_CLUSTER`, `GCP_COMPUTE_ENGINE_INSTANCE`, `GCP_CLOUD_SQL_INSTANCE`, `GCP_CLOUD_STORAGE_BUCKET`, `RESOURCE_TYPE_UNSPECIFIED`
- `resourceId` (string, optional) — Eon-assigned resource ID.
- `sourceAccountProviderId` (string, optional) — Cloud-provider-assigned account ID for the source account.

### Cost

- `amount` (double, required) — Cost amount in the specified currency unit. 1 credit is equivalent to 0.01 USD.
- `unit` (enum, required, default: CREDITS) — Currency unit.
  - Allowed values: `CREDITS`, `USD`, `UNSPECIFIED`

### Usage

Raw usage amount and unit that generated the associated cost.

- `amount` (double, required) — Raw usage quantity that generated the cost.
- `unit` (enum, required, default: BYTE_MONTHS) — Unit of measurement for the usage amount
  - Allowed values: `BYTE_MONTHS`, `BYTES`, `UNSPECIFIED`

## Examples

**Request**

```json
{
  "timeFrame": {
    "startTime": "2025-01-01T00:00:00Z",
    "endTime": "2025-01-31T23:59:59Z"
  }
}
```

**Response**

```json
{
  "records": [
    {
      "recordTimeFrame": {
        "startTime": "2025-01-01T00:00:00Z",
        "endTime": "2025-01-31T23:59:59Z"
      },
      "costs": [
        {
          "meteringDimension": "AWS_EC2_METERING_DIMENSION",
          "cost": {
            "amount": 150.75,
            "unit": "CREDITS"
          },
          "usage": {
            "amount": 1073741824,
            "unit": "BYTES"
          }
        }
      ],
      "resourceCount": 10,
      "dimensions": {
        "cloudProvider": "AWS",
        "resourceType": "AWS_EC2",
        "resourceId": "123e4567-e89b-12d3-a456-426614174000",
        "sourceAccountProviderId": "123456789012"
      }
    }
  ],
  "totalCount": 1543,
  "resourceCount": 2000,
  "nextToken": "eyJvZmZzZXQiOjEwMCwic29ydCI6InRpbWVGcmFtZSJ9"
}
```

**SDK Code**

```python
import requests

url = "https://{account-domain}.console.eon.io/api/v1/cost-data"

querystring = {"pageSize":"100"}

payload = { "timeFrame": {
        "startTime": "2025-01-01T00:00:00Z",
        "endTime": "2025-01-31T23:59:59Z"
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://{account-domain}.console.eon.io/api/v1/cost-data?pageSize=100';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"timeFrame":{"startTime":"2025-01-01T00:00:00Z","endTime":"2025-01-31T23:59:59Z"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://{account-domain}.console.eon.io/api/v1/cost-data?pageSize=100")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"timeFrame\": {\n    \"startTime\": \"2025-01-01T00:00:00Z\",\n    \"endTime\": \"2025-01-31T23:59:59Z\"\n  }\n}")
  .asString();
```