Customer usage
Retrieve past usage
API Reference
- Getting started
- Add-ons
- Analytics
- Billable metrics
- Coupons
- Credit notes
- Customer usage
- Customers
- Events
- Fees
- Invoices
- Organizations
- Payments
- Payment receipts
- Payment requests
- Plans
- Resources
- Subscriptions
- Taxes
- Wallets
- Webhook endpoints
- Webhooks
Customer usage
Retrieve past usage
Fetch historical customer usage data for closed billing periods.
GET
/
customers
/
{external_customer_id}
/
past_usage
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
EXTERNAL_CUSTOMER_ID="__EXTERNAL_CUSTOMER_ID__"
EXTERNAL_SUBSCRIPTION_ID="__EXTERNAL_SUBSCRIPTION_ID__"
curl --location --request GET "$LAGO_URL/api/v1/customers/$EXTERNAL_CUSTOMER_ID/past_usage?external_subscription_id=$EXTERNAL_SUBSCRIPTION_ID" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json'
{
"usage_periods": [
{
"customer_usage": {
"from_datetime": "2022-07-01T00:00:00Z",
"to_datetime": "2022-07-31T23:59:59Z",
"issuing_date": "2022-08-01",
"lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"currency": "EUR",
"amount_cents": 123,
"taxes_amount_cents": 200,
"total_amount_cents": 123,
"charges_usage": [
{
"units": "1.0",
"events_count": 10,
"amount_cents": 123,
"amount_currency": "EUR",
"charge": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"charge_model": "graduated",
"invoice_display_name": "Setup"
},
"billable_metric": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Storage",
"code": "storage",
"aggregation_type": "sum_agg"
},
"filters": [
{
"units": "0.9",
"amount_cents": 1000,
"events_count": 10,
"invoice_display_name": "AWS eu-east-1",
"values": {
"region": "us-east-1"
}
}
],
"grouped_usage": [
{
"amount_cents": 1000,
"events_count": 10,
"units": "0.9",
"grouped_by": {},
"filters": [
{
"units": "0.9",
"amount_cents": 1000,
"events_count": 10,
"invoice_display_name": "AWS eu-east-1",
"values": {
"region": "us-east-1"
}
}
]
}
]
}
]
}
}
],
"meta": {
"current_page": 2,
"next_page": 3,
"prev_page": 1,
"total_pages": 4,
"total_count": 70
}
}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
EXTERNAL_CUSTOMER_ID="__EXTERNAL_CUSTOMER_ID__"
EXTERNAL_SUBSCRIPTION_ID="__EXTERNAL_SUBSCRIPTION_ID__"
curl --location --request GET "$LAGO_URL/api/v1/customers/$EXTERNAL_CUSTOMER_ID/past_usage?external_subscription_id=$EXTERNAL_SUBSCRIPTION_ID" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json'
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Path Parameters
The customer external unique identifier (provided by your own application).
Example:
"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
Query Parameters
Page number.
Example:
1
Number of records per page.
Example:
20
The unique identifier of the subscription within your application.
Example:
"sub_1234567890"
Billable metric code filter to apply to the charge usage
Example:
"cpu"
Number of past billing period to returns in the result
Example:
5
Response
200
application/json
Customer past usage
The response is of type object
.
Was this page helpful?
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
EXTERNAL_CUSTOMER_ID="__EXTERNAL_CUSTOMER_ID__"
EXTERNAL_SUBSCRIPTION_ID="__EXTERNAL_SUBSCRIPTION_ID__"
curl --location --request GET "$LAGO_URL/api/v1/customers/$EXTERNAL_CUSTOMER_ID/past_usage?external_subscription_id=$EXTERNAL_SUBSCRIPTION_ID" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json'
{
"usage_periods": [
{
"customer_usage": {
"from_datetime": "2022-07-01T00:00:00Z",
"to_datetime": "2022-07-31T23:59:59Z",
"issuing_date": "2022-08-01",
"lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"currency": "EUR",
"amount_cents": 123,
"taxes_amount_cents": 200,
"total_amount_cents": 123,
"charges_usage": [
{
"units": "1.0",
"events_count": 10,
"amount_cents": 123,
"amount_currency": "EUR",
"charge": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"charge_model": "graduated",
"invoice_display_name": "Setup"
},
"billable_metric": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Storage",
"code": "storage",
"aggregation_type": "sum_agg"
},
"filters": [
{
"units": "0.9",
"amount_cents": 1000,
"events_count": 10,
"invoice_display_name": "AWS eu-east-1",
"values": {
"region": "us-east-1"
}
}
],
"grouped_usage": [
{
"amount_cents": 1000,
"events_count": 10,
"units": "0.9",
"grouped_by": {},
"filters": [
{
"units": "0.9",
"amount_cents": 1000,
"events_count": 10,
"invoice_display_name": "AWS eu-east-1",
"values": {
"region": "us-east-1"
}
}
]
}
]
}
]
}
}
],
"meta": {
"current_page": 2,
"next_page": 3,
"prev_page": 1,
"total_pages": 4,
"total_count": 70
}
}