- Documentation
- API References
- Integrations
- Templates
- Blog
- FAQ
- GitHub
- Getting started
Add-ons
Analytics
Billable metrics
Coupons
Credit notes
Customer usage
Customers
Events
Fees
Invoices
Organizations
Plans
Resources
Subscriptions
Taxes
Wallets
Webhook endpoints
Webhooks
API Reference
Batch usage events
This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/events/batch" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"events": [
{
"transaction_id": "__UNIQUE_ID__",
"external_subscription_id": "__YOUR_SUBSCRIPTION_ID__",
"code": "__BILLABLE_METRIC_CODE__",
"timestamp": $(date +%s),
"properties": {
"custom_field": 12
}
}
]
}'
This response has no body data.
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
This field represents a unique identifier for the event. It is crucial for ensuring idempotency, meaning that each event can be uniquely identified and processed without causing any unintended side effects.
The customer external unique identifier (provided by your own application). This field is optional if you send the external_subscription_id
, targeting a specific subscription.
This field is deprecated and is no longer supported or maintained. Please use the external_subscription_id
instead.
The unique identifier of the subscription within your application. It is a mandatory field when the customer possesses multiple subscriptions or when the external_customer_id
is not provided.
The code that identifies a targeted billable metric. It is essential that this code matches the code
property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC). If this timestamp is not provided, the API will automatically set it to the time of event reception. You can also provide miliseconds precision by appending decimals to the timestamp.
This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a sum_agg
, max_agg
, or unique_count_agg
aggregation method. However, when using a simple count_agg
, this object is not required.
Was this page helpful?
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/events/batch" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"events": [
{
"transaction_id": "__UNIQUE_ID__",
"external_subscription_id": "__YOUR_SUBSCRIPTION_ID__",
"code": "__BILLABLE_METRIC_CODE__",
"timestamp": $(date +%s),
"properties": {
"custom_field": 12
}
}
]
}'
This response has no body data.