lago_types/models/
event.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4use uuid::Uuid;
5
6/// Represents a usage measurement event in the Lago billing system.
7///
8/// Events are used to track customer usage and are aggregated into invoice
9/// line items based on billable metrics.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Event {
12    /// Unique identifier for the event in Lago
13    pub lago_id: Uuid,
14    /// External transaction reference provided when creating the event
15    pub transaction_id: String,
16    /// Lago ID of the associated customer (may be null)
17    pub lago_customer_id: Option<Uuid>,
18    /// Billable metric code
19    pub code: String,
20    /// Event occurrence timestamp
21    pub timestamp: DateTime<Utc>,
22    /// Lago ID of the linked subscription (may be null)
23    pub lago_subscription_id: Option<Uuid>,
24    /// External subscription reference
25    pub external_subscription_id: String,
26    /// Record creation timestamp
27    pub created_at: DateTime<Utc>,
28    /// Precise amount calculation in cents
29    pub precise_total_amount_cents: Option<i64>,
30    /// Custom event metadata/properties
31    pub properties: Option<Value>,
32}