Events
Events are the foundation of usage-based billing in Monk. When customers use your product, you send events to Monk, which aggregates them into billable usage on invoices.What is an Event?
An event is a record of something billable happening in your system:- Immutable — Once accepted, events cannot be modified
- Timestamped — Each event has a timestamp for billing period assignment
- Customer-attributed — Every event is tied to a customer
- Schema-flexible — Properties can contain any key-value metadata
How Events Work
- Ingestion — Your app sends events via the Events API
- Storage — Events are durably persisted
- Aggregation — Meters query events and compute usage (COUNT, SUM, MAX, etc.)
- Billing — Aggregated usage updates invoice line items
Event Schema
| Field | Required | Description |
|---|---|---|
customerId | Yes* | Monk’s internal customer UUID |
externalCustomerId | Yes* | Your external customer identifier |
eventName | Yes | Identifies the type of event |
properties | No | Key-value metadata (strings, numbers, booleans) |
timestamp | No | ISO 8601 timestamp (defaults to now). Must not be more than 1 hour in the future. |
idempotencyKey | No | Unique key to prevent duplicates |
customerId or externalCustomerId must be provided.
Properties
Properties are flexible metadata attached to each event:- Aggregate values — Sum a property like
tokensfor token-based billing - Filter events — Bill differently by region or model
- Audit and debug — Track context for each billable action
Timestamp Validation
Thetimestamp field determines which billing period an event falls into. Monk enforces the following rules:
- If omitted, defaults to the current time (UTC)
- Must be a valid ISO 8601 string (e.g.
2026-03-06T14:30:00Z) - Must not be more than 1 hour in the future — events with timestamps further ahead are rejected with a validation error
Idempotency
Idempotency keys prevent duplicate events from affecting billing.How It Works
- You send an event with
"idempotencyKey": "evt_123" - Monk accepts the event and stores it
- If you retry with the same key, Monk accepts the request again (no error) — the latest version of the event becomes the source of truth
- Only one copy of the event is counted toward billing
Best Practices
- Event type:
api_call_... - Customer:
..._cust123_... - Unique identifier:
..._req456or timestamp
Event Matching
For an event to affect billing, the following must be true:- Customer must exist in Monk
- Customer must have an active contract
- The contract must include a meter that matches the event (via event type filters and/or property filters)
- The event timestamp must fall within an active billing period
Best Practices
High-Volume Ingestion
Use the batch endpoint
Use the batch endpoint
For bulk imports or high throughput, use
POST /v1/events/batch to send up to 10,000 events per request.Implement client-side buffering
Implement client-side buffering
Buffer events in your application and flush every few seconds rather than sending one at a time.
Fire and forget
Fire and forget
Don’t block your application waiting for the Events API. Send asynchronously and handle failures in the background.
Reliability
Always use idempotency keys for retries
Always use idempotency keys for retries
Include
idempotencyKey when implementing retry logic to prevent duplicate
billing.Implement exponential backoff
Implement exponential backoff
On transient failures (5xx errors), retry with increasing delays: 1s, 2s,
4s, etc.
Don't retry client errors
Don't retry client errors
4xx errors (validation, auth) won’t succeed on retry. Log them and
investigate.
Data Quality
Include meaningful properties
Include meaningful properties
Add context that helps with debugging, analytics, and future billing
flexibility.
Use consistent event names
Use consistent event names
Event names are case-sensitive.
api_call ≠ API_CALL ≠ apiCall.Send events in real-time when possible
Send events in real-time when possible
Real-time events give customers accurate usage visibility and prevent
billing surprises.
Next Steps
Send Your First Event
Step-by-step guide to sending events
Events API Reference
Full API specification
List Events
Query and paginate through events
Batch Events
Send multiple events at once
Meters
Learn how meters aggregate events