Import API
POST /api/v1/import brings in your history from before mettr, a thousand events a batch, each with its own id so a second run adds nothing twice.
Your dashboard can start with years behind it, not on the day you installed the script. POST https://mettr.app/api/v1/import takes past events with a secret key, in batches of up to 1,000.
On Laravel with spatie/laravel-activitylog, the Laravel SDK does all of this with one command.
A batch
curl https://mettr.app/api/v1/import \ -H "Authorization: Bearer $METTR_SECRET_KEY" \ -H "Content-Type: application/json" \ --data-binary @batch.json
{ "events": [ {"source_id": "log-10231", "type": "pageview", "ts": "2025-03-14T09:26:53Z", "url": "https://example.com/docs", "referrer": "https://www.google.com/", "ip": "203.0.113.7", "user_agent": "Mozilla/5.0 ..."}, {"source_id": "log-10232", "type": "event", "ts": "2025-03-14T09:27:10Z", "name": "signup", "user_id": "4821"} ] }
{"accepted": 2}
How it differs from live events
source_idis required: your own id for the row (up to 100 characters). An event already imported with the same id andtsis not added again, so a run that stopped can be run again from the start.tsis required, and may reach back as far as your plan's history: one month on Free, two years on Pro, five on Business. An older event refuses the batch with422, naming it.- Every type but
presenceandcrawl. The fields are those of the Events API. - Up to 1,000 events a batch, 2 MB as sent and 8 MB unzipped.
- Imported events are not counted toward the month's events and not shown in the live feed as they arrive.
- They go through the same checks as live ones: places from addresses (then dropped), visitors, sessions, bots. Send the
ipanduser_agentyou logged, if you did, and the history reads like live traffic.
Before and after
If the site already sends live events, import only what came before: stop the import at the moment the script or SDK started, or those hours are counted twice.
Run a small batch first and check it on the dashboard (set the range to its days). Then send the rest in order, oldest first, one batch at a time; a 429 means wait a moment and send the same batch again.
Updated · This page as Markdown · Something unclear? [email protected]