> ## Documentation Index
> Fetch the complete documentation index at: https://getlago.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Latest

> Use the most recent value reported for an event property during a billing cycle.

`Latest` measures the last reported value of an event property in the billing cycle. Lago uses the value with the latest event timestamp. Use it when your application reports a current value and you want the last reading, rather than a total of all readings.

![Diagram of the Latest aggregation, keeping the value of the most recent event](https://mintcdn.com/lago-docs/L57i4PY_iDpAEuWL/guide/images/latest.png?fit=max\&auto=format\&n=L57i4PY_iDpAEuWL\&q=85\&s=881b2357be5ea1f21d6d24f9896b28bb)

Latest calculation method

## Configure the metric

Set `field_name` to the event property you want to measure.

Set `recurring` to `false`. This aggregation does not support carrying the quantity into the next billing cycle. Lago resets the measured quantity at the end of each cycle.

## Create the metric

> [tab] Dashboard
>
> 1. Go to **Billable metrics** in the side menu.
> 2. Create a new billable metric.
> 3. Enter a name, a code and an optional description.
> 4. Select **Latest** as the aggregation type.
> 5. Select the event property you want to measure.
> 6. Add filters if you want to group usage by dimensions such as region or provider.
> 7. Click **Add billable metric**.

> [tab] API
>
> ```bash theme={"dark"}
> LAGO_URL="https://api.getlago.com"
> API_KEY="__YOUR_API_KEY__"
>
> curl --location --request POST "$LAGO_URL/api/v2/billable_metrics" \
>   --header "Authorization: Bearer $API_KEY" \
>   --header 'Content-Type: application/json' \
>   --data-raw '{
>       "billable_metric": {
>         "name": "API requests",
>         "code": "api_requests",
>         "description": "Latest reported number of API requests.",
>         "aggregation_type": "latest_agg",
>         "field_name": "total_requests",
>         "recurring": false
>       }
>     }'
> ```

## Calculation example

The two example events below belong to `contract_example` and the same billing cycle. Their timestamps are January 16 and 17, 2027 at 00:00 UTC.

```json Event 1 theme={"dark"}
{
  "transaction_id": "transaction_1",
  "external_contract_id": "contract_example",
  "code": "api_requests",
  "timestamp": 1800057600,
  "properties": {
    "total_requests": 20
  }
}
```

```json Event 2 theme={"dark"}
{
  "transaction_id": "transaction_2",
  "external_contract_id": "contract_example",
  "code": "api_requests",
  "timestamp": 1800144000,
  "properties": {
    "total_requests": 10
  }
}
```

The first event reports 20 and the later event reports 10. Lago uses the later reading, so the measured quantity is 10.

> [card] [Aggregation examples](https://getlago.com/docs/v2/guide/billable-metrics/aggregation-types/aggregation-examples.md)
>
> Compare how aggregation types calculate usage.

> [card] [Metered products](https://getlago.com/docs/v2/guide/product-catalog/metered-products.md)
>
> Connect your metric to a Product.

> [card] [Create a billable metric (API)](https://getlago.com/docs/v2/api-reference/billable-metrics/create.md)
>
> `POST /billable_metrics`

> [card] [Ingest usage](https://getlago.com/docs/v2/guide/events/ingesting-usage.md)
>
> Send usage events to Lago.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.