Define a price for a combination of filters
When a billable metric has defined filters, establish a set of filters to refine an event and assign a price to this combination.
- Add a charge to a plan (this charge should be associated with a billable metric containing filters);
- Add a new filter;
- Choose a combination of filters, either specifying a key and its value or simply the key itself (covering all values);
- Set a price for this combination of filters; and
- Optionally, provide an Invoice display name.
Set a price for a combination of filters
Here are an example of plans you can create:LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/subscriptions" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Standard plan",
"code": "standard_plan",
"interval": "monthly",
"pay_in_advance": false,
"amount_cents": 1000,
"amount_currency": "USD",
"charges": [
{
"billable_metric_id": "5d387072-e1f2-416f-b981-135c2f177069",
"invoice_display_name": null,
"charge_model": "standard",
"properties": {
"amount": "2"
},
"filters": [
{
"values": {
"region": ["africa"],
"provider": ["aws"]
},
"invoice_display_name": "Africa & AWS",
"properties": {
"amount": "1"
}
},
{
"values": {
"region": ["__ALL_FILTER_VALUES__"],
"provider": ["__ALL_FILTER_VALUES__"]
},
"invoice_display_name": "Other regions and providers",
"properties": {
"amount": "0.5"
}
}
]
}
]
}'
Define a default price
When a billable metric has filters defined, set a default price on the charge level to cover all the other combination of filters not defined in the charge.
- Add a charge to a plan (this charge should be associated with a billable metric containing filters);
- Add a default price;
- Set a price for this default price
Set a default price for a charge handling groups
Here are an example of plans you can create:LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/subscriptions" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Standard plan",
"code": "standard_plan",
"interval": "monthly",
"pay_in_advance": false,
"amount_cents": 1000,
"amount_currency": "USD",
"charges": [
{
"billable_metric_id": "5d387072-e1f2-416f-b981-135c2f177069",
"invoice_display_name": null,
"charge_model": "standard",
"properties": {
"amount": "2"
}
}
]
}'
If the default price is not set, Lago will automatically define it as 0 based on the charge model.