Events API
POST /api/v1/events takes page views, your product's events, errors, payments and crawler visits, one at a time or a hundred in a batch, live.
POST https://mettr.app/api/v1/events takes one event, or {"events": [...]} with up to 100. It answers 202 with how many it accepted, and they are on the dashboard's feed within a second or two. Keys, limits and errors are in the API overview.
One event
curl https://mettr.app/api/v1/events \ -H "Authorization: Bearer $METTR_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "event", "name": "upgrade", "user_id": "4821", "url": "https://example.com/billing", "props": {"from": "free", "to": "pro", "seats": 3} }'
{"accepted": 1}
A batch
{ "events": [ {"type": "pageview", "url": "https://example.com/pricing", "referrer": "https://news.ycombinator.com/", "ip": "203.0.113.7", "user_agent": "Mozilla/5.0 ..."}, {"type": "event", "name": "signup", "user_id": "4821", "props": {"plan": "pro"}}, {"type": "error", "name": "PaymentFailed", "url": "https://example.com/pay"} ] }
The batch is taken whole or not at all: one event that does not fit refuses all of them, with its errors named by its place (events.2.name), so nothing is lost without your knowing.
Fields
| Field | Type | Key | What it is |
|---|---|---|---|
type |
string | any | Required. One of the types below |
name |
string | any | The event's name, up to 100 characters. Required for event, error and revenue |
url |
string | any | The page it happened on, up to 8,000 characters. Required for pageview |
referrer |
string | any | Where the visitor came from, for a page view |
props |
object | any | Flat props: up to 30 (below) |
ts |
string | secret | When it happened, ISO 8601 (2026-12-01T09:30:00Z), up to 7 days back. Now when left out |
user_id |
string | secret | Your own id for the signed-in person, up to 191 characters |
ip |
string | secret | The visitor's address, for the place and the visit. Never stored |
user_agent |
string | secret | The visitor's browser, for the device and bot checks |
revenue |
object | secret | {"amount": 49.00, "currency": "USD"}, for type revenue only |
With a public key, the body also carries "key": "pk_...".
Props
Up to 30 an event, each named with 1 to 64 letters, digits, _, . or -, each a string (up to 500 characters), a number, a boolean or null. No nested objects or lists: a prop is something to group and filter by (plan, format, source), so keep values few and repeated. Never put an email, a token or anything secret in a prop.
Types
| Type | Sent by | What it is |
|---|---|---|
pageview |
script or server | A page seen |
event |
script or server | Your product's own: signup, export, invite.sent |
error |
server | Something broke: 404, an exception's class, a failed job |
revenue |
server | A payment or a refund (negative), with its amount and currency |
engagement |
script | How a page was read as it was left: props scroll (percent) and ms (time in use) and nothing else |
presence |
script | The heartbeat that says who is online. Not stored |
crawl |
server | A crawler's request as your server saw it: url, user_agent and the prop status (the HTTP status) alone |
engagement, presence and crawl are not counted toward your plan, and neither are events flagged as bots.
Visitors, and the address
mettr tells visitors apart by a hash of the site, the address and the user agent with a salt of the day, and deletes each day's salt after 8 days, so the same person is a new visitor the next day and nobody can be followed across days or sites. The address finds the place (country, region, city) and the network, then it is dropped: it is never written to the database, a log or a queue.
From the browser, mettr sees the visitor's address itself. From your server, send ip and user_agent with each event, or it is placed where your server is. An event with neither is still counted, with no place and no visitor.
Bots
Every event is checked as it arrives: known crawlers, automated browsers, hosting networks, scanners probing for wp-login.php. A bot's events are kept, flagged with the reason, and left out of every number, so a rule that changes later can be applied to the past. Send what you see; mettr sorts it.
Revenue events
A payment as it happens, for the feed and for revenue panels when your billing is not one mettr reads:
{"type": "revenue", "name": "payment", "user_id": "4821", "revenue": {"amount": 49.00, "currency": "EUR"}}
For recurring revenue (MRR), send subscriptions instead: see Subscriptions API, or connect Stripe or Paddle.
Updated · This page as Markdown · Something unclear? [email protected]