Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Analytics

Change the analytics settings

Changes what analytics counts: the domain, other hostnames, cookieless tracking, attack mode, exclusions, the main KPI and the colour of the bars. Each list of exclusions replaces the old one. It also changes the weekly and monthly email reports, their other addresses, the alerts of spikes and drops, and the GitHub repo and branch whose commits show on the chart. share on gives the dashboard a public read-only link, and off takes the link away. reset makes a new link, and the old link no longer opens. Only owners and admins change share.

patch/api/v1/analytics/site

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 settings
MCP toolNone. Call it over REST or with the CLI.
Rate limit30 calls in 60 seconds, for each key

Body

application/json
domainstring

The root domain, like acme.com

At least 3 characters · At most 253 characters

allowedHostnamesarray<string>

At most 20 items

cookielessboolean
attackModeboolean
excludeobject
4 properties
pathsarray<string>

Paths that analytics never counts. /admin is that page only, and /admin/* is every page under it

At most 50 items

ipsarray<string>

At most 50 items

countriesarray<string>

ISO 3166-1 alpha-2 codes

At most 250 items

hostnamesarray<string>

At most 50 items

kpistring

revenue, mrr, or the name of a goal

colorenum<string>

The colour of revenue on the charts and cards of the dashboard

redcoralpinkambergreentealblueindigovioletslate

shareenum<string>

onoffreset

shareForenum<string>

How long the public link opens from now: 24h, 7d, 14d, 30d, 90d, or never. It comes with share on or reset

24h7d14d30d90dnever

sharePasswordstring | null

A password that the public link asks for, 6 characters at least. null takes it away. A frame in another page cannot open a link with a password

shareSegmentstring | null

The id of a saved segment that the public link always shows. null: all visitors

weeklyReportboolean
monthlyReportboolean
reportEmailsarray<string>

More addresses for the reports and the traffic alerts, 10 at most. Each list replaces the old one. Only owners and admins change it

At most 10 items

spikeAlertsboolean
dropAlertsboolean
githubRepostring | null

owner/name: one of the repos that the GitHub connection of the workspace reaches. With null, the chart shows no commits

githubBranchstring | null

The branch of the repo whose commits show on the chart, like production. Null, or no branch with a new repo: the default branch. A new repo or branch takes the commits of the old one off the chart

mentionsobject

What to look for on X and Reddit besides the domain

2 properties
keywords*array<string>

4 to 15 characters each, any case

At most 10 items

handles*array<string>

X handles whose posts and bio links count, like @acme

At most 5 items

proxystring | null

A subdomain of the site for the managed proxy, like a.acme.com. Point its CNAME at proxy.troopy.ai. null takes the proxy away

Response

200 · application/json
data*object
23 properties
siteId*string

The public id that the tracking script sends

domain*string

The root domain: every subdomain counts too

allowedHostnames*array<string>

Other domains that count as this site

cookieless*boolean
attackMode*boolean

Stricter bot filters, for a site under attack

replays*boolean

Session replays and heatmaps of a share of the visits (PATCH /session-settings). The tag carries data-replay with the share

replaySample*number

The share of visits that replays record, 0.01 to 1

exclude*object
4 properties
paths*array<string>

Paths that analytics never counts. /admin is that page only, and /admin/* is every page under it

At most 50 items

ips*array<string>

At most 50 items

countries*array<string>

ISO 3166-1 alpha-2 codes

At most 250 items

hostnames*array<string>

At most 50 items

kpi*string

What the dashboard leads with: revenue, mrr, or the name of a goal

color*enum<string>

The colour of revenue on the charts and cards of the dashboard

redcoralpinkambergreentealblueindigovioletslate

script*string

The tag to paste into the <head> of every page

timezone*string

The days of reports start at midnight in this time zone

share*object | null

The read-only dashboard that anyone with the link can open

4 properties
url*string

Add ?embed=true to show it in a frame of another page

until*string | null

When the link stops opening, or null when it never stops

password*boolean

Whether the link asks for a password

segment*string | null

The saved segment that the link always shows, or null for all visitors

hasEvents*boolean

Whether the script sent anything yet

weeklyReport*boolean

A weekly summary by email to the owners and admins of the organization, on Monday morning

monthlyReport*boolean

A monthly summary by email, on the morning of the first day of the month

reportEmails*array<string>

More addresses that get the reports and the traffic alerts, besides the owners and admins

spikeAlerts*boolean

An email to owners and admins when visits jump well above the usual

dropAlerts*boolean

An email to owners and admins when the pageviews of the last 12 hours fall far under the usual

githubRepo*string | null

The repo whose commits show as notes on the chart (owner/name)

githubBranch*string | null

The branch of that repo whose commits show. Null: the default branch

mentions*object

Words and X handles that Troopy finds on X and Reddit, as well as the domain. Posts that name them show as notes on the chart

2 properties
keywords*array<string>
handles*array<string>
proxy*object | null

The managed proxy: the script and events on a subdomain of the site, so ad blockers leave them alone

5 properties
host*string

The subdomain of the site that serves the script, like a.acme.com

status*enum<string>

pending until a check finds the CNAME and the script over HTTPS

pendingactivefailed

error*string | null

What the last check found missing

checkedAt*string | null
target*string

Where the CNAME of the host points, like proxy.troopy.ai

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.
429 rate_limitedWait the number of seconds in Retry-After, then retry.