> ## 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.

# Count

> Count matching usage events during a billing cycle.

`Count` measures how many matching events Lago receives during a billing cycle. Use it when each event represents one action you want to measure, such as an API call.

![Diagram of the Count aggregation, counting the number of events received in a period](https://mintcdn.com/lago-docs/L57i4PY_iDpAEuWL/guide/images/count.png?fit=max\&auto=format\&n=L57i4PY_iDpAEuWL\&q=85\&s=4a9878963e1f6d8c628cd34b09f40d7e)

Count calculation method

## Configure the metric

Each matching event adds one to the count. You do not need to select an event property.

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 **Count** as the aggregation type.
> 5. Add filters if you want to group usage by dimensions such as region or provider.
> 6. 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 calls",
>         "code": "api_calls",
>         "description": "Number of API calls",
>         "aggregation_type": "count_agg",
>         "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_calls",
  "timestamp": 1800057600,
  "properties": {}
}
```

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

Both events match the `api_calls` metric. Each adds one, so the measured quantity is 2.

> [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.