Skip to main content

Send Usage Events

Send usage events to Alguna to power usage-based billing. Events are aggregated according to your billable metrics and automatically appear on customer invoices.

Event Structure

Events are the basic unit of billable usage. Each event represents a single action a customer may be billed for.

Required Fields

FieldTypeDescription
uniqueIdstringUnique identifier for deduplication
eventNamestringEvent type (matches your metric)
accountIdstringCustomer ID or alias
timestampISO 8601When the event occurred
propertiesobjectEvent data for filtering/aggregation

Example Event


Send via API

The recommended method for real-time event ingestion.

Single Event

Batch Events

Send multiple events in a single request (recommended for high volume):

cURL Example

Response


Send via CSV

Upload CSV files for batch ingestion or historical data.

CSV Format

Upload via Dashboard

  1. Navigate to Usage Metering in the dashboard
  2. Click Upload CSV
  3. Select your CSV file
  4. Map columns to fields
  5. Click Upload

Upload via API

CSV Best Practices

  • Maximum file size: 100MB
  • Maximum rows per file: 1,000,000
  • Use ISO 8601 timestamps
  • JSON-encode properties column
  • Include header row

Send via Data Sources

Connect external data sources for automated ingestion.

BigQuery Integration

Supported Data Sources

SourceDescription
BigQueryGoogle BigQuery tables
SnowflakeSnowflake data warehouse
PostgreSQLDirect database connection
S3AWS S3 buckets (CSV/JSON)
SegmentSegment events
WebhooksIncoming webhooks
See Data Ingestion for detailed setup.

Customer Identification

Using Alguna Account ID

Using External ID (Alias)

Use your own customer identifiers:

Using Multiple Aliases


Idempotency & Deduplication

Unique ID Requirements

The uniqueId field prevents duplicate processing:

Deduplication Window

Events with the same uniqueId are deduplicated within a 7-day window.

Upsert Mode

Update existing events by using the same uniqueId:

Timestamps

Requirements

  • Must be ISO 8601 format
  • Must be within the current or previous billing period
  • Future timestamps are rejected

Examples

Backdating Events

Ingest historical events (within billing period):

Properties

Properties carry event data used for filtering and aggregation.

Common Property Patterns

Property Types

TypeExampleUse Case
String"us-east-1"Filtering, grouping
Number1024Aggregation (sum, max)
BooleantrueFiltering

Nested Properties


Error Handling

Validation Errors

Common Errors

ErrorCauseSolution
INVALID_TIMESTAMPWrong format or future dateUse ISO 8601, current/past dates
ACCOUNT_NOT_FOUNDUnknown accountIdCreate account or check alias
DUPLICATE_EVENTSame uniqueId processedUse unique IDs per event
INVALID_PROPERTIESNon-JSON propertiesEnsure valid JSON structure

Retry Strategy


High-Volume Ingestion

Batch Recommendations

VolumeBatch SizeFrequency
< 1,000/min1-100Real-time
1,000-10,000/min100-500Every 1-5 seconds
> 10,000/min500-1,000Continuous batching

Async Ingestion

For very high volume, use async mode:

Rate Limits

TierRequests/secEvents/request
Standard1001,000
Enterprise50010,000

Query Usage

Current Period Usage

Usage History

Usage by Property


Webhooks

EventDescription
usage.recordedEvent processed (opt-in)
usage.threshold_exceededUsage exceeded threshold

Threshold Alerts


Best Practices

Batch Events

Send events in batches for better performance.

Unique IDs

Generate truly unique IDs to prevent duplicates.

Accurate Timestamps

Use the actual event time, not ingestion time.

Rich Properties

Include properties needed for filtering and aggregation.

Troubleshooting

Events Not Appearing

  1. Check event timestamp is within billing period
  2. Verify accountId exists or alias is configured
  3. Confirm eventName matches your metric
  4. Review API response for errors

Usage Shows Zero

  1. Verify events are being sent successfully
  2. Check metric configuration and filters
  3. Confirm event properties match metric requirements

Duplicate Charges

  1. Ensure uniqueId is truly unique per event
  2. Check for duplicate event sends in your code
  3. Review event logs for repeated ingestion

Next Steps

Define Metrics

Configure billable metrics.

Metrics Reference

Complete metrics configuration guide.