Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Analytics

Record visits from a server

Records pageviews and goals that a server saw, 500 at most in one call. Use it for a site without the script, for an app, or to send past visits again, up to 30 days back. Each event passes the same checks as the script: the domain, bots, exclusions and rate limits. Send the user agent and the address of the visitor. Troopy reads the place from the address and never keeps it. Without a visitor id, Troopy makes one from the address and the user agent, which changes each day. dropped says which events did not count, and why.

post/api/v1/analytics/events

Authorization

HeaderAuthorization: Bearer <API key>
Or the headerX-API-Key: <API key>
API keyMake one in Troopy under Settings > API keys. It acts as you, in its workspace.

Other ways to call it

CLItroopy analytics events
MCP toolNone. Call it over REST or with the CLI.
Rate limit60 calls in 60 seconds, for each key
RetriesSend an Idempotency-Key header. A retry with the same key gets the first answer back, and the operation runs one time.

Body

application/json
events*array<object>

At most 500 items

11 properties
type*enum<string>

pageviewgoal

url*string

The address of the page, on the domain of the site

At most 2000 characters · uri

namestring

Goals only: the name of the goal

paramsobject

Goals only: 10 at most. Troopy keeps them as text

referrerstring | null
userAgent*string

The User-Agent header of the visitor

At most 500 characters

ipstring | null

The address of the visitor, for the country and the city

visitorstring

Your own id of the visitor, the same on each visit

sessionstring

Your own id of the visit. Without it, the visitor id is the visit

langstring

The language of the visitor, such as en-US

At most 35 characters

atstring

When it happened, 30 days back at most. Without it, now

Response

200 · application/json
data*object
2 properties
accepted*integer
dropped*array<object>

The events that did not count, by their place in events

2 properties
index*integer
reason*string

Errors

400 invalid_inputFix the field named in detail. Each operation's schema is in /api/v1/openapi.json.
401 unauthorizedSend an API key as `Authorization: Bearer tr_live_...`. Create one in Troopy under Settings.
403 forbiddenThe key lacks a scope this operation needs, or its owner lacks the role. detail says which; create a key with the scope, or ask an organization owner or admin.
409 conflictThis Idempotency-Key was used for a different request, or that request is still running. Use a new key for a new request.
429 rate_limitedWait the number of seconds in Retry-After, then retry.