Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Analytics

Sync revenue now

Reads new payments from every connected provider now. (The ticker also reads them every 5 minutes.) Then it ties each payment to the visitor who paid. It uses the troopy_visitor_id in the metadata, the checkout id that the script saw, or the email that the site gave to troopy("payment"). Each payment counts once.

post/api/v1/analytics/revenue/sync

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 revenue sync
MCP toolNone. Call it over REST or with the CLI.
Rate limit6 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.

Query parameters

fromstring

Read the history again from this day (YYYY-MM-DD), at most 2 years back. Payments that Troopy counted stay counted one time

date

Response

200 · application/json
data*object
7 properties
syncedAt*string | null
attributed*integer

Payments that Troopy tied to a visitor, all time

unattributed*integer

Payments of the last 30 days that Troopy could not tie to a visit

unattributedRevenue*integer

The sum of those payments, in minor units

missing*string | null

The reads that the keys do not have, with the provider of each, like "Refunds in Polar". Give each key those reads, or replace it

error*string | null
subscriptions*object | null

The sum of the subscriptions of every connected provider. Troopy reads them once an hour at most. null before the first read

8 properties
mrr*integer

Monthly recurring revenue, in minor units: active and past-due subscriptions, after their coupons

mrrBefore*integer | null

MRR about 30 days ago, if Troopy has that history

currency*string | null
subscribers*integer
trials*integer | null

Subscriptions in their free trial. null on a reading from before Troopy counted trials

churnRate*number

The share of the subscriptions that paid 30 days ago and ended since, 0 to 1. A trial counts from its first payment

ltv*integer | null

Revenue per subscriber divided by the monthly churn, in minor units

at*string

ISO 8601 date and time

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.