Skip to main content

Cost & Recommendations API

These endpoints expose the two things most integrations need: what you spent, and what KOSTRA recommends you do about it. All calls require the x-optscale-token header (see Authentication).

Query expenses

GET /restapi/v2/organizations/{organization_id}/clean_expenses
Returns normalized, resource-level expenses across every connected provider for the organization, filtered by the query parameters you supply. This is the endpoint to pull cost data into a data warehouse or a custom report. Common query parameters:
ParameterDescription
start_date, end_dateThe period to report, as Unix timestamps
cloud_account_idRestrict to one or more data sources — for example, a single Huawei Cloud account
pool_idRestrict to a pool in your organization structure
regionRestrict to a cloud region
resource_typeRestrict to a kind of resource
limitCap the number of records returned
Because expenses are normalized, Huawei Cloud spend is returned in the same shape as AWS, Azure, and Google Cloud, so a single integration handles all providers.

Pool expense breakdown

GET /restapi/v2/pools_expenses/{pool_id}
Returns the expense breakdown for a specific pool, useful for building per-team cost views without post-processing the full expense list.

List recommendations

GET /restapi/v2/organizations/{organization_id}/optimizations
Returns the organization’s optimization findings — the same recommendations shown in the interface, grouped by type, each with the flagged resources and their estimated savings. Use this to feed recommendations into a ticketing system or a savings dashboard. The response spans every recommendation module that applies to your connected accounts across all providers: abandoned instances, unattached volumes, obsolete snapshots, idle IPs, abandoned load balancers, abandoned object-storage buckets, database rightsizing, and more.

Recommendations for one resource

GET /restapi/v2/resources/{resource_id}/optimizations
Returns the recommendations that apply to a single resource, so you can surface “what should I do about this?” in context — for example, next to a resource in your own inventory tool.

A savings-report integration

A common pattern:
  1. GET .../optimizations to retrieve current findings and their savings.
  2. Filter to the categories or services your team owns.
  3. Push each finding to your tracker, and re-pull on a schedule so resolved items drop off as KOSTRA re-evaluates.