Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Analytics

Record a payment

Records a payment from a provider that Troopy does not read, or from your own webhook. Troopy ties it to the visitor who paid. It uses the visitor's id (the troopy_visitor_id cookie), or else the earlier payments of the customer, or else the email that the visitor gave to troopy("payment"). Each transactionId counts once. If Troopy cannot tie a payment to a visit yet, the payment shows as unattributed. Send it again later to try again. With refund, it records money that went back: the chart shows it beside the revenue, and revenue stays as it was.

post/api/v1/analytics/payments

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 payments record
MCP toolNone. Call it over REST or with the CLI.
Rate limit600 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
transactionId*string

The payment's id in your billing system: it counts once

At least 1 characters · At most 255 characters

amountnumber

In major units, like 29.99. 0 for a free trial. Give amount or amountMinor

At least 0 · At most 1000000000

amountMinorinteger

In minor units, like 2999 for 29.99 USD, as most webhooks send it. Give amount or amountMinor

At least 0 · At most 100000000000

currency*string

ISO 4217, like USD

visitorstring

The visitor's id, as the script or SDK sent it

emailstring

The customer's email

At most 320 characters · email

namestring

The name of the customer. It names a visitor that identify did not name

At least 1 characters · At most 100 characters

customerstring

The customer's id in your billing system: a renewal finds its visitor by it

At least 1 characters · At most 255 characters

renewalboolean

A subscription that renews. It also counts as Subscription renewed

trialboolean

The start of a free trial. true when amount is 0

refundboolean

Money that went back to the customer, not a payment. The amount is what went back. Its transactionId is the id of the refund

atstring

When the customer paid, or when the money went back. Without it, Troopy uses now

date-time

providerenum<string>

For a payment that Troopy also reads from a connected provider. Give the provider, and the id of the payment as Troopy reads it (Lemon Squeezy: order_<id>). Then the payment counts one time, and the visitor of your webhook ties it to a visit

stripelemonsqueezypolarpaddle

Response

200 · application/json
data*object
1 properties
status*enum<string>

Recorded on a visitor, already recorded, or not tied to a visit yet

recordedknownunattributed

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.