Skip to main content

API Reference

Direct HTTP API for sending events to Mostly Good Metrics.

Authentication

All requests require an API key in the Authorization header:

Authorization: Bearer mgm_proj_your_api_key

Endpoints

POST /api/events

Send one or more events.

Request:

curl -X POST https://ingest.mostlygoodmetrics.com/api/events \
-H "Authorization: Bearer mgm_proj_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"name": "button_clicked",
"user_id": "user_123",
"timestamp": "2024-01-15T10:30:00Z",
"properties": {
"button_name": "signup"
}
}
]
}'

Response:

{
"success": true,
"events_received": 1
}

Event Schema

FieldTypeRequiredDescription
namestringYesEvent name
user_idstringNoUser identifier
timestampstringNoISO 8601 timestamp (defaults to now)
propertiesobjectNoCustom properties
session_idstringNoSession identifier

Rate Limits

PlanRate Limit
Free100 requests/minute
Pro1000 requests/minute
EnterpriseCustom

When rate limited, you'll receive a 429 response with a Retry-After header.

Compression

For payloads > 1KB, use gzip compression:

curl -X POST https://ingest.mostlygoodmetrics.com/api/events \
-H "Authorization: Bearer mgm_proj_your_api_key" \
-H "Content-Type: application/json" \
-H "Content-Encoding: gzip" \
--data-binary @events.json.gz

Error Responses

StatusMeaning
400Invalid request body
401Invalid or missing API key
429Rate limited
500Server error
{
"success": false,
"error": "Invalid API key"
}