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

# Dynamic rate model

> Bill the amounts your application sends with usage events.

Dynamic pricing uses the monetary amount your application sends with each usage event. Use it when your application calculates the amount to bill.

## How it works

* The Product's billable metric must use Sum (`sum_agg`). It measures the quantity, for example the units in each event.
* Each event sends its own total in `precise_total_amount_cents`: a finite amount in cents, as a number or decimal string.
* The fee is the sum of those event amounts for the period.

Send the measured quantity in `properties` and the event's total monetary amount in `precise_total_amount_cents`. Lago aggregates the quantity and sums the monetary amounts separately.

## Availability

* Fixed Products: not available.
* Metered Products: Sum metrics only, with `recurring: false` or `recurring: true` without proration. Arrears and advance.

See the [availability matrix](https://getlago.com/docs/v2/guide/rate-cards/pricing-models/overview.md#model-availability).

## Configure the rate

Set `rate_model` to `dynamic`. The model needs no `rate_properties`.

```bash Create a dynamic rate theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request POST "$LAGO_URL/api/v2/rate_cards/sms_messages_usd/rates" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "rate": {
      "code": "sms_dynamic",
      "effective_from": "2027-01-01T00:00:00Z",
      "rate_model": "dynamic",
      "billing_interval_count": 1,
      "billing_interval_unit": "month"
    }
  }'
```

```bash Send events with their amounts theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/events/batch" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "events": [
      {
        "transaction_id": "sms_0001",
        "code": "sms_units",
        "external_contract_id": "contract_example",
        "precise_total_amount_cents": "70",
        "properties": { "units": "7" }
      },
      {
        "transaction_id": "sms_0002",
        "code": "sms_units",
        "external_contract_id": "contract_example",
        "precise_total_amount_cents": "55",
        "properties": { "units": "5" }
      }
    ]
  }'
```

## Example

This example uses a metered Product, `sms_messages`, and `sms_units`, a Sum metric on the `units` property. Two events fall within the same full monthly billing period. The Rate Card uses USD, with no proration or spending minimum:

| Event | `units` | `precise_total_amount_cents` |
| - | - | - |
| `sms_0001` | 7 | 70 |
| `sms_0002` | 5 | 55 |
| **Total** | **12** | **125** |

The measured quantity is 12 units. The calculated fee is 1.25 USD before tax: 70 + 55 = 125 cents.

Send `precise_total_amount_cents` on every event priced this way.

## Check the result

Compare the sum of event quantities with the measured quantity, and the sum of event amounts with the calculated fee. Check these two totals separately. Use [Contract current usage](https://getlago.com/docs/v2/guide/events/retrieve-usage.md#retrieve-current-usage) to inspect provisional values. See [Rates](https://getlago.com/docs/v2/guide/rate-cards/rates.md#check-which-rate-was-used) to check which Rate applies.

> [card] [Usage ingestion](https://getlago.com/docs/v2/guide/events/ingesting-usage.md)
>
> Send events to a Contract.

> [card] [Pricing models](https://getlago.com/docs/v2/guide/rate-cards/pricing-models/overview.md)
>
> Compare every rate model.

> [card] [Ingest a batch of events](https://getlago.com/docs/v2/api-reference/events/batch.md)
>
> `POST /events/batch`

> [card] [Create a rate](https://getlago.com/docs/v2/api-reference/rates/create.md)
>
> `POST /rate_cards/{rate_card_code}/rates`


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