Skip to main content

Events

Events represents the data delivered to lago application that will then be aggregated into billable metrics. The following endpoint explains how to send an event for a customer.

Route

POST
api/v1/events

Usage

LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request POST "$LAGO_URL/api/v1/events" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"event": {
"transaction_id": "__UNIQUE_ID__",
"customer_id": "__CUSTOMER_ID__",
"code": "__EVENT_CODE__",
"timestamp": $(date +%s),
"properties": {
"custom_field": 12
}
}
}'

Arguments

{
"event": {
"transaction_id": "__UNIQUE_ID__",
"customer_id": "__CUSTOMER_ID__",
"code": "__EVENT_CODE__",
"timestamp": 1650893379,
"properties": {
"custom_field": 12
}
}
}
AttributesTypeDescription
transaction_idString      RequiredUnique ID identifying the event.
As it will be used for idempotency, it should be a unique identifier
customer_idString      RequiredCustomer unique identifier in your application
codeString      RequiredCode identifying the type of the event.
It should match the code property of one of your active billable metrics, otherwise it will be ignored
timestampInteger      Optional
Default: event reception timestamp
Unix timestamp of the event occurence in UTC.
If not provided, the API will set the event reception time
propertiesJSON      VariableExtra data to use for the event aggregation.
When mandatory, it should contains the field_name configured at billable metric level as key and any value as field value.
Aggregation type:
- COUNT: optional
- MAX: required. value must be an integer
- SUM: required. value must be an integer
- COUNT UNIQUE: required. value could have any datatype

Responses

The event has been stored in the system and will be aggregated to generate fees.

Returns an empty response body.