# Savings

> What your accepted recommendations actually saved: the aggregate, the row-by-row audit trail, and the parameters that narrow it.

Source: https://docs.levelfour.ai/resources/savings


These methods read what your accepted recommendations actually saved. [Get summary](#get-summary) returns the aggregate. [List savings](#list-savings) returns one row per implemented saving, carrying the cost before and after the optimization, the period, and the return on investment.

[Pagination](/pagination) has the defaults, the page-size cap, and the auto-paginating iterators the examples below rely on.

## Get summary

Returns the aggregate across every realized saving: total saved, the monthly savings rate, and the split by provider.

**Python**

```python  
summary = client.recommendations.audit.get_summary()
```

**TypeScript**

```typescript  
const summary = await client.recommendations.audit.getSummary();
```

**Go**

```go  
summary, err := client.Recommendations.Audit.GetSummary(ctx)
```

## List savings

Returns a page of implemented savings, filtered by date, provider, service, environment or account.

**Python**

```python  
page = client.recommendations.audit.list(
    page=1,
    page_size=50,
    sort_by="monthly_savings",
    sort_order="desc",
    provider="aws",
    start="2025-01-01",
    end="2025-03-31",
)

for item in page:
    print(f"{item.service}: ${item.monthly_savings}/mo (ROI: {item.roi}x)")
```

**TypeScript**

```typescript  
for await (const item of await client.recommendations.audit.list({
    page_size: 50,
    sort_by: "monthly_savings",
    sort_order: "desc",
    provider: "aws",
    start: "2025-01-01",
    end: "2025-03-31",
})) {
    console.log(`${item.service}: $${item.monthly_savings}/mo`);
}
```

**Go**

```go  
page, err := client.Recommendations.Audit.List(ctx, &levelfour.ListAuditRequest{
    PageSize:  levelfour.Int(50),
    SortBy:    levelfour.String("monthly_savings"),
    SortOrder: levelfour.ListAuditRequestSortOrder("desc").Ptr(),
    Provider:  levelfour.String("aws"),
    Start:     levelfour.String("2025-01-01"),
    End:       levelfour.String("2025-03-31"),
})

iter := page.Iterator()
for iter.Next(ctx) {
    item := iter.Current()
    fmt.Printf("%s: $%.2f/mo\n", item.Service, item.MonthlySavings)
}
```

### Parameters

| Parameter     | Type       | Description                                                                                                                                                                                            |
| ------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `page`        | `int`      | Page number, 1-indexed                                                                                                                                                                                 |
| `page_size`   | `int`      | Items per page                                                                                                                                                                                         |
| `sort_by`     | `string`   | Sort field: `period`, `account_id`, `environment`, `service`, `usage_type`, `usage_quantity`, `usage_unit`, `pre_optimization_cost`, `post_optimization_cost`, `monthly_savings`, `roi`, `approved_by` |
| `sort_order`  | `string`   | `asc` or `desc`                                                                                                                                                                                        |
| `start`       | `string`   | Start date (`YYYY-MM-DD` or `YYYY-MM`)                                                                                                                                                                 |
| `end`         | `string`   | End date (`YYYY-MM-DD` or `YYYY-MM`)                                                                                                                                                                   |
| `preset`      | `string`   | Date preset: `30D`, `6M`, or `12M`                                                                                                                                                                     |
| `provider`    | `string`   | Filter by provider: `aws`, `gcp`, `azure`, `k8s`                                                                                                                                                       |
| `service`     | `string[]` | Filter by service(s)                                                                                                                                                                                   |
| `environment` | `string[]` | Filter by environment(s)                                                                                                                                                                               |
| `account_id`  | `string[]` | Filter by account ID(s)                                                                                                                                                                                |

> **Warning**
>
> `preset` takes precedence over `start` and `end`. Send all three and the window you get back is the preset's, not the dates you typed.

## SavedItem

The row shape [List savings](#list-savings) returns.

| Field                    | Type      | Description                                                                |
| ------------------------ | --------- | -------------------------------------------------------------------------- |
| `audit_id`               | `int`     | The row's id. [Get one realized saving](#get-one-realized-saving) takes it |
| `recommendation_id`      | `string`  | The recommendation that produced this saving                               |
| `period`                 | `string`  | Savings period identifier                                                  |
| `account_id`             | `string?` | Cloud account ID                                                           |
| `environment`            | `string?` | Environment tag                                                            |
| `service`                | `string`  | Cloud service name                                                         |
| `usage_type`             | `string`  | Type of usage                                                              |
| `usage_quantity`         | `float`   | Quantity of usage                                                          |
| `usage_unit`             | `string`  | Unit of usage                                                              |
| `approved_by`            | `string?` | Who approved the optimization                                              |
| `pre_optimization_cost`  | `float`   | Cost before optimization                                                   |
| `post_optimization_cost` | `float`   | Cost after optimization                                                    |
| `monthly_savings`        | `float`   | Monthly savings amount                                                     |
| `annual_savings`         | `float`   | Annual savings amount                                                      |
| `roi`                    | `float`   | Return on investment                                                       |

> **Warning**
>
> Each row carries a full monthly rate. Adding `monthly_savings` down a filtered list gives you a run rate, not the cash saved inside the window you filtered.

## Get one realized saving

Returns one audited saving in full: who approved it, how it was applied and when, the change recorded in your cloud account, the savings measured after 7 and 30 days, and the saving broken down line by line per usage type. The id is the numeric `audit_id` a row from [List savings](#list-savings) carries.

**Go**

```go  
detail, err := client.Audit.GetRealizedAuditDetail(ctx, 4821)
```

**HTTP**

```bash  
curl -s "https://api.levelfour.ai/api/v1/recommendations/audit/realized/4821" \
  -H "Authorization: Bearer $LEVELFOUR_API_KEY"
```

## Savings by provider

[Get summary](#get-summary) returns the split by provider in one call. For one provider's totals on their own, the [Providers](/resources/providers) page owns [Get realized savings summary](/resources/providers#get-realized-savings-summary), which the example below calls once per provider.

**Python**

```python  
from levelfour import LevelFour

client = LevelFour()

for provider in ["aws", "gcp", "azure"]:
    summary = client.recommendations.audit.get_provider_summary(provider)
    print(f"{provider}: {summary}")
```

**TypeScript**

```typescript  
import { LevelFourClient } from "levelfour";

const client = new LevelFourClient();

for (const provider of ["aws", "gcp", "azure"]) {
    const summary = await client.recommendations.audit.getProviderSummary({
        provider_id: provider,
    });
    console.log(`${provider}:`, summary);
}
```

**Go**

```go  
for _, provider := range []string{"aws", "gcp", "azure"} {
    summary, err := client.Recommendations.Audit.GetProviderSummary(ctx, provider)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s: %v\n", provider, summary)
}
```

## Next

* [Recommendations](/resources/recommendations) is the potential side: opportunities LevelFour has found and nobody has applied yet
* [Providers](/resources/providers) scopes realized savings, recommendations and costs to one cloud
* [Pagination](/pagination) has the defaults behind `page` and `page_size`, and the iterators that page for you
* [`/api-reference/audit`](/api-reference/audit) is the generated REST reference for the endpoints behind these methods
