Skip to main content

Widget

Configure the widget

Create it, change what it draws, or switch it on.

PUT/sites/{siteId}/widget
Configure the widget
curl --request PUT \
  --url 'https://truestat.io/api/v1/sites/{siteId}/widget' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "type": "realtime",
  "metric": "online",
  "enabled": false,
  "chart_style": "bar",
  "publish_revenue": false
}'
{
  "data": {
    "url": "/widget/w_7zbahifpaj7frk2k",
    "slug": "w_7zbahifpaj7frk2k",
    "type": "analytics",
    "metric": "visitors",
    "enabled": true,
    "created_at": "2026-09-14T12:00:00.000Z",
    "updated_at": "2026-09-16T19:00:00.000Z",
    "view_count": 0,
    "chart_style": "area",
    "publish_revenue": false
  },
  "meta": {
    "site_id": "6fed8980-a119-4a9c-a4d4-53e448ef9f9e"
  }
}

See Embeddable widget for why it starts off, what the first-event gate protects, and the difference between switching it off and removing it.

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.

Request bodyapplication/json

typeenum<string>body
Which card to draw.
options:realtimerecentanalyticsrevenue
metricenum<string>body
Which number to show. `online` is the ten-minute window rather than the thirty-minute one.
options:onlinevisitorsviews
enabledbooleanbody
Whether the card is public. Switching it on needs at least one recorded event.
chart_styleenum<string>body
How the chart is drawn.
options:bararea
publish_revenuebooleanbody
Whether takings appear on the public card. Off unless asked for.

Response

application/json

The answer.

dataobject
metaobject