Skip to main content

Integrations

Rebuild the figures

Re-import a site's revenue from the provider, keeping the connection.

POST/sites/{siteId}/integrations/{provider}/resync
Rebuild the figures
curl --request POST \
  --url 'https://truestat.io/api/v1/sites/{siteId}/integrations/{provider}/resync' \
  --header 'Authorization: Bearer <token>'
{
  "data": {
    "backfill": {
      "state": "queued"
    },
    "provider": "stripe"
  },
  "meta": {
    "site_id": "6fed8980-a119-4a9c-a4d4-53e448ef9f9e"
  }
}

Re-imports the site's revenue from the beginning, keeping the connection.

This is the call for the numbers look wrong. The key, the webhook and the secret all stay; only the derived figures are rebuilt.

Re-sync or disconnect?

Re-syncDisconnect
The connectionkeptremoved
The webhook at your providerkeptdeleted
Stored paymentsrebuiltdeleted
Lifecycle historykeptgone for good

If the goal is correct figures, this is the endpoint. Disconnecting and reconnecting also rebuilds the payments — and permanently loses the history described below.

What no re-sync can rebuild

Payments can be read back from your provider whenever we like. Some things cannot:

  • an upgrade or downgrade

  • a pause and a resume

  • a trial converting to a paying subscription

Those exist only because a webhook arrived at the moment they happened. A provider's API can tell you what a subscription looks like now, not that it changed at 14:02 on a Tuesday.

So they are deliberately kept rather than purged. A re-sync clears the two lifecycle events an import can genuinely reproduce — a subscription starting and ending — and leaves the rest alone.

Why it takes a moment

The order matters, and each step is there because skipping it has produced a real failure:

Clear the stored payments

In both stores, not one. Clearing only one leaves the figures either doubled or empty, depending which one was missed.

Wait for that to finish

The purge runs in the background. An import starting while it is still running has its fresh rows deleted too — and every step reports success while the panel ends up empty.

Queue the import

From the beginning, not from where the last one stopped. Resuming would skip everything already walked, which is the opposite of re-syncing.

The response returns once the queue is set, with backfill.state: "queued". Watch GET /integrations for it to finish.

The provider in the path must match

A site holds one connection. Naming a provider that is not the one attached answers 404 rather than re-syncing whatever happens to be there.

Authorizations

Authorizationstringheaderrequired

An API key from Settings → API keys. Scopes available: analytics:read, sites:read, sites:write, settings:read, settings:write, goals:read, goals:write, funnels:read, funnels:write, notes:read, notes:write, alerts:read, alerts:write, team:read, team:write, revenue:read, revenue:write.

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path parameters

siteIdstring (uuid)pathrequired
The site's id, from `GET /sites`. A site that is not yours and a site that does not exist both answer 403, so this cannot be used to discover other people's ids.
providerstringpath
Must match the provider actually connected, or the call is a 404.

Response

application/json

The answer.

dataobject
metaobject